Session 8· 06· 15 min
Streaming Agent Output
What you'll learn
- ▸Stream agent progress with stream_mode="updates"
- ▸Stream individual tokens with stream_mode="messages"
- ▸See tool calls appear in real time
Agents may take several seconds for multi-step reasoning. Streaming shows progress in real time — users see the model thinking, tools executing, and the answer arriving token by token.
stream_mode="updates"
step progress
- •One event per agent step
- •Shows tool calls and results
- •Good for progress indicators
stream_mode="messages"
token streaming
- •One event per token
- •Typewriter effect
- •Good for live chat UIs
$ python 06_streaming.py
Knowledge Check
Which stream mode would you use for a chat UI that shows tokens appearing one by one?
Recap — what you just learned
- ✓agent.stream() replaces agent.invoke() for real-time output
- ✓"updates" = one event per step; "messages" = one event per token
- ✓You can combine both: stream_mode=["updates", "messages"]