Skip to content

fix(llminternal): backport streaming aggregator and response fixes (#2071, #1249, #2070, #2190, #2301, #2310, #2308) - #2350

Merged
wolo-lab merged 7 commits into
v1from
wolo/v1-backport-05a-llminternal-streaming
Nov 16, 2026
Merged

wolo-lab merged 7 commits into
v1from
wolo/v1-backport-05a-llminternal-streaming

Conversation

@wolo-lab

Copy link
Copy Markdown
Contributor

Problem

Seven defects in the streaming response path are present on 1.x.

  • A streamed text run loses its thought signature. The aggregator merges consecutive text chunks into one part it builds from scratch and did not copy the signature a chunk carried, so a streamed turn was stored without the signature a non-streamed turn keeps, and it was never sent back.
  • A later chunk with nil UsageMetadata wipes the usage an earlier chunk reported, so the final response carried no token counts (seen with Vertex AI grounding streams).
  • The aggregated streaming response has no ModelVersion, although every chunk and every non-streamed response reports it.
  • A nil part in a streamed chunk panics the aggregation loop. The empty-part filter dereferenced each part before any nil test.
  • Every live run starts with an empty event. The live read loop turned every Live API response into an event, including the empty one built from setupComplete, and the session kept it.
  • A response carrying only grounding metadata is dropped by the non-live flow's empty check, so its metadata never reached an event, and an IncludeContents: none agent could anchor its turn on that empty event and lose the user's input.
  • Streamed function-call and event IDs are unstable. Only the first chunk of a streamed function call carries the call ID, so continuation chunks got a different client ID each, and each partial response of one model call got its own event ID, so a client could not tell they belong together.

Summary

Backports #2071, #1249, #2070, #2190, #2301, #2310 and #2308, one commit each, in the order they landed on main.

User-visible behavior changes:

  • Live sessions no longer start with an empty event.
  • Streamed partial events and their final aggregated event share one event ID, and streamed function-call parts share one call ID.
  • Grounding-only responses are now stored as events.

Adaptations for 1.x:

  • #2301: 1.x's LiveConnection.Recv does not populate UsageMetadata until #2215 lands (in the live-config backport PR), so the wire-level "usage metadata" row moves from TestRunLiveSkipsEmptyResponses to TestIsEmptyLiveResponse, which checks the same branch directly.
  • #2310: isEmptyEvent omits the 2.x-only compactioninternal.HasUsableSummary arm, and the test builds its run config through InvocationContextParams.RunConfig since 1.x has no runconfig package.
  • #2308: the lazy event-ID reuse is integrated into 1.x's inline span handling in generateContent, which main had already extracted into telemetry.InstrumentGenerateContent.
  • Callback signatures use 1.x's agent.CallbackContext.

@wolo-lab wolo-lab added the v1 PR targeting v1 branch. label Nov 16, 2026
@wolo-lab
wolo-lab requested a review from wojtas000 November 16, 2026 09:40
@wolo-lab
wolo-lab merged commit 783a83f into v1 Nov 16, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v1 PR targeting v1 branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants