By Abhijith N M · Reviewed 24 October 2026 · Editorial standards
A graph run is observed by three different people. The customer wants to see something happening: tokens as they arrive, a step label while a tool runs, never a frozen screen. The developer wants a trace: which node ran, with what state, how long it took and what it cost. The reviewer wants to rewind a run and inspect the state before a decision — which is what the checkpoint history from Lesson 7 already gives you. Streaming, tracing and time travel are three views of the same checkpointed execution.
| Stream mode | What you receive | Use it for |
|---|---|---|
values | The full state after each superstep | A simple debug console |
updates | A dict keyed by node name with that node's update | Progress labels such as "Looking up order…" |
messages | Model token chunks plus metadata (node, model, run id) | The typing effect and token accounting |
custom | Arbitrary data your node writes with get_stream_writer | "Fetched 10 of 100 records" progress |
debug | Detailed events for both tasks and checkpoints | Debugging the runtime itself |
graph.stream(inputs, config, stream_mode="updates") is the easiest place to start: each yield is one node's partial update, so you can render progress without knowing the graph's internals. Pass a list of modes — stream_mode=["updates", "messages"] — when you want steps and tokens at the same time. Recent LangGraph releases can wrap each chunk as {"type": ..., "data": ...} with version="v2"; check the version you deploy rather than mixing the two shapes.
from typing import TypedDict
from langgraph.graph import END, START, StateGraph
class CleanState(TypedDict):
raw: str
cleaned: str
words: int
def clean(state: CleanState) -> dict:
return {"cleaned": state["raw"].strip().lower()}
def count_words(state: CleanState) -> dict:
return {"words": len(state["cleaned"].split())}
builder = StateGraph(CleanState)
builder.add_node("clean", clean)
builder.add_node("count_words", count_words)
builder.add_edge(START, "clean")
builder.add_edge("clean", "count_words")
builder.add_edge("count_words", END)
graph = builder.compile()
for update in graph.stream(
{"raw": " Harbor Supply ships in 3 days ", "cleaned": "", "words": 0},
stream_mode="updates",
):
print(update)For custom progress, get_stream_writer() returns a writer your node can call with any JSON-serialisable payload; those events arrive under stream_mode="custom". Keep payloads small and free of personal data.
from langgraph.config import get_stream_writer
def retrieve(state: dict) -> dict:
writer = get_stream_writer()
writer({"status": "retrieving", "source": "refund-policy"})
# ... perform the retrieval ...
writer({"status": "retrieved", "count": 3})
return {}LangGraph traces are built from the names you give nodes, tools and agents. create_agent names its nodes model and tools; your hand-built graph uses your names, so a trace reads like the diagram you drew. Name nodes after the action (classify, lookup_order, approve_refund) rather than after their position, and log the fields that let you reconstruct a decision without replaying the model.
thread_id, run id, customer or account id, channel and timestamp.LangSmith is the batteries-included option: set LANGSMITH_TRACING=true, LANGSMITH_API_KEY and a project name in the environment, then run the graph normally. Without it, wrap invoke or stream in structured logging with the same fields. In both cases, redact at the logging boundary — never log API keys, full prompts containing personal data or card-like numbers.
Time travel reuses the checkpoints from Lesson 7. Walk get_state_history(config), pick the snapshot you want, and read its checkpoint_id from snapshot.config. To replay, resume that snapshot's config with no new input: graph.invoke(None, snapshot.config). To fork, call graph.update_state(snapshot.config, {...}) first and then resume: the edit becomes a new checkpoint and later history branches from it while the original is preserved. Both are how you debug "what would have happened if the refund had been rejected?" without guessing.
get_state_history.values and next tell you what was about to run.graph.invoke(None, snapshot.config) to re-execute from there.graph.update_state(...) when you want a different decision, then resume.Key takeaways
stream_mode='updates' gives step progress; messages gives tokens; custom carries your own events.
Trace names come from node, tool and agent names — name them after the action they take.
get_state_history plus a checkpoint_id lets you replay a thread; update_state forks it.
Streaming is for the customer, tracing is for the developer, checkpoint history is the reviewable record.
Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.
Don't lose this lesson
Create a free account to save your progress, keep your streak, and work toward a shareable certificate.