Skip to main content
Switch on each streamed event’s or item’s type to render text, reasoning, tool calls, and progress as they arrive, then rebuild the same timeline later from the saved run result. TypeScript yields a typed item union; the other languages yield the raw events as maps, dicts, or hashes.

Render a streamed timeline

Rust has no streaming; build the timeline from the completed run, as below.

TypeScript item types

AgentItem<TOutput> is a discriminated union, and TypeScript narrows each item from its type: Items built from provider output also keep the original payload in rawProviderItem, for the rare field the portable types don’t carry. Build product logic on the portable fields, because rawProviderItem differs by provider.

Event types in the other languages

Go, C#, PHP, Ruby, and Java deliver the same event types. Python’s item_stream() yields provider and runtime items as dicts with a type key. Where the fields live differs by language: None of these is a typed union, so validate the fields your UI uses, keep provider-specific parsing behind one adapter, and keep an unknown-type fallback. In Go, C#, and Java, model stream events carry the run ID "stream"; use lifecycle events for the real run ID. The full lifecycle event list is in Lifecycle hooks.

Rebuild a timeline after the run

The event history stays readable after the run ends, so one consumer can render while another persists events, with no second model request. For a durable timeline, store the completed run result:
The completed result has the same ordered items as the stream, in items:
Last modified on November 5, 2026