Runner test contract: refetch session snapshot before post-run assertions #4551
davidahmann
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Problem observed
Runner tests can hold an earlier in-memory session object and assert event counts after
run_async. Because the in-memory service returns copies, those handles can be stale immediately after persistence operations. This creates false-negative assertions that look like persistence bugs, even when the authoritative session state is correct when re-fetched from the session service.Why it matters operationally
For ADK, replay and session correctness are contract-critical. Test patterns that read stale snapshots can produce misleading signals and waste triage time. Explicitly codifying re-fetch-before-assert behavior strengthens deterministic event-contract testing and reduces flaky interpretations in runner/session investigations, especially where invocation-level persistence timing is under review.
Minimal repro
Fix approach
We added a focused regression test that demonstrates the stale-handle behavior and enforces using a fresh session fetch for post-run assertions. The change is test-only, intentionally minimal, and tied directly to runner/session verification semantics. It does not alter runtime behavior; it codifies the correct assertion pattern for deterministic persistence checks.
Validation evidence
uv run pytest tests/unittests/test_runners.py -k refetched_session_snapshot -qpassed.test_runners.py.Open follow-up question for maintainers
Would you like a small shared helper for “re-fetch session before event-count assertions” so this contract is standardized across runner and session tests?
This contribution was informed by patterns from Gait: https://github.com/Clyra-AI/gait
Beta Was this translation helpful? Give feedback.
All reactions