fix(agents): prevent premature end_of_agent on sub-agent pause#5716
Open
kyson-dev wants to merge 2 commits into
Open
fix(agents): prevent premature end_of_agent on sub-agent pause#5716kyson-dev wants to merge 2 commits into
kyson-dev wants to merge 2 commits into
Conversation
In nested multi-agent architectures, when a deep sub-agent triggers a Long-Running Operation (LRO) pause, the orchestrating LlmAgent incorrectly sets end_of_agent=True for itself upon the first resumption pause. This caused subsequent resumptions to silently fail. This fixes Issue google#5349 (Bug 2) by tracking pause_invocation during sub-agent execution, aligning LlmAgent behavior with SequentialAgent and LoopAgent. Partially fixes google#5349
Author
|
Hi team! Just a quick heads up: the CI failure is throwing a 404 NOT_FOUND for gemini-2.5-pro inside |
Collaborator
|
Hi @kyson-dev , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Your PR has been received by the team and is currently under review. We will provide feedback as soon as we have an update to share. |
Collaborator
|
Hi @sasha-gitg , can you please review this. |
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.
🔴 Required Information
Describe the Bug:
In nested multi-agent architectures (e.g.,
LlmAgent->SequentialAgent->LlmAgent), when a deep sub-agent triggers a Long-Running Operation (LRO) pause, the orchestratingLlmAgentincorrectly setsend_of_agent=Truefor itself upon the first resumption pause. This causes subsequent resumptions in the same invocation to silently fail.This PR addresses the "Bug 2" root cause detailed in Issue #5349.
Steps to Reproduce:
See Issue #5349 for the full reproduction script. The issue occurs when:
ResumabilityConfig(is_resumable=True)is used.LlmAgentdelegates to a sub-agent with LRO tools.Expected Behavior:
The orchestrating agent should only set
end_of_agent=Truewhen its sub-agent has genuinely completed execution, not when the sub-agent has paused to wait for tool confirmation.Observed Behavior:
The orchestrator immediately marks itself as finished upon the first LRO pause of its sub-agent, preventing the sub-agent from continuing its work after the first tool confirmation.
🟡 Optional Information
Proposed Changes:
src/google/adk/agents/llm_agent.py's_run_async_implto trackpause_invocationduring sub-agent execution, aligning its behavior withSequentialAgentandLoopAgent.from __future__ import annotationsto the new test file to comply with repo standards.Testing Plan:
tests/unittests/agents/test_nested_agent_resume.py.testing_utils.MockModelto deterministically simulate a deeply nested agent topology (Root->Loop->Sequential->Worker) undergoing an LRO pause (viaadk_request_confirmation).Root) does not emitend_of_agent=Trueprematurely during the pause, and properly resumes upon receiving the human response../scripts/unittests.shwith 100% test pass rate.pre-commit runlocally to ensure all formatting (pyink,isort, license headers) is compliant.Partially fixes #5349