fix(a2a): keep every artifact when converting an A2A task to an event - #7201
Open
AtulJoshi1206 wants to merge 1 commit into
Open
AtulJoshi1206 wants to merge 1 commit into
AtulJoshi1206 wants to merge 1 commit into
Conversation
convert_a2a_task_to_event built the event from a2a_task.artifacts[-1], so a task carrying more than one artifact lost everything before the last one. A remote agent returns one artifact per non-partial event it produced, and ADK's own convert_event_to_a2a_events mints a fresh artifact_id per event, so a multi-event remote agent hit this on every call. This is the default client path: RemoteA2aAgent._handle_a2a_response uses it for any peer that does not advertise the new integration extension. Flatten the artifacts the way to_adk_event.convert_a2a_task_to_event already does.
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
No existing issue; described below following the bug-report structure.
Describe the Bug:
convert_a2a_task_to_eventina2a/converters/event_converter.pybuilds the ADK event from only the task's last artifact:An A2A
Taskcarries oneArtifactper output the remote agent produced, so everything before the final artifact is dropped on the way into ADK.The sibling converter in the same package,
to_adk_event.convert_a2a_task_to_event, already flattens them:Two converters for the same A2A shape disagree, and one of them loses data.
Impact:
This is the default client path, not a legacy one.
RemoteA2aAgent._handle_a2a_responsecalls it for the initial response of a streaming task and for the complete response of a non-streaming task._run_async_implonly routes to_handle_a2a_response_v2when the peer advertises the new ADK integration extension, so any non-ADK peer, or an ADK peer on the legacy executor, lands here.Multiple artifacts are the normal result rather than an edge case: ADK's own server-side
from_adk_event.convert_event_to_a2a_eventsmints a freshartifact_idfor every non-partial event, so an agent that produces N events returns N artifacts.Steps to Reproduce:
On current
main(665ec9835), convert a completed task carrying three artifacts:Observed Behavior:
The same task through
to_adk_event.convert_a2a_task_to_eventyields all three.Expected Behavior:
Every artifact's parts reach the event, in task order, matching the sibling converter.
Solution:
Flatten all artifacts instead of indexing the last, using the same comprehension the sibling converter already uses.
Testing Plan
Unit Tests:
Added
test_convert_a2a_task_to_event_keeps_every_artifactbeside the existingtest_convert_a2a_task_to_event_with_artifacts_priority. Verified it fails on an unmodifiedevent_converter.pyand passes with the change. The existing artifact tests use a single artifact, where flattening is the identity, so they are unaffected.Manual End-to-End (E2E) Tests:
Driven through the converter directly, since reaching it end-to-end needs a live remote A2A peer. Running the same three-artifact task through both converters:
Checklist
Additional context
No public API change. Streaming chunk updates go through
convert_a2a_message_to_eventon the per-update artifact and carry an explicit comment about not re-emitting the accumulated task, so this does not introduce duplicate parts. The one behaviour change is that a client reconnecting to an already-accumulated task now sees every accumulated artifact rather than only the last.🤖 Generated with Claude Code