Render a streamed timeline
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’sitem_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:- TypeScript
- Python
- Go
- C#
- PHP
- Ruby
- Java
- Rust
The completed result has the same ordered items as the stream, in
items: