Intermediate12 min
Streaming
Surface real-time agent progress to users. Choose stream_mode='updates' for step-by-step progress, 'messages' for LLM tokens, or 'custom' for arbitrary signals from inside tools. Pass version='v2' for a unified chunk format.
Quick Reference
- →stream_mode='updates' — state diff after each agent step
- →stream_mode='messages' — LLM token chunks + metadata as they're generated
- →stream_mode='custom' — arbitrary user data via get_stream_writer() inside tools
- →Pass a list: stream_mode=['updates', 'custom'] to combine modes
- →version='v2' gives every chunk a unified {type, ns, data} shape
What You Can Stream
| stream_mode | What you get | Best for |
|---|---|---|
| 'updates' | State diff after each agent step (model → tools → model) | Showing step-by-step agent progress |
| 'messages' | Token chunks + metadata from every LLM call | Token-by-token typing effect in chat UIs |
| 'custom' | Arbitrary signals emitted via get_stream_writer() | Progress updates from inside long-running tools |