Fix: Sub-agent with sequential LRO tools fails to resume (Issue #5349)#5365
Draft
9chait9 wants to merge 2 commits intogoogle:mainfrom
Draft
Fix: Sub-agent with sequential LRO tools fails to resume (Issue #5349)#53659chait9 wants to merge 2 commits intogoogle:mainfrom
9chait9 wants to merge 2 commits intogoogle:mainfrom
Conversation
The sub-agent resumption logic was incorrectly marking the agent as finished even if the sub-agent had merely paused (e.g., to wait for a long-running operation). This change tracks whether the sub-agent paused, and only marks the agent as finished if no pause occurred. Fixes google#5349
…esume. Modified `_run_async_impl` in `llm_agent.py` to prevent premature `end_of_agent` marking when a sub-agent pauses for an LRO. Added `sub_agent_paused` tracking to ensure `end_of_agent=True` is only set if the sub-agent actually finished.
Collaborator
|
Response from ADK Triaging Agent Hello @9chait9, thank you for creating this PR! To help reviewers to review your PR more efficiently, could you please include a Thanks! |
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.
Fixes #5349
Change Summary
The issue was caused by an incorrect assumption in the orchestrator's flow control for sub-agents. When a sub-agent was resumed, the orchestrator unconditionally marked the sub-agent as finished (
end_of_agent=True) after therun_asyncgenerator finished.In the case of a sub-agent using LROs, the generator finishes when the sub-agent pauses. The orchestrator mistook this pause for agent completion. Consequently, when the user provided the response for the next LRO, the system replayed the stale
end_of_agent=Trueflag, causing the runner to terminate execution prematurely.The fix introduces a check to track if the sub-agent paused for an LRO.
end_of_agent=Trueis now only set if the sub-agent did not pause.