fix(remoteagent/v2): invoke AfterA2ARequestCallbacks on synthesized aggregated events#973
Open
nuthalapativarun wants to merge 1 commit into
Conversation
…ggregated events aggregatePartial can build new non-partial events from accumulated partial artifact chunks (buildNonPartialAggregation). These synthesized events were emitted directly without going through runAfterA2ARequestCallbacks, so registered AfterA2ARequestCallback handlers never received them. Fix: after aggregatePartial returns, run callbacks on any event whose pointer differs from the original converted event (i.e., a synthesized aggregated event). The original event already went through callbacks before aggregatePartial was called. Closes google#948
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
Root Cause
aggregatePartialsynthesizes new non-partial events viabuildNonPartialAggregationwhen accumulated partial artifact chunks arrive before a terminal status update. These synthesized events were emitted directly viayieldwithout going throughrunAfterA2ARequestCallbacks, so registeredAfterA2ARequestCallbackhandlers never received them.The original event (converted from the individual A2A chunk) correctly went through the callbacks, but the aggregated result—which is the event callers actually care about—did not.
Fix
In
processEvent, after callingaggregatePartial, runrunAfterA2ARequestCallbackson each emitted event whose pointer differs from the originalevent(i.e., synthesized aggregated events). The original event already went through callbacks above theaggregatePartialcall.Testing Plan
Unit Tests:
TestRemoteAgent_AfterCallbackInvokedOnAggregatedEvent: streams two partial artifact chunks ("Hel" + "lo") followed by a terminal status. Registers a callback that counts invocations and records non-partial content text. Asserts 4 callback invocations (partial×2 + aggregated + terminal) and["Hello"]as the text seen by the callback for the aggregated non-partial event../agent/remoteagent/v2/...continue to pass.Manual End-to-End (E2E) Tests:
The fix is contained to the callback dispatch path in
processEvent. The change is additive—existing behavior is preserved for the common case (single-event slice fromaggregatePartial) and the new path only fires when a synthesized aggregated event is present.Checklist