Skip to main content

Overview

LangGraph supports multiple streaming modes to provide real-time feedback, build responsive UIs, and monitor graph execution. Instead of waiting for the entire graph to complete, you can process results as they become available.

Stream Modes

LangGraph offers 7 different streaming modes, each serving different use cases:

Mode Overview

values

Complete state after each step

updates

Individual node outputs

messages

LLM token streaming

custom

User-defined events

checkpoints

State snapshots

tasks

Task execution events

debug

Debugging information

Values Mode

Emits the complete state after each step:
Use cases:
  • Display complete state in UI
  • Monitor full state changes
  • Simple progress tracking
values is the default stream mode. It includes the initial state before any nodes execute.

Updates Mode

Emits individual node outputs as they complete:
Each event is a dictionary with:
  • Key: Node name
  • Value: Node’s output (state update)
Use cases:
  • Track which nodes executed
  • Show per-node progress
  • Collect individual results

Parallel Node Updates

Messages Mode

Stream LLM tokens in real-time:

Message Metadata

Use cases:
  • Real-time chat interfaces
  • Streaming chatbots
  • Progressive text generation

Custom Mode

Emit custom events from within nodes:
StreamWriter is automatically injected when requested as a parameter. It’s a no-op when not using stream_mode="custom".
Use cases:
  • Fine-grained progress tracking
  • Custom metrics/telemetry
  • Application-specific events

Checkpoints Mode

Emits state snapshots when checkpoints are created:
Each checkpoint includes:
  • values: Current state
  • next: Upcoming nodes
  • config: Runtime configuration
  • metadata: Step info, source
  • created_at: Timestamp
  • tasks: Pending tasks
Use cases:
  • Monitor checkpointing
  • Display execution timeline
  • Debug state persistence
Requires a checkpointer to be configured.

Tasks Mode

Emits events for task lifecycle:
Event types:
  • task: Task started
  • task_result: Task completed (with result or error)
Use cases:
  • Monitor task execution
  • Track task duration
  • Debug failures

Debug Mode

Combines checkpoints and tasks for comprehensive debugging:
Use cases:
  • Development debugging
  • Troubleshooting execution
  • Performance analysis

Multiple Stream Modes

Combine modes for richer output:
Each event is a dict with a single key indicating the mode:

Async Streaming

All streaming modes support async iteration:
Use async streaming for:
  • Async I/O operations
  • Concurrent event processing
  • WebSocket connections
  • Server-sent events (SSE)

Streaming with Subgraphs

Control subgraph streaming:

Building a Streaming UI

Real-Time Chat Interface

Progress Bar with Custom Events

FastAPI SSE Endpoint

Stream Configuration

Early Emission

Force eager event emission:
By default, events are batched. stream_eager=True reduces latency.

Filtering Stream Channels

Limit which state keys are streamed:

Best Practices

  • Use values for state monitoring and simple UIs
  • Use updates to track individual node execution
  • Use messages for chat interfaces with LLMs
  • Use custom for application-specific events
  • Use debug during development
  • Combine modes when you need multiple perspectives
  • Use async streaming for I/O-bound applications
  • Enable stream_eager for lower latency
  • Limit state size to reduce serialization overhead
  • Filter stream channels to reduce bandwidth
  • Batch custom events when possible
  • Buffer tokens before displaying (avoid flickering)
  • Show loading indicators between node executions
  • Handle reconnection for long-running streams
  • Display node names from updates mode
  • Use custom events for progress bars

Troubleshooting

  • Verify correct stream mode
  • Check if graph has any nodes
  • Ensure nodes return state updates
  • For messages mode, confirm LLM is used
  • For custom mode, verify StreamWriter calls
  • Enable stream_eager=True
  • Check for buffering in transport layer
  • Verify async streaming is used correctly
  • Review node execution time
  • Ensure LLM supports streaming
  • Check that LLM is configured for streaming
  • Verify message format is correct
  • Review LangChain callback configuration

Next Steps

Human-in-the-Loop

Combine streaming with interrupts for human oversight

Checkpointing

Use checkpoint streaming for state monitoring