Agent progress
Show incremental progress while a multi-step graph executes.
AI Agents · Const
LangGraph's stream API lets applications observe graph execution as it happens. Select a stream mode to receive state changes, full state snapshots, LLM tokens, custom events, checkpoints, tasks, or debug events.
LangGraph's stream method exposes graph execution as an async iterable. Choose a stream mode to receive state updates, complete state snapshots, LLM tokens, custom data, checkpoints, task events, or debugging information.
await graph.stream(input, { streamMode: "updates" })| Name | Type | Description |
|---|---|---|
input | Graph input | Initial graph state supplied to the stream invocation. |
config | Stream options | Options including the selected stream mode, such as updates, values, messages, custom, checkpoints, tasks, or debug. |
An async iterable of streamed graph execution output.
graph.stream(...) and consume the returned async iterable with for await...of.updates for incremental state changes or values for the full state after each graph step.updates mode reports only what changed after each execution step.values mode reports the accumulated state snapshot after each execution step.messages when the application needs to render model output progressively.messages for token-level LLM output; it is different from state streaming modes such as updates and values.import { StateGraph, Annotation } from "@langchain/langgraph";
const State = Annotation.Root({
count: Annotation<number>(),
});
const graph = new StateGraph(State)
.addNode("increment", (state) => ({ count: state.count + 1 }))
.addEdge("__start__", "increment")
.addEdge("increment", "__end__")
.compile();
const stream = await graph.stream(
{ count: 0 },
{ streamMode: "updates" }
);
for await (const chunk of stream) {
console.log(chunk);
}Runs a graph and prints each node's state update as it becomes available.
Show incremental progress while a multi-step graph executes.
Render LLM responses token by token in a chat interface.
Send application-specific events from graph nodes to a client.
Inspect checkpoints, tasks, or detailed runtime events during execution.
streamModeupdatesvaluesmessagescustomcheckpointstasksdebug