LangGraphLangGraph 1.2 · Python 3.10+
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
38 small wins to finish your pathNext lesson →

Streaming: watch a run happen

graph.stream() yields a run as it happens. stream_mode picks what you see: "updates" for each node's change, "values" for the whole state, "messages" for model tokens.

Last updated: 27 Sep, 2026 · LangGraph 1.2

invoke waits for the whole run and returns the final state. stream hands you each step as it finishes, which is how a UI shows progress and tokens as they arrive.

The graph.stream API

python
for chunk in graph.stream(inputs, stream_mode="updates"):
    print(chunk)   # {node_name: what_that_node_changed}

The example runs one node and watches its update arrive. Build it in four small steps.

The state

python
from typing_extensions import TypedDict
from langgraph.graph import StateGraph, START, END

class State(TypedDict):
    topic: str   # what to joke about
    joke: str    # the node fills this in

The state has two fields: topic is given at the start, and joke is what the node writes.

The make node

python
def make(state):
    return {"joke": f"a joke about {state['topic']}"}   # writes the joke field

The make node reads topic and returns a new joke. This is the one change the run produces.

Building the graph

python
builder = StateGraph(State)
builder.add_node("make", make)
builder.add_edge(START, "make")   # START -> make -> END
builder.add_edge("make", END)

One node again, running from START to make to END.

Streaming the run

python
for chunk in builder.compile().stream(
    {"topic": "cats", "joke": ""}, stream_mode="updates"   # yield each node's change
):
    print(chunk)
  • stream hands you each step as it finishes instead of waiting for the whole run.
  • In "updates" mode each chunk is {node_name: the_change}.
  • There is one node, so the loop prints one chunk: the make node's new joke.

Streaming a run end to end

The four steps in one file.

Example
from typing_extensions import TypedDict
from langgraph.graph import StateGraph, START, END

class State(TypedDict):
    topic: str
    joke: str

def make(state):
    return {"joke": f"a joke about {state['topic']}"}

builder = StateGraph(State)
builder.add_node("make", make)
builder.add_edge(START, "make")
builder.add_edge("make", END)

for chunk in builder.compile().stream({"topic": "cats", "joke": ""}, stream_mode="updates"):
    print(chunk)

What each chunk showed

  • In "updates" mode each chunk is {node_name: the_change}, so you see the make node's update as it happens.
  • "values" mode would yield the whole state after each step instead.
  • "messages" mode yields model tokens as 2-tuples, which is how a chat streams a reply word by word.

Stream modes

stream_modeYields
"updates"Each node's change, keyed by node name
"values"The full state after each step
"messages"Model tokens as they arrive

When to stream a run

  • Showing progress in a UI while a multi-step run works.
  • Streaming a model's reply token by token instead of waiting for the whole answer.
Watch out. Pass a list of modes, e.g. stream_mode=["updates", "messages"], to get both; each chunk then says which mode it came from.
Try it yourself
  • Switch to stream_mode="values" and compare the chunks.
  • Add a second node and watch two update chunks arrive.

Slow is fine. Stopping is the only problem.