Repository navigation
Conversation
A task-mode caller treats any terminal finish_task as the remote task completing. Both executors skip that event only when the branch carries a run id (name@run_id). ParallelAgent's parent.child branch has no run id, so a served parallel root still completes. An unset branch is kept, including a Workflow child with a different author. Fixes google#7745
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.
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):
Problem:
A task-mode
RemoteA2aAgenttreats any terminalfinish_taskresponse as the remote task completing. BothA2aAgentExecutorpaths forward every event fromrunner.run_async, including a nested peer'sfinish_task. That nested event hasbranchset (inner@<run_id>), which is what the wire shows asadk_branch. The served agent's ownfinish_taskleavesbranchunset. The outer delegation then closes on the inner result.Solution:
Skip a
finish_taskcall or terminal response whose branch has a run id (name@run_id), in both executor loops, before conversion. That is what task delegation stamps, viaoverride_branchon AgentTool anduse_sub_branchonrun_node. Other events on that branch are still forwarded. An unset branch is still forwarded, including a Workflow or SequentialAgent child whose author is not the served root.ParallelAgentstampsparent.childwith no run id, and that child'sfinish_taskis forwarded so a served parallel root still completes.A client-side
adk_branchcheck inRemoteA2aAgentis not in this change. The caller buildsEvent.branchfrom its own invocation context, not from the remoteadk_branchmetadata, so that check is a separate read of the A2A message.Testing Plan
Unit Tests:
test_legacy_executor_forwards_finish_task_by_run_idandtest_new_executor_forwards_finish_task_by_run_ideach run four cases: a nested text event oninner@fcis forwarded while that hop'sfinish_taskis dropped and the unset-branchfinish_taskis kept; authorreporteragainst served rootworkflowwith branch unset is kept; a chat root that ends in text keeps the text and drops the nestedfinish_task;par.childis kept.test_nested_branch_finish_task_requires_a_run_idchecks the helper for unset branch,par.c, a text event oninner@fc, and a terminalfinish_taskoninner@fc.9 passed. mypy on
_finish_task_tool.py,a2a_agent_executor.py, anda2a_agent_executor_impl.py: no issues.Manual End-to-End (E2E) Tests:
Did not run the issue's three-agent ASGI script. The executor tests cover both
_handle_requestloops.Checklist
Additional context
A non-terminal
finish_taskresponse on a sub-branch is still forwarded. It does not close the outer task.