fix(a2a): send append=True for the final chunk of a streamed artifact - #6686
Open
chelsealong wants to merge 1 commit into
Open
fix(a2a): send append=True for the final chunk of a streamed artifact#6686chelsealong wants to merge 1 commit into
chelsealong wants to merge 1 commit into
Conversation
convert_event_to_a2a_events() set append=partial for continuation chunks, so the final (non-partial) chunk of a multi-chunk streamed artifact was sent with append=False. Per the A2A task_manager, an append=False update replaces the artifact's parts entirely instead of appending to them, silently discarding everything streamed before the last chunk. Addresses google#6680
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:
google.adk.a2a.converters.from_adk_event.convert_event_to_a2a_events()tracks in-flight streamed artifacts per agent in an
agents_artifactsdict so that later chunks can be marked
append=Trueand appended tothe artifact created by the first chunk. For continuation chunks it
computed
append = partialinstead ofappend = True, so the finalchunk of a stream (
partial=False) was sent withappend=False.Per the A2A
task_manager.append_artifact_to_tasksemantics, anappend=Falseupdate for an artifact_id that already existsreplaces the artifact's parts wholesale rather than appending to
them. So the last chunk of any multi-chunk streamed text/artifact
response silently overwrites everything streamed before it, and the
consumer (e.g. a
RemoteA2aAgentclient, or any A2A client consumingmessage:stream) ends up with only the tail of the response insteadof the full text — matching the truncation/dropped-content symptoms
described in #6680 for
message:streamagainst agents that streammulti-chunk responses.
Solution:
Once an artifact_id has already been established for an agent's
in-flight stream (i.e. a prior chunk created it with
append=False),every subsequent chunk — including the final, non-partial one — must
set
append=True.last_chunk(derived frompartial) alreadysignals when the stream ends;
appendshould only beFalsefor thevery first chunk that creates the artifact.
Testing Plan
Unit Tests:
Added
test_convert_event_to_a2a_events_final_chunk_appends, whichstreams a first
partial=Truechunk (expectsappend=False, and theartifact id gets tracked) followed by a final
partial=Falsechunkfor the same agent (expects
append=True, and the artifact id iscleared from the tracking dict). Verified the new test fails against
the unfixed code (
git checkout HEAD~1 -- src/.../from_adk_event.py)with:
With the fix applied, full local run:
tests/unittests/a2a/converters/test_from_adk.pyspecifically:Also verified formatting/import ordering with
pyink --checkandisort --checkon both changed files (no issues).Manual End-to-End (E2E) Tests:
Not run — this fix targets a specific dict/flag bug in the ADK-side
A2A event converter and is covered by the unit test above; reproducing
the full deployed Agent Engine streaming scenario from the issue is
out of scope for this change.
Checklist
Additional context
This addresses one concrete, reproducible defect in the streaming
artifact path that #6680 exercises (
convert_event_to_a2a_events,used by the ADK
A2aAgentExecutorwhen converting streamed ADK eventsinto
TaskArtifactUpdateEvents, and consumed client-side byRemoteA2aAgent/any A2A streaming client). The issue also describes adistinct symptom (
append=True for nonexistent artifact_id) andtruncation specifically against a deployed Vertex AI Agent Engine
target, which the reporter suspects may live in Agent Engine's own
REST-wrapped proxy layer rather than in
google-adkora2a-sdkdirectly — this PR does not claim to resolve that half of the report,
only the append-flag bug found in this repo's own conversion code.
Note on AI assistance: this change was developed with the help of an
AI coding agent (Claude Code), including drafting the fix, the
regression test, and this PR description; the change was reviewed and
verified (tests run locally as shown above) before submission.