How to See What Each Node Returns in a LangGraph Graph in Python
graph.invoke() gives you only the final state, so when a result looks wrong, it doesn't tell you which node did what. graph.stream() with stream_mode="updates" prints what each node returned, one node at a time. This guide uses it on a two-node graph with LangGraph 1.2.25.
Syntax
for <update> in <graph>.stream(<input>, stream_mode="updates"):
print(<update>)
| Part | What it means |
|---|---|
<graph> | A compiled graph, the result of compile() |
<input> | The starting state: the same dictionary you'd pass to invoke() |
stream_mode="updates" | Asks for each node's update, as soon as the node has run |
<update> | One dictionary per node that ran, with the node's name as the key and what the node returned as the value |
LangGraph's streaming guide says that updates "streams the updates to the state after each step of the graph", and it shows each one in the shape {"node_name": {"key": "value"}}.
The Example
A graph with two nodes. clean takes a name typed with stray spaces and small letters, " ada lovelace ", and tidies it into Ada Lovelace. greet then builds a greeting from the tidy name. No AI model is involved, so no API key is needed.
Prerequisites
- uv. This guide uses uv 0.13.10 with Python 3.14.10.
Step 1: Create the Project
In a terminal, in the folder where you keep your projects, create a project, move into it and add LangGraph:
uv init --python 3.14 --no-package name-greeter
cd name-greeter
uv add langgraph
Initialized project `name-greeter` at `/Users/you/source/name-greeter`
Using CPython 3.14.10
Creating virtual environment at: .venv
Resolved 40 packages in 26ms
Installed 38 packages in 81ms
+ langgraph==1.2.25

How to Install LangGraph in Python with uv explains these commands and the packages they install.
Step 2: Build the Graph and Run It with invoke()
Replace everything in main.py with:
from typing import TypedDict
from langgraph.graph import END, START, StateGraph
class State(TypedDict):
name: str
greeting: str
def clean(state: State) -> dict:
return {"name": state["name"].strip().title()}
def greet(state: State) -> dict:
return {"greeting": "Hello, " + state["name"] + "!"}
builder = StateGraph(State)
builder.add_node("clean", clean)
builder.add_node("greet", greet)
builder.add_edge(START, "clean")
builder.add_edge("clean", "greet")
builder.add_edge("greet", END)
graph = builder.compile()
print(graph.invoke({"name": " ada lovelace "}))
cleanreturns a newname:strip()removes the spaces at both ends, andtitle()starts each word with a capital letter.greetreturns agreetingmade from the name.- The edges run
START→clean→greet→END, sogreetsees the name thatcleantidied.
Run it:
uv run main.py
{'name': 'Ada Lovelace', 'greeting': 'Hello, Ada Lovelace!'}

That's the final state, and it's right. But it doesn't show who did what: you passed in " ada lovelace ", and nothing in this line says that clean changed it.
Step 3: Stream What Each Node Returns
Replace the last line of main.py, the print(graph.invoke(...)), with a loop over graph.stream():
for update in graph.stream({"name": " ada lovelace "}, stream_mode="updates"):
print(update)
Run it again:
uv run main.py
{'clean': {'name': 'Ada Lovelace'}}
{'greet': {'greeting': 'Hello, Ada Lovelace!'}}

Each line is one node's update, in the order the nodes ran:
{'clean': {'name': 'Ada Lovelace'}}:cleanreturned only the tidiedname.{'greet': {'greeting': 'Hello, Ada Lovelace!'}}:greetreturned only thegreeting.
The graph ran exactly as before. What changed is what you see: every node's return value, labelled with the node's name. When a result looks wrong, this tells you which node to look at. The commands in this guide work unchanged in PowerShell.
The Complete File
from typing import TypedDict
from langgraph.graph import END, START, StateGraph
class State(TypedDict):
name: str
greeting: str
def clean(state: State) -> dict:
return {"name": state["name"].strip().title()}
def greet(state: State) -> dict:
return {"greeting": "Hello, " + state["name"] + "!"}
builder = StateGraph(State)
builder.add_node("clean", clean)
builder.add_node("greet", greet)
builder.add_edge(START, "clean")
builder.add_edge("clean", "greet")
builder.add_edge("greet", END)
graph = builder.compile()
for update in graph.stream({"name": " ada lovelace "}, stream_mode="updates"):
print(update)

Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
Printing what stream() returns: print(graph.stream(...)) | You see the generator object, such as <generator object Pregel.stream at 0xafd60b010> (the number after at changes on every run), instead of the updates | Loop over it with for, as in Step 3 |
Misspelling the mode: stream_mode="update" | The loop prints nothing at all, and there's no error | Write "updates". Fixed: LangGraph graph.stream() Prints Nothing and Raises No Error shows why |
Using invoke() to find out which node changed a value | You get only the final state, as in Step 2 | Use stream() with stream_mode="updates" |
FAQ
What does stream_mode="values" show?
The whole state after each step, starting with your input. With this loop:
for state in graph.stream({"name": " ada lovelace "}, stream_mode="values"):
print(state)
the same graph printed:
{'name': ' ada lovelace '}
{'name': 'Ada Lovelace'}
{'name': 'Ada Lovelace', 'greeting': 'Hello, Ada Lovelace!'}
The streaming guide says that values "streams the full value of the state after each step of the graph". Use updates to see what each node changed, and values to see where the state stood after each step.
Do I have to write stream_mode="updates"?
Not for this graph. Without stream_mode, the same loop printed the same two lines, so a graph built with StateGraph streams its updates by default. Writing it out still makes it clear what the loop prints.
What does version="v2" change?
Every item gets the same three keys, whatever the mode: type, ns and data. With this loop:
for part in graph.stream({"name": " ada lovelace "}, stream_mode="updates", version="v2"):
print(part)
the graph printed:
{'type': 'updates', 'ns': (), 'data': {'clean': {'name': 'Ada Lovelace'}}}
{'type': 'updates', 'ns': (), 'data': {'greet': {'greeting': 'Hello, Ada Lovelace!'}}}
The update from Step 3 is now under data, type names the mode, and ns stays empty unless the graph runs subgraphs. The streaming guide notes that this format "Requires LangGraph 1.1 or later", and its own examples use it.
Conclusion
graph.stream() with stream_mode="updates" printed one line per node: clean returned the tidied name, and greet returned the greeting. invoke() had shown only the final state.
Additional Resources
- Streaming — every stream mode, and the v2 output format.
- Graph API overview — state, nodes and edges, and how a graph runs.
