Repository navigation
fix(a2a_agent): a trajectory follower ends with its step - #618
Merged
Merged
Conversation
andrewpark-scaleai
enabled auto-merge (squash)
November 11, 2026 17:34
earakely-scale
approved these changes
Nov 11, 2026
… leaves its follower running
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A live trajectory follower can outlive the step that started it. On the agent-env workers, 26 followers kept polling agents that had already gone away, on 11 pods. Each one holds a Temporal activity slot and logs
Live trajectory read failedabout 5 times a second. Two bugs combine:asyncio.wait_fordrops the cancel. A step's teardown setsstopand cancels the follower in the same tick. If the follower is waiting inwait_for(stop.wait())at that moment, 3.11 returns normally and swallows the cancel. The workers run 3.11.stopis set, a failed read retries every 0.2 s with no limit. An agent that is gone never answers, so the follower loops until it is cancelled. When the cancel was dropped, it loops forever, andfollowing_live_trajectory'sawait asyncio.wait(turn.followers)hangs the step with it.What
asyncio.timeout, which does not drop a cancel.stopis set, a failed read ends following. The turn has ended by then, so an agent that stops answering is gone, not busy.following_live_trajectoryalready marks a turn's end when its follower stops early, and the final trajectory still holds every event.Validation
I ran a step against an agent that closes every connection, on the deployed worker image (Python 3.11.15, agentenv-framework 0.9.1490). The step either was cancelled, raised, or returned.
Two new unit tests:
test_a_follower_cancelled_as_it_is_stopped_endsfails on the old follower under 3.11 and passes under 3.12, wherewait_forwas fixed. CI runs 3.12, so it guards only a 3.11 run.test_an_agent_that_fails_after_the_turn_ends_ends_followingfails on the old follower under both versions.With the change, the follower and live-trajectory tests pass on 3.11 and 3.12 (31 each).
In the full unit suite, 14,522 tests pass. The 1 failure,
test_mcp_cli_builder.py::test_codegen_loads_sibling_env_file, fails on main too, because its subprocess can't importhttpxhere.

Confidence Score: 5/5
The PR appears safe to merge; both previous test issues are fixed.Summary
The PR keeps trajectory followers from outliving their steps:
Both previous findings are addressed. No new actionable issues were found in the changes since the previous review. Tests were not run during this review.
Reviews (2) · Last reviewed commit: "test: the cancel test fails when only th..." · Reviewed by Greptile