Intermediate9 min
Streaming v2
Unified StreamPart protocol, type-safe output modes, and real-time token streaming.
Quick Reference
- →version='v2' streaming: unified StreamPart objects with .event and .data fields
- →stream_mode='values': emits full state after each super-step
- →stream_mode='updates': emits only the delta (changed keys) from each node
- →stream_mode='messages': emits individual LLM tokens for real-time UI streaming
- →Multiple modes: stream_mode=['updates', 'messages'] to get both in one stream
The v2 Streaming Protocol
Three stream modes: values (snapshots), updates (deltas), messages (tokens)
v2 streaming is the standard
version='v2' returns typed StreamPart objects with .event and .data fields. Each part is self-describing -- you know what kind of event it is (values, updates, messages, custom, debug) without guessing. v1 returned raw tuples and dicts; v2 is structured, typed, and extensible.
Basic v2 streaming loop