fix: RemoteA2aAgent fails to send taskId in multi-turn scenarios#4944
Open
shriramThakare3 wants to merge 1 commit intogoogle:mainfrom
Open
fix: RemoteA2aAgent fails to send taskId in multi-turn scenarios#4944shriramThakare3 wants to merge 1 commit intogoogle:mainfrom
shriramThakare3 wants to merge 1 commit intogoogle:mainfrom
Conversation
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.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
Problem:
RemoteA2aAgentonly sendscontext_idon subsequent turns, nevertask_id, causing the remote server to spawn a new task every turn instead of resuming the paused one. A multi-turn flow (e.g.input-required→ user replies) always creates stale orphaned tasks on the remote agent.Solution:
In
_construct_message_parts_from_session, after readingcontext_idfromcustom_metadata, also read the stored task state from the previous response metadata. Forwardtask_idonly when the task is still open (input-requiredorauth-required). For terminal states (completed,failed,cancelled)task_idstaysNoneso the server correctly starts a fresh task under the samecontext_id.Testing Plan
Unit Tests:
I have added or updated unit tests for my change.
All unit tests pass locally.
test_multiturn_sends_task_id_when_input_required— verifiestask_idis included in the second-turn request when task state isinput-requiredtest_multiturn_sends_task_id_when_auth_required— same forauth-requiredtest_first_turn_omits_task_id— verifiestask_idisNoneon the first turntest_completed_task_omits_task_id— verifiestask_idis not forwarded when previous task state iscompletedManual End-to-End (E2E) Tests:
RemoteA2aAgentpointing at the currency agent froma2a-samplesadk weband sendHow much is 10 USD?Provide the currency to convert toandtask.status=input-requiredCADas the second turncontextIdandtaskIdmatching the first turn's taskChecklist
Additional context
The same root cause was previously reported in #3765. That issue proposed a fix but it was not fully applied —
task_idwas still never populated because the state check was missing.