Skip to content

fix(agents): prevent premature end_of_agent on sub-agent pause#5716

Open
kyson-dev wants to merge 2 commits into
google:mainfrom
kyson-dev:fix-llm-agent-lro-resume
Open

fix(agents): prevent premature end_of_agent on sub-agent pause#5716
kyson-dev wants to merge 2 commits into
google:mainfrom
kyson-dev:fix-llm-agent-lro-resume

Conversation

@kyson-dev
Copy link
Copy Markdown

🔴 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 orchestrating LlmAgent incorrectly sets end_of_agent=True for 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:

  1. ResumabilityConfig(is_resumable=True) is used.
  2. An orchestrator LlmAgent delegates to a sub-agent with LRO tools.
  3. The sub-agent pauses for human-in-the-loop (HITL) input and then resumes.

Expected Behavior:
The orchestrating agent should only set end_of_agent=True when 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:

  • Modified src/google/adk/agents/llm_agent.py's _run_async_impl to track pause_invocation during sub-agent execution, aligning its behavior with SequentialAgent and LoopAgent.
  • Added missing from __future__ import annotations to the new test file to comply with repo standards.

Testing Plan:

  • Added a new automated unit test: tests/unittests/agents/test_nested_agent_resume.py.
  • The test utilizes testing_utils.MockModel to deterministically simulate a deeply nested agent topology (Root -> Loop -> Sequential -> Worker) undergoing an LRO pause (via adk_request_confirmation).
  • The test strictly asserts that the orchestrator (Root) does not emit end_of_agent=True prematurely during the pause, and properly resumes upon receiving the human response.
  • Successfully ran ./scripts/unittests.sh with 100% test pass rate.
  • Ran pre-commit run locally to ensure all formatting (pyink, isort, license headers) is compliant.

Partially fixes #5349

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
@kyson-dev
Copy link
Copy Markdown
Author

Hi team! Just a quick heads up: the CI failure is throwing a 404 NOT_FOUND for gemini-2.5-pro inside
contributing/samples/adk_pr_triaging_agent/agent.py. It looks like an upstream config issue with the model availability in the runner,unrelated to my changes in this PR.

@rohityan rohityan self-assigned this May 18, 2026
@rohityan rohityan added needs review [Status] The PR/issue is awaiting review from the maintainer core [Component] This issue is related to the core interface and implementation labels May 18, 2026
@rohityan
Copy link
Copy Markdown
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.

@rohityan
Copy link
Copy Markdown
Collaborator

Hi @sasha-gitg , can you please review this.

@rohityan rohityan requested a review from sasha-gitg May 18, 2026 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core [Component] This issue is related to the core interface and implementation needs review [Status] The PR/issue is awaiting review from the maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sub-agent with sequential LRO tools fails to resume

2 participants