Skip to content

Support sub-agent escalation event in ParallelAgent - #5105

Closed
jinnigu wants to merge 1 commit into
google:mainfrom
jinnigu:feature/subagent-escalation
Closed

jinnigu wants to merge 1 commit into
google:mainfrom
jinnigu:feature/subagent-escalation

Conversation

@jinnigu

@jinnigu jinnigu commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Please ensure you have read the contribution guide before creating a pull request.

Link to Issue or Description of Change

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

2. Or, if no issue exists, describe the change:

Problem:
ParallelAgent does not short-circuit when a sub-agent emits an escalation event (actions.escalate = True). Other sub-agents continue running to completion unnecessarily. This is the Python counterpart of google/adk-java#561, resolved in google/adk-java#612.

Solution:
When any sub-agent emits an escalation event, the ParallelAgent now yields the event, cancels all remaining sub-agent tasks, and marks itself as complete in resumable mode. This works for both the Python 3.11+ (TaskGroup) and pre-3.11 code paths.

Testing Plan

Unit Tests:

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

  • All unit tests pass locally.

  • test_run_async_short_circuits_other_agents_on_escalate_action — parameterized over is_resumable (True/False) x use_pre_3_11_merge (True/False) = 4 test variants. Verifies the slow agent is cancelled, post-escalation events are suppressed, correct event ordering, and proper end_of_agent state in resumable mode.

  • test_resumable_parallel_agent_escalation_short_circuits_persisted_run — integration test using InMemoryRunner that verifies events are correctly persisted to the session store and that re-running a completed escalated invocation is a no-op.

  • All 15 tests pass (12 in test_parallel_agent.py, 3 in test_resume_invocation.py), no regressions.

Manual End-to-End (E2E) Tests:

N/A — behavior is fully covered by unit and integration tests.

Checklist

  • I have read the CONTRIBUTING.md document.
  • 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

  • Java counterpart: google/adk-java#612
  • LoopAgent already supports escalation; this brings ParallelAgent to parity.

@adk-bot adk-bot added the core [Component] This issue is related to the core interface and implementation label Apr 2, 2026
@rohityan rohityan self-assigned this Apr 2, 2026
@rohityan rohityan added the request clarification [Status] The maintainer need clarification or more information from the author label Apr 13, 2026
@rohityan

Copy link
Copy Markdown
Collaborator

Hi @jinnigu , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Please fix formatting errors by running autoformat.sh

@jinnigu
jinnigu force-pushed the feature/subagent-escalation branch from 29f3359 to c9b1001 Compare April 14, 2026 06:59
@jinnigu

jinnigu commented Apr 14, 2026

Copy link
Copy Markdown
Contributor Author

Hi @jinnigu , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Please fix formatting errors by running autoformat.sh

Thanks @rohityan for helping review. I synced and fixed the format. ptal

@rohityan

Copy link
Copy Markdown
Collaborator

Hi @jinnigu , Thank you for your patience here. I apologize for the delay in getting to this review; I know this has been sitting for a while. This PR has merge conflicts that require changes from your end. Could you please rebase your branch with the latest main branch to address these? Once this is complete, please let us know so we can proceed with the review.

copybara-service Bot pushed a commit that referenced this pull request Aug 19, 2026
@adk-bot

adk-bot commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Thank you @jinnigu for your contribution! 🎉

Your changes have been successfully imported and merged via Copybara in commit 0fd681e.

Closing this PR as the changes are now in the main branch.

@adk-bot adk-bot added the merged [Status] This PR is merged label Aug 19, 2026
@adk-bot adk-bot closed this Aug 19, 2026
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 merged [Status] This PR is merged request clarification [Status] The maintainer need clarification or more information from the author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support sub-agent escalation event in ParallelAgent

3 participants