openai.internal.ChatStreamDecoder

The stateful SSE decoder for one streamed turn.

Reference version

Signature

class openai.internal.ChatStreamDecoder

The stateful SSE decoder for one streamed turn.

ai.stream.Event is TextDelta | TurnMeta | TurnDone and TurnStream.final_turn() only ever produces a single Text block, so streamed tool calls cannot reach the runner today (PLAN §6 — extending Event is its own stdlib change). They are still fully assembled here: tool_uses() returns them once the stream ends, which is what a future Event variant will emit and what the tests assert on.

Source:<builtin>/openai/ns_internal/chat.bamlbytes 5694861935

Fields

Static methods

function

new

(provider: string) -> openai.internal.ChatStreamDecoder

Instance methods

function

_absorb_call

(self, delta: openai.internal.CcToolCall, position: int) -> void

(internal) Extend (or open) the buffer for one tool-call delta.

function

decode

(
self,
batch: string
) -> ai.stream.Event[] throws baml.json.DecodeError | baml.json.ParseError | ai.errors.ParseFailed

One SseStream.next() batch -> provider-agnostic stream events.

function

tool_uses

(self) -> ai.content.ToolUse[] throws ai.errors.ParseFailed

The tool calls assembled from the stream, in wire order.