Repository navigation
Conversation
When a coordinator delegated two tasks to the same RemoteA2aAgent in one turn, the first task's request carried both requests, because the sibling call filter ran after the coordinator's event had been rendered as text. The second task was then sent as a resume of the first, because the function response that closed the first task was taken for a reply to a pause the peer raised. Drop sibling calls from the event before it is rendered, and do not treat a response to a delegation to this agent as a resume in task mode. Fixes google#8242
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:
When one model turn delegates twice to the same
RemoteA2aAgent(mode="task"):_construct_message_parts_from_sessionrenders the coordinator's event as quoted text (_present_other_agent_message) before its sibling-call filter runs, so by the time the filter looks at the parts there is nofunction_callleft to skip._create_a2a_request_for_user_function_responsematched it to the coordinator's call and sent it to the peer, which has no such call and rejects it.Solution:
_without_sibling_calls, same shape as_without_credential_parts). The old per-part filter is removed, since it could no longer match anything._create_a2a_request_for_user_function_responsereturnsNonewhen the last user event answers a delegation to this agent (a function response named after the agent, the same test_is_remote_responseuses for a completed delegation). The next delegation then starts a new task. A response to a pause the peer raised still resumes the task.The existing test
test_construct_message_parts_from_session_filters_sibling_fcspatched_present_other_agent_messageto a no-op, which is why it passed. It now uses real events and the real presenter.flowchart TD A[One turn delegates twice to one remote agent] --> B{Requests sent} B -->|Before| C[First asks for both and second is a bad resume] B -->|After| D[Each task asks only for its own request]Narrated recording, before then after (sound on):
evidence.mp4
Testing Plan
Unit Tests:
I have added or updated unit tests for my change.
All unit tests pass locally.
test_construct_message_parts_from_session_filters_sibling_fcs(rewritten with real events): the task's request holds its own request and not the sibling's.test_create_a2a_request_for_user_function_response_after_earlier_task(new): the response that closed an earlier task is not sent as a resume.pyinkandisortwith the repo config leave the changed files unchanged.Manual End-to-End (E2E) Tests:
delegations.pybuilds the session the issue describes (no network, no API key) and asksRemoteA2aAgentwhat it would send for each task.On main:
On this branch:
Edge cases and unchanged behaviour checked (in the recording, on this branch):
Checklist
Additional context
This change was prepared with AI assistance (Claude Code), which also ran the tests and recorded the runs shown above.
🤖 Generated with Claude Code