openai.internal.ChatStreamDecoder
The stateful SSE decoder for one streamed turn.
Reference version
Signature
class openai.internal.ChatStreamDecoderThe 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 56948–61935
Fields
provider
stringcalls
Static methods
function
new
(provider: string) -> openai.internal.ChatStreamDecoderInstance methods
(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.ParseFailedThe tool calls assembled from the stream, in wire order.