google.internal._gm_decode_batch
(internal) One SseStream batch -> provider-agnostic stream events.
Signature
(internal) One SseStream batch -> provider-agnostic stream events.
Wire shape: each SSE data: payload is a GmResponse fragment; text deltas
ride in candidates[0].content.parts[].text, the last fragment carries
finishReason, and usageMetadata (cumulative) appears on fragments.
Termination: Gemini's SSE has no terminal sentinel — the fragment carrying
finishReason IS the end of the turn, and the connection then closes. That
fragment is decoded as ai.stream.TurnDone, which lets both stream call
sites pass require_terminal: a connection cut mid-answer then surfaces as
an ai.errors.NetworkFailure instead of a silently truncated Complete turn.
A data: payload that is not decodable is a failure too. Dropping it (what
this used to do) turns a cut or a proxy's error page into missing text that
no caller can see.
Source:<builtin>/google/ns_internal/gemini.bamlbytes 37890–40816