Skip to content

Enforce deterministic persisted-event counts after run_async #4595

@davidahmann

Description

@davidahmann

Runner/session tests can misreport event totals when assertions rely on stale session snapshots, reducing confidence in replay behavior.

Current behavior is insufficient because post-invocation assertions sometimes count in-memory state that is no longer authoritative for persisted session events.

Why now: session replay and event-contract stability are core runtime guarantees and this failure pattern is recurring.

Claim-to-codepath map:

  • Invocation persistence flow in src/google/adk/runners.py.
  • Session storage/read paths in src/google/adk/sessions.
  • Assertions and fixtures in tests/unittests.

Requested behavior: tests re-fetch session state before counting events and demonstrate deterministic totals across repeated runs.

Evidence Packet

  • Commit under test: aa77920
  • Runtime environment:
    • OS: Darwin 25.3.0 arm64
    • Python 3.14.0
    • go version go1.25.7 darwin/arm64
    • Node: v22.19.0
  • Minimal repro:
    1. Follow the repo's current local validation/CI-triage path.
    2. Observe the behavior described above for this issue.
  • Expected behavior: deterministic, documented behavior matching acceptance criteria below.
  • Actual behavior: behavior can be inconsistent for the scenario described above.

Acceptance Criteria

  • Implement the smallest code change that addresses the proven pain point.
  • Add focused regression test coverage for the changed behavior.
  • Ensure backward compatibility expectations are explicit in tests/docs.

Metadata

Metadata

Assignees

Labels

core[Component] This issue is related to the core interface and implementationrequest clarification[Status] The maintainer need clarification or more information from the author

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions