Skip to content

fix(agents): only stop ParallelAgent on direct sub-agent escalation - #1491

Merged
copybara-service[bot] merged 1 commit into
google:mainfrom
mithun-sudo:fix/parallel-agent-nested-escalation
Sep 21, 2026
Merged

copybara-service[bot] merged 1 commit into
google:mainfrom
mithun-sudo:fix/parallel-agent-nested-escalation

Conversation

@mithun-sudo

@mithun-sudo mithun-sudo commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Match adk-python: nested escalate events must not cancel sibling branches. Adds regression test for LoopAgent nested under ParallelAgent.

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

Problem:
ParallelAgent stops all parallel branches when any event has escalate=true, including escalation from nested sub-agents (e.g. an agent inside a LoopAgent sub-branch). adk-python only stops when the escalating event's author is a direct sub-agent (_asks_this_agent_to_exit).

Solution:
Filter takeUntil with asksThisAgentToExit(), which requires both escalate=true and event.author() in the set of direct sub-agent names. Matches adk-python parity without changing behavior for direct sub-agent escalation (existing test still passes).

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

Summary:

  • ./mvnw -pl core clean compile test -Dtest=ParallelAgentEscalationTest2 tests passed
  • ./mvnw -Prelease clean packageBUILD SUCCESS
  • Verified regression: runAsync_nestedLoopEscalation_keepsSiblingBranchesRunning fails on main (stream completes after 1 nested escalate) and passes with this change
  • runAsync_escalationEvent_shortCircuitsOtherAgents still passes (direct sub-agent escalate still short-circuits siblings)

Manual End-to-End (E2E) Tests:

Not applicable — behavior covered by unit tests; no user-facing API or runtime config change.

Checklist

  • I have read the CONTRIBUTING.md document.
  • My pull request contains a single commit.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Additional context

Python reference:

  • src/google/adk/agents/parallel_agent.py_asks_this_agent_to_exit
  • tests/unittests/agents/test_parallel_agent.pytest_run_async_keeps_siblings_when_a_nested_loop_ends_itself

@hemasekhar-p hemasekhar-p self-assigned this Sep 10, 2026
@hemasekhar-p
hemasekhar-p force-pushed the fix/parallel-agent-nested-escalation branch from 30bda8e to 47810f7 Compare September 10, 2026 05:58
@hemasekhar-p

Copy link
Copy Markdown
Contributor

Hi @mithun-sudo, thank you for your contribution. we appreciate you taking the time to submit this PR. It is currently under review by our team, and we will keep you updated if any additional information is required.

@wikaaaaa wikaaaaa left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution! LGTM, two minor comments.

Comment thread core/src/main/java/com/google/adk/agents/ParallelAgent.java Outdated
Comment thread core/src/main/java/com/google/adk/agents/ParallelAgent.java
@wikaaaaa wikaaaaa added waiting on reporter Waiting for reaction by reporter. Failing that, maintainers will eventually closed it as stale. and removed needs review labels Sep 17, 2026
@mithun-sudo
mithun-sudo force-pushed the fix/parallel-agent-nested-escalation branch from 47810f7 to daecb5b Compare September 18, 2026 08:25
@wikaaaaa

Copy link
Copy Markdown

@mithun-sudo thanks, approved. Can you please merge the latest changes from main into this branch? Its currently out-of-date.

Match adk-python: nested escalate events must not cancel sibling branches.
Adds regression test for LoopAgent nested under ParallelAgent.
@mithun-sudo
mithun-sudo force-pushed the fix/parallel-agent-nested-escalation branch from daecb5b to fc3e352 Compare September 21, 2026 10:18
@mithun-sudo

Copy link
Copy Markdown
Contributor Author

@wikaaaaa Thanks for reviewing the PR. Rebased onto latest main

@wikaaaaa wikaaaaa added ready to pull and removed waiting on reporter Waiting for reaction by reporter. Failing that, maintainers will eventually closed it as stale. labels Sep 21, 2026
@copybara-service
copybara-service Bot merged commit 87c0433 into google:main Sep 21, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ParallelAgent stops sibling branches on nested sub-agent escalation

3 participants