RemoteA2aAgent emits only partial events on the streaming path, never a final aggregated non-partial event, so the specialist's answer is never persisted
Describe the bug
When RemoteA2aAgent delegates to a streaming A2A agent, every event it yields for the turn has partial=True. It never yields a terminal partial=False event carrying the complete answer.
ADK does not persist partial events to the session. As a result, the parent agent never receives the remote agent's answer as a final response. Live streaming to a UI looks correct, but the answer is missing from session history and from anything that reads the final event.
This was confirmed with Google Cloud Support on the case that also covered #6680 / #7230. Support agreed that RemoteA2aAgent should emit a final aggregated non-partial event on the streaming path, and asked us to file it separately.
Versions
google-adkat PR #7230 head (chelsealong/adk-python@0fe68deb,__version__2.9.2), on client and server. #7230 is required to get past thenonexistent artifact_iderror. This bug is separate and is still present with #7230 applied.- Remote agent deployed on Vertex AI Agent Engine via
A2aAgent,northamerica-northeast1. - Client uses
RemoteA2aAgentwith streaming enabled, calling/a2a/.../message:stream.
To reproduce
- Deploy an agent that streams a multi-chunk text answer to Agent Engine via
A2aAgent. - From a parent agent, delegate to it through
RemoteA2aAgentwith streaming on. - Log every event
RemoteA2aAgent._run_async_implyields for the turn. - Inspect the session after the turn.
Expected behavior
- Partial events stream through as they arrive.
- When the remote task reaches a terminal state (
COMPLETED,FAILED,CANCELEDorINPUT_REQUIRED),RemoteA2aAgentyields one non-partialEventwhose content is the full accumulated answer. ADK persists it like any other final response.
Actual behavior
- All answer-bearing events have
partial=True. - The stream reaches
TASK_STATE_COMPLETED, with 13 status updates and 1 artifact update in our run, but no non-partial event is yielded. - The specialist's answer is absent from the parent session.
Related history
On 2.6.3, the old path set event.partial = not update.last_chunk. The final non-partial event then carried only the last delta, not the full answer. The in-code comment explains the trade-off: converting the accumulated task would re-emit earlier chunks. Aggregating the text of the partials into the terminal event avoids that duplication while still producing a complete final event.
Workaround
We subclass RemoteA2aAgent to fix this on our side. The subclass:
- passes partial events through unchanged, so live streaming still works;
- buffers their non-thought text parts, excluding
thought=Trueprogress text; - if a terminal non-partial event arrives, rewrites its text to the full buffer and keeps any non-text parts;
- if the stream ends on partials only, emits one non-partial
Eventwith the buffered text. On 2.9.2 this is the path every streamed turn takes.
class AccumulatingRemoteA2aAgent(RemoteA2aAgent):
async def _run_async_impl(self, ctx):
buffered = []
async for event in super()._run_async_impl(ctx):
texts = [p.text for p in (event.content.parts if event.content else [])
if getattr(p, "text", None) and not getattr(p, "thought", False)]
if not texts:
yield event
continue
if event.partial:
buffered.extend(texts)
yield event
continue
if buffered:
# rewrite terminal event's text parts to "".join(buffered + texts)
...
yield event
if buffered:
yield Event(
author=self.name,
content=types.Content(parts=[types.Part(text="".join(buffered))]),
invocation_id=ctx.invocation_id,
branch=ctx.branch,
)
We used a subclass rather than the a2a_artifact_update_converter hook because that hook only exists on _handle_a2a_response_v2. That path runs only when the response advertises the new-integration A2A extension, and our custom executor doesn't advertise it.
Suggested fix
Have RemoteA2aAgent do this natively on the streaming path: accumulate answer text from partial events and emit one aggregated non-partial event when the remote task reaches a terminal state. A stream that closes without reaching a terminal state should surface an error instead of returning silently.
Related: #6680, #7230.
Picking this one up now — opening a PR shortly. Flagging it here so nobody duplicates the work; if someone is already on it, say so and I will drop mine.
Tested #7256 end to end. It resolves this issue for us.
Setup
google-adkbuilt from #7230 + #7256 applied together (__version__2.9.2). They apply cleanly on top of each other; #7230 is still needed separately for thenonexistent artifact_iderror.- Server: a streaming test agent on Vertex AI Agent Engine via
A2aAgent,northamerica-northeast1, emitting a long multi-chunk text answer. - Client:
RemoteA2aAgentwith streaming on, callingmessage:stream. Each run logs every event_run_async_implyields and checks what the session persists.
Results
| Client | Events | Partial chunks | Streamed text | Non-partial finals | Final text | Persisted |
|---|---|---|---|---|---|---|
Stock RemoteA2aAgent (#7256) |
162 | 159 | 18,041 chars | 1 | 18,041 chars (equals streamed) | 1 event, 18,041 chars |
Our AccumulatingRemoteA2aAgent workaround on top of #7256 |
148 | 145 | 16,388 chars | 1 | 32,776 chars (exactly 2×) | 32,776 chars |
With stock RemoteA2aAgent, partials still stream through live and exactly one aggregated non-partial event arrives at the end with the full answer, which ADK persists. That is the behaviour this issue asked for.
Note for anyone who used the workaround in the issue body: remove it once you're on #7256. The subclass re-buffers the partials and rewrites the new terminal event, so the final answer is duplicated (2× the streamed text, as above). We've dropped the subclass and now use stock RemoteA2aAgent.
Thanks for the quick fix. We'll move back to a release pin once #7230 and #7256 are both released.
Hi @virktapvir, thank you for reporting this issue and sharing the workaround. Buffering the partial chunks to emit a terminal event is indeed the right approach in the interim.
Thanks as well for confirming that #7256 resolves the issue on your end. The PR is currently under review by our team and will be merged once approved.
Checked this against the latest releases — the behaviour from the issue is still present in v2.11.0, and #7256 is not in v2.10.0 or v2.11.0. (This is from reading the source at the tags; I have not re-run the deployed repro on 2.11.0.)
In src/google/adk/a2a/agent/_remote_a2a_agent.py at v2.11.0 (agents/remote_a2a_agent.py is now a re-export shim for it):
-
An artifact update is converted from only the parts it carries, and one with no parts emits nothing:
if not update.artifact.parts: return None ... event.partial = not update.last_chunkSo a server that streams its text as
append=Truechunks and then closes the artifact with an empty-partslast_chunk=Trueterminator (which is what our executor does) produces onlypartial=Trueevents on the client. The terminator emits no event, and ADK does not persist partial events. -
After the stream loop, the only event added at the end of a stream is the error event for a task that has not reached a terminal state (the v2.10.0 change that reports a stream ending early,
e29ee23). Nothing builds one aggregated non-partial event from the streamed text, which is what #7256 adds.
So the parent agent still never receives the specialist's answer as a final response unless something assembles it. We remain on the #7230 + #7256 build, with stock RemoteA2aAgent, until both are released. Happy to re-run the deployed repro against a newer branch or release if that is useful for review.
Update: #7230 (the make_stream_normalizer snapshot-merge fix) was merged into main on Oct 4 as 71c4fd7, and #6680 is closed. I checked a2a/_compat.py on main and the normalizer now carries over artifacts the snapshot lacks. It is not in a release yet (latest is v2.11.0, from before the merge).
That leaves #7256 as the only piece we still carry outside of main. On v2.11.0, and on main as of today, a delegated stream through stock RemoteA2aAgent still produces only partial=True events and no aggregated non-partial event (see my comment above for the code paths). This is from reading the source; I have not re-run the deployed repro on main.
Once a release with #7230 ships, we plan to drop it from our fork and carry only #7256. Happy to re-test #7256 against the new release or main and post the results here, or to adjust the PR if the reviewers want a different approach.
Hey thanks for contributing to this @chelsealong and bringing this to our attention @virktapvir. Our internal team will be taking over now and your work will be credited!
@willie3838 Appreciate looking into the matter. Please let me know if you need anything from my side. Happy to support the community.