Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

AI Agents · Const

Streaming

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.

How it works

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.

Syntax

await graph.stream(input, { streamMode: "updates" })

Parameters

NameTypeDescription
inputGraph inputInitial graph state supplied to the stream invocation.
configStream optionsOptions including the selected stream mode, such as updates, values, messages, custom, checkpoints, tasks, or debug.

Returns

An async iterable of streamed graph execution output.

Key points

  • Call graph.stream(...) and consume the returned async iterable with for await...of.
  • Choose updates for incremental state changes or values for the full state after each graph step.
  • The updates mode reports only what changed after each execution step.
  • The values mode reports the accumulated state snapshot after each execution step.
  • Use messages when the application needs to render model output progressively.
  • Available modes cover state, model messages, custom events, checkpoints, task events, and debugging.

Common mistakes

  • Use messages for token-level LLM output; it is different from state streaming modes such as updates and values.

Example: Stream graph updates

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.

When to use it

Agent progress

Show incremental progress while a multi-step graph executes.

Token streaming

Render LLM responses token by token in a chat interface.

Custom events

Send application-specific events from graph nodes to a client.

Observability

Inspect checkpoints, tasks, or detailed runtime events during execution.

  • streamMode
  • updates
  • values
  • messages
  • custom
  • checkpoints
  • tasks
  • debug

Source: Streaming. Checked 2026-10-15.