Zenaique

Which is the right LangGraph stream_mode for showing tokens vs node updates?

MCQ·Medium·4.0 · 0·~1 min·Asked atLocusMoveworksSnap
Attempt it
TL;DR

Three main modes: messages for LLM tokens, updates for per-node state deltas, values for the full state after each node. There is no tokens or nodes mode.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Picture a relay race where each runner writes a note on a clipboard between laps. With messages you watch each runner whispering syllables as they run, the play by play. With updates you only see what each runner added to the clipboard when they handed it off, a tidy diff per leg. With values you photograph the whole clipboard after each runner finishes, complete but heavy. These are three views of the same race, picked by what your UI needs to show.

Key concepts

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

LangGraph's stream_mode argument decides what a streaming client receives. A wrong choice is one of the most visible failures in a chat UI. Pick the wrong mode and either the UI freezes (no tokens reach the user) or it fills with state deltas the UI has no use for.

Three modes cover most UI needs: messages, updates and values. The names tokens and nodes sound plausible but do not exist, and stream=True does not pick a mode. The other modes (custom, checkpoints, tasks, debug) carry custom progress data, persistence events and debug detail.

The LLM emits tokens (messages), the graph emits per-node deltas (updates), and the graph snapshots full state (values). Three granularities, three modes.

Three modes, three granularities

messages. Per-token granularity

stream_mode='messages' emits AIMessageChunk and ToolCallChunk events as the LLM (or tool) inside any node produces them. Each chunk carries a small token-delta payload plus metadata identifying which node emitted it.

This is the right mode for any UI that shows typewriter-style output to the user. It is also how you get tool-call previews mid-flight: the AI SDK or your custom frontend can show 'the model is calling search(query=...)' before the tool returns.

updates. Per-node delta

stream_mode='updates' emits one event per node, shaped as {node_name: state_delta} where state_delta is exactly what the node's function returned. The event is lightweight (only the fields the node changed) and structured (keyed by node name).

Use it for status bars, per-stage progress indicators, and any UI that cares about 'a node finished' rather than 'a token arrived.'

values. Per-node full state

stream_mode='values' emits the FULL state object after each node runs. Every event is a complete snapshot. It is heavier than updates because unchanged fields are re-shipped. It is useful when the client does not maintain its own state copy, or when you want each event to be self-contained for replay or debugging.

Picking by UI

UI needMode
Typewriter chat outputmessages
Status pill (planner ran, tool running)updates
Debug console showing full state per stepvalues
Chat plus status combined['messages', 'updates']
Why the wrong options are wrong
The multi-mode pattern and operational notes
Putting it together in production
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.

Real products, models, and research that use this idea.

  • LangGraph chat templates wire stream_mode messages to the chat surface and stream_mode updates to a status pill in the same UI.
  • A coding-agent UI can stream messages for the editor diff preview and updates for a build progress timeline.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QHow would you wire both messages and updates to a single chat UI?
A

Call stream with stream_mode=['messages', 'updates']. Each event arrives tagged by mode. Route messages events to the typewriter renderer. Route updates events to the status pill or progress bar. Use SSE or WebSocket with explicit event types so the frontend can dispatch on tag without parsing the payload first.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Picking 'tokens' or 'nodes' as a mode name. They sound right but do not exist. The real names are messages and updates.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • The three main stream_mode names and what each emits

  • Why messages mode is the typewriter-output choice

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
Identify the concrete lock in costs a framework imposes on a production codebase (select all that apply)
Multi-select·Medium