Streaming
A 20-second tool call with no tokens looks like a hang. Streaming is how you show 'still working' and partial answers.
A live sports ticker vs waiting for the newspaper. Same game. Different when you learn the score.
Visual Workflows
Start here — scroll inside each diagram frame to explore, then use + / − to zoom up to 200% if needed.
Overview
Scroll inside the frame to explore · use + / − to zoom up to 200%
Scroll inside the frame to explore · use + / − to zoom up to 200%
What the user should see
Scroll inside the frame to explore · use + / − to zoom up to 200%
Tokens for the reply. A card when a tool starts. A HITL card when interrupt fires. Not raw debug dumps.
invoke vs stream
Scroll inside the frame to explore · use + / − to zoom up to 200%
invoke waits for Finish. stream yields along the way. Same graph, different consumption.
Key Takeaways
- 1.stream / astream emits the graph as it runs so the UI is not a blank spinner. Mode values: the full state after a step. Mode updates: only what that node changed. Mode messages: tokens and tool messages.
- 2.Custom mode is for your own progress events (Searching tickets...). Debug mode is for you, not for users. Streaming is orthogonal to checkpoints: you can stream a durable thread.
- 3.graph.stream(input, config, stream_mode='updates') is the usual learning mode — you see which node just ran. messages mode is for token UIs. You can pass a list of modes.
- 4.Subgraphs can be included or hidden. Pair with AG-UI later; this module is the runtime events.
Learn elsewhere
- →AG-UI — Phase 22
- →LangGraph Platform
Real Example
Scenario
User asks a long research question. UI shows 'searching' when the search node updates, then tokens as the reply node streams, then done.
What you would do
Start with stream_mode='updates' in a terminal so you learn the shape. Then wire messages mode into the chat bubble. Do not start with debug in production logs of user text.
Commands
Commands to Remember
graph.stream(input, config, stream_mode='updates')stream_mode='messages' # tokens for the bubbleinvoke = wait, stream = tickerSame thread_id as checkpoints
Cheat Sheet
Quick recap
quick ref- •stream not only invoke
- •updates vs messages
- •Custom for progress
- •Works with threads
Common Mistakes
- ✕Only using invoke, then wondering why the UI spins for 30 seconds
- ✕Dumping debug streams to the end user
- ✕Streaming without a thread_id when you also need HITL
