LangGraph — used by Replit, Uber, LinkedIn, GitLab and more — is a low-level orchestration framework for building controllable agents. While langchain provides integrations and composable components to streamline LLM application development, the LangGraph library enables agent orchestration — offering customizable architectures, long-term memory, and human-in-the-loop to reliably handle complex tasks.
npm install @langchain/langgraph @langchain/core
[!TIP] If you're looking to quickly build agents, check out Deep Agents — a higher-level package built on LangGraph for agents that can plan, use subagents, and leverage file systems for complex tasks.
For an equivalent Python library, check out LangGraph and the Python docs.
LangGraph provides low-level supporting infrastructure for any long-running, stateful workflow or agent:
[!TIP] For developing, debugging, and deploying AI agents and LLM applications, see LangSmith.
While LangGraph can be used standalone, it also integrates seamlessly with any LangChain product, giving developers a full suite of tools for building agents. To improve your LLM application development, pair LangGraph with:
LangGraph is inspired by Pregel and Apache Beam. The public interface draws inspiration from NetworkX. LangGraph is built by LangChain Inc, the creators of LangChain, but can be used without LangChain.
Stores the last value received, but only made available after finish(). Once made available, clears the value.
Stores the result of applying a binary operator to the current value and each new value.
Reducer channel that stores only a sentinel in checkpoint blobs and reconstructs state by replaying ancestor writes through the reducer.
DeltaChannel avoids re-serializing the full accumulated valu
A Zod v4-compatible meta registry that extends the base registry.
This registry allows you to associate and retrieve metadata for Zod schemas, leveraging the base registry for storage. It is compatib
A registry for storing and managing metadata associated with schemas. This class provides methods to get, extend, remove, and check metadata for a given schema.
Abstract base class for persistent key-value stores.
Stores enable persistence and memory that can be shared across threads, scoped to user IDs, assistant IDs, or other arbitrary namespaces.
Feature
Abstract base class for persistent key-value stores.
Stores enable persistence and memory that can be shared across threads, scoped to user IDs, assistant IDs, or other arbitrary namespaces.
Feature
Stores the result of applying a binary operator to the current value and each new value.
One or more commands to update the graph's state and send messages to nodes. Can be used to combine routing logic with state updates in lieu of conditional edges
Final result from building and compiling a StateGraph.
Should not be instantiated directly, only using the StateGraph .compile()
instance method.
Reducer channel that stores only a sentinel in checkpoint blobs and reconstructs state by replaying ancestor writes through the reducer.
DeltaChannel avoids re-serializing the full accumulated valu
Represents a state field backed by a DeltaChannel.
Unlike ReducedValue (which stores the full accumulated value in every
checkpoint blob via BinaryOperatorAggregate), a DeltaValue field persists
A projection channel for StreamTransformers.
Implements AsyncIterable<T> so it can be iterated directly by
in-process consumers via run.extensions.<key>. Channels created with
StreamChannel.remot
Extend this class and pass an instance through callbacks to observe graph
interrupts and resumes. Lifecycle methods are always awaited, including when
other callbacks run in the background. Set `rai
Raised when a graph run exits early due to a drain request.
This indicates the graph stopped cooperatively at a superstep boundary because RunControl#requestDrain was called (e.g., in response to SIG
Primary run stream for a LangGraph execution.
Implements AsyncIterable over ProtocolEvent and exposes ergonomic projections for values, messages, subgraphs, output, and interrupts. Created by createG
In-memory key-value store with optional vector search.
A lightweight store implementation using JavaScript Maps. Supports basic key-value operations and vector search when configured with embeddings.
Failure context passed to a node-level error handler.
A node-level error handler is registered via
StateGraph.addNode(name, fn, { errorHandler }). The handler runs ONLY after
the failing node's Ret
Raised by a node to interrupt execution.
Raised when a node invocation exceeds one of its configured timeouts.
Does not extend GraphBubbleUp (so it flows through the normal node error path) and is intentionally treated as retryable by t
Bypass a reducer and write the wrapped value directly to a BinaryOperatorAggregate channel.
Receiving multiple Overwrite values for the same channel in a single
super-step will raise an InvalidUpda
Represents a state field whose value is computed and updated using a reducer function.
ReducedValue allows you to define accumulators, counters, aggregators, or other fields whose value is determined
Exception raised when an error occurs in the remote graph.
Run-scoped control surface for cooperative draining.
Intended for a single graph run. Create a fresh RunControl per run; reusing a control after RunControl#requestDrain leaves it drained.
Safe to us
A message or packet to send to a specific node in the graph.
The Send class is used within a StateGraph's conditional edges to
dynamically invoke a node with a custom state at the next step.
Imp
A graph whose nodes communicate by reading and writing to a shared state.
Each node takes a defined State as input and returns a Partial<State>.
Each state key can optionally be annotated with a
Error thrown when invalid input is provided to a StateGraph.
This typically means that the input to the StateGraph constructor or builder did not match the required types. A valid input should be a S
StateSchema provides a unified API for defining LangGraph state schemas.
A run stream for a child subgraph within a parent graph execution.
Extends GraphRunStream with a parsed name and index extracted from the last segment of the namespace path. The segment is expected t
Represents a state field whose value is transient and never checkpointed.
Use UntrackedValue for state fields that should be tracked for the lifetime of the process, but should not participate in dur
The Pregel class is the core runtime engine of LangGraph, implementing a message-passing graph computation model inspired by [Google's Pregel system](https://research.google/pubs/pregel-a-system-for-l
A projection channel for StreamTransformers.
Implements AsyncIterable<T> so it can be iterated directly by
in-process consumers via run.extensions.<key>. Channels created with
StreamChannel.remot
A node that runs the tools requested in the last AIMessage. It can be used either in StateGraph with a "messages" key or in MessageGraph. If multiple tool calls are requested, they will be run in para
Utility class for working with channels in the Pregel system. Provides static methods for subscribing to channels and writing to them.
Channels are the communication pathways between nodes in a Prege
The Pregel class is the core runtime engine of LangGraph, implementing a message-passing graph computation model inspired by [Google's Pregel system](https://research.google/pubs/pregel-a-system-for-l
The RemoteGraph class is a client implementation for calling remote
APIs that implement the LangGraph Server API specification.
For example, the RemoteGraph class can be used to call APIs from de
A projection channel for StreamTransformers.
Implements AsyncIterable<T> so it can be iterated directly by
in-process consumers via run.extensions.<key>. Channels created with
StreamChannel.remot
A projection channel for StreamTransformers.
Implements AsyncIterable<T> so it can be iterated directly by
in-process consumers via run.extensions.<key>. Channels created with
StreamChannel.remot
Abstract base class for persistent key-value stores.
Stores enable persistence and memory that can be shared across threads, scoped to user IDs, assistant IDs, or other arbitrary namespaces.
Feature
Abstract base class for persistent key-value stores.
Stores enable persistence and memory that can be shared across threads, scoped to user IDs, assistant IDs, or other arbitrary namespaces.
Feature
Stores the result of applying a binary operator to the current value and each new value.
The main stream object returned by chat model streaming.
Implements AsyncIterable<ChatModelStreamEvent> for raw event access
and PromiseLike<AIMessage> for simple await usage.
One or more commands to update the graph's state and send messages to nodes. Can be used to combine routing logic with state updates in lieu of conditional edges
Final result from building and compiling a StateGraph.
Should not be instantiated directly, only using the StateGraph .compile()
instance method.
Reducer channel that stores only a sentinel in checkpoint blobs and reconstructs state by replaying ancestor writes through the reducer.
DeltaChannel avoids re-serializing the full accumulated valu
Represents a state field backed by a DeltaChannel.
Unlike ReducedValue (which stores the full accumulated value in every
checkpoint blob via BinaryOperatorAggregate), a DeltaValue field persists
A projection channel for StreamTransformers.
Implements AsyncIterable<T> so it can be iterated directly by
in-process consumers via run.extensions.<key>. Channels created with
StreamChannel.remot
Extend this class and pass an instance through callbacks to observe graph
interrupts and resumes. Lifecycle methods are always awaited, including when
other callbacks run in the background. Set `rai
Raised when a graph run exits early due to a drain request.
This indicates the graph stopped cooperatively at a superstep boundary because RunControl#requestDrain was called (e.g., in response to SIG
Primary run stream for a LangGraph execution.
Implements AsyncIterable over ProtocolEvent and exposes ergonomic projections for values, messages, subgraphs, output, and interrupts. Created by createG
In-memory key-value store with optional vector search.
A lightweight store implementation using JavaScript Maps. Supports basic key-value operations and vector search when configured with embeddings.
Failure context passed to a node-level error handler.
A node-level error handler is registered via
StateGraph.addNode(name, fn, { errorHandler }). The handler runs ONLY after
the failing node's Ret
Raised by a node to interrupt execution.
Raised when a node invocation exceeds one of its configured timeouts.
Does not extend GraphBubbleUp (so it flows through the normal node error path) and is intentionally treated as retryable by t
Bypass a reducer and write the wrapped value directly to a BinaryOperatorAggregate channel.
Receiving multiple Overwrite values for the same channel in a single
super-step will raise an InvalidUpda
The Pregel class is the core runtime engine of LangGraph, implementing a message-passing graph computation model inspired by [Google's Pregel system](https://research.google/pubs/pregel-a-system-for-l
Represents a state field whose value is computed and updated using a reducer function.
ReducedValue allows you to define accumulators, counters, aggregators, or other fields whose value is determined
Exception raised when an error occurs in the remote graph.
Run-scoped control surface for cooperative draining.
Intended for a single graph run. Create a fresh RunControl per run; reusing a control after RunControl#requestDrain leaves it drained.
Safe to us
A message or packet to send to a specific node in the graph.
The Send class is used within a StateGraph's conditional edges to
dynamically invoke a node with a custom state at the next step.
Imp
A graph whose nodes communicate by reading and writing to a shared state.
Each node takes a defined State as input and returns a Partial<State>.
Each state key can optionally be annotated with a
Error thrown when invalid input is provided to a StateGraph.
This typically means that the input to the StateGraph constructor or builder did not match the required types. A valid input should be a S
StateSchema provides a unified API for defining LangGraph state schemas.
A projection channel for StreamTransformers.
Implements AsyncIterable<T> so it can be iterated directly by
in-process consumers via run.extensions.<key>. Channels created with
StreamChannel.remot
A run stream for a child subgraph within a parent graph execution.
Extends GraphRunStream with a parsed name and index extracted from the last segment of the namespace path. The segment is expected t
Represents a state field whose value is transient and never checkpointed.
Use UntrackedValue for state fields that should be tracked for the lifetime of the process, but should not participate in dur
Hydrate channels from a checkpoint, reconstructing any DeltaChannel
whose value is absent from channel_values by replaying ancestor writes.
For most channels (and for delta channels with a DeltaSna
Return the set of DeltaChannel names that should snapshot now.
A channel snapshots when EITHER its accumulated update count reaches
snapshotFrequency OR the total supersteps since its last snapshot
Synthetic task id for exit-mode DeltaChannel writes.
Embeds the superstep in the first UUID group so ORDER BY task_id, idx
preserves chronological order while remaining a valid RFC UUID (required b
Structural check for a DeltaChannel without importing it (avoids an
import cycle: delta.ts imports base.ts).
Get the config schema for a graph.
Get the input schema for a graph.
Get the output schema for a graph.
Get the state schema for a graph.
Get the update schema for a graph.
Creates a GraphRunStream with built-in transformers and kicks off the background pump that feeds raw stream chunks through the transformer pipeline.
Built-in transformers are registered in this order
Create the built-in lifecycle transformer.
Marked as a NativeStreamTransformer so the run stream
factory can expose _lifecycleLog via a dedicated getter
(run.lifecycle) rather than through `run.e
Creates a StreamTransformer that groups messages channel events into
per-message ChatModelStream instances.
A new ChatModelStream is created on message-start and closed on
message-finish. Con
Create the subgraph discovery transformer.
Registering this transformer against a mux replaces the legacy inline behavior that previously lived in StreamMux.push. The mux no longer knows about the su
Creates a StreamTransformer that captures values channel events
into a local StreamChannel. Only events whose namespace exactly
matches path are recorded; events from child or sibling namespaces
are
Define a LangGraph workflow using the entrypoint function.
Function signature
The wrapped function must accept at most two parameters. The first parameter is the input to the function. The
Filter a lifecycle StreamChannel to only the entries whose namespace lies within the subtree rooted at path.
Returns an AsyncIterable whose iterator yields every entry whose
namespace either equals
Filter a SubgraphDiscovery channel to only the direct children of a given namespace.
Returns an AsyncIterable whose iterator yields stream handles for
discoveries whose namespace is exactly one seg
A helper utility function that returns the LangGraphRunnableConfig that was set when the graph was initialized.
Note: This only works when running in an environment that supports node:async_hooks and
A helper utility function that returns the input for the currently executing task.
Note: When called without arguments, this relies on node:async_hooks /
AsyncLocalStorage, which is available in
Get the JSON schema from a SerializableSchema.
A helper utility function for use with the functional API that returns the previous state from the checkpoint from the last invocation of the current thread.
This function allows workflows to access
Detect if a schema has a default value by validating undefined.
Uses the Standard Schema ~standard.validate API to detect defaults.
If the schema accepts undefined and returns a value, that val
A helper utility function that returns the BaseStore that was set when the graph was initialized
Used for subgraph detection.
A helper utility function that returns the LangGraphRunnableConfig#writer if "custom" stream mode is enabled, otherwise undefined.
Interrupts the execution of a graph node.
This function can be used to pause execution of a node, and return the value of the resume
input when the graph is re-invoked using Command.
Multiple inte
True when payload is a lightweight checkpoint envelope (not a full-state
Pregel checkpoints debug payload).
A type guard to check if the given value is a Command.
Useful for type narrowing when working with the Command object.
Checks if the given graph invoke / stream chunk contains interrupt.
Type guard that tests whether a transformer is a NativeStreamTransformer.
Type guard that checks whether a value is a NodeError.
Type guard to check if a given value is a SerializableSchema, i.e.
both a Standard Schema and a Standard JSON Schema object.
Type guard to check if a given value is a Standard Schema V1 object.
Experimental. Batch reducer for use with DeltaChannel.
Processes all writes in one pass — dedup by ID and RemoveMessage
tombstoning — without calling messagesStateReducer.
This reducer is ba
Reducer function for combining two sets of messages in LangGraph's state system.
This reducer handles several tasks:
left and right message inputs to arrays.Manually push a message to a message stream.
This is useful when you need to push a manually created message before the node has finished executing.
When a message is pushed, it will be automaticall
Define a LangGraph task using the task function.
Tasks can only be called from within an entrypoint or from within a StateGraph. A task can be called like a regular function with the following diff
Reducer function for combining two sets of messages in LangGraph's state system.
This reducer handles several tasks:
left and right message inputs to arrays.A conditional edge function that determines whether to route to a tools node or end the graph.
This function is designed to be used as a conditional edge in a LangGraph state graph to implement the c
Maps a protocol event method to its subscription Channel.
Returns undefined for unrecognized methods so that new server-side
channels (e.g. from extension transformers) don't break existing
subscri
Whether namespace starts with prefix.
Segments are compared literally first; if the prefix segment itself contains
no :, the candidate segment is also compared after its dynamic suffix is
strip
@langchain/langgraph/stream — backend toolkit for the v2 streaming protocol.
This entrypoint collects the primitives needed to build a custom transport or server on top of the Agent Streaming Proto
Whether value names a protocol subscription channel — either a base
channel ("messages", "values", …) or a named custom channel
("custom:<name>"). Unknown/future method names return false,
m
Returns whether an event should be delivered for a subscription definition.
When the definition carries a since replay cursor, events at or before
that sequence number are excluded — letting the sa
Strip dynamic suffixes (after :) from a namespace segment.
Server-emitted namespaces contain runtime-generated suffixes like
"fetcher:abc-uuid", while user-supplied subscription filters are typic
True when payload is a lightweight checkpoint envelope (not a full-state
Pregel checkpoints debug payload).
Reducer function for combining two sets of messages in LangGraph's state system.
This reducer handles several tasks:
left and right message inputs to arrays.Creates a GraphRunStream with built-in transformers and kicks off the background pump that feeds raw stream chunks through the transformer pipeline.
Built-in transformers are registered in this order
Create the built-in lifecycle transformer.
Marked as a NativeStreamTransformer so the run stream
factory can expose _lifecycleLog via a dedicated getter
(run.lifecycle) rather than through `run.e
Creates a StreamTransformer that groups messages channel events into
per-message ChatModelStream instances.
A new ChatModelStream is created on message-start and closed on
message-finish. Con
Create the subgraph discovery transformer.
Registering this transformer against a mux replaces the legacy inline behavior that previously lived in StreamMux.push. The mux no longer knows about the su
Creates a StreamTransformer that captures values channel events
into a local StreamChannel. Only events whose namespace exactly
matches path are recorded; events from child or sibling namespaces
are
Define a LangGraph workflow using the entrypoint function.
Function signature
The wrapped function must accept at most two parameters. The first parameter is the input to the function. The
Filter a lifecycle StreamChannel to only the entries whose namespace lies within the subtree rooted at path.
Returns an AsyncIterable whose iterator yields every entry whose
namespace either equals
Filter a SubgraphDiscovery channel to only the direct children of a given namespace.
Returns an AsyncIterable whose iterator yields stream handles for
discoveries whose namespace is exactly one seg
A helper utility function that returns the LangGraphRunnableConfig that was set when the graph was initialized.
Note: This only works when running in an environment that supports node:async_hooks and
A helper utility function that returns the input for the currently executing task.
Note: When called without arguments, this relies on node:async_hooks /
AsyncLocalStorage, which is available in
Get the JSON schema from a SerializableSchema.
A helper utility function for use with the functional API that returns the previous state from the checkpoint from the last invocation of the current thread.
This function allows workflows to access
Detect if a schema has a default value by validating undefined.
Uses the Standard Schema ~standard.validate API to detect defaults.
If the schema accepts undefined and returns a value, that val
A helper utility function that returns the BaseStore that was set when the graph was initialized
Used for subgraph detection.
A helper utility function that returns the LangGraphRunnableConfig#writer if "custom" stream mode is enabled, otherwise undefined.
Interrupts the execution of a graph node.
This function can be used to pause execution of a node, and return the value of the resume
input when the graph is re-invoked using Command.
Multiple inte
True when payload is a lightweight checkpoint envelope (not a full-state
Pregel checkpoints debug payload).
A type guard to check if the given value is a Command.
Useful for type narrowing when working with the Command object.
Checks if the given graph invoke / stream chunk contains interrupt.
Type guard that tests whether a transformer is a NativeStreamTransformer.
Type guard that checks whether a value is a NodeError.
Type guard to check if a given value is a SerializableSchema, i.e.
both a Standard Schema and a Standard JSON Schema object.
Type guard to check if a given value is a Standard Schema V1 object.
Experimental. Batch reducer for use with DeltaChannel.
Processes all writes in one pass — dedup by ID and RemoveMessage
tombstoning — without calling messagesStateReducer.
This reducer is ba
Reducer function for combining two sets of messages in LangGraph's state system.
This reducer handles several tasks:
left and right message inputs to arrays.Manually push a message to a message stream.
This is useful when you need to push a manually created message before the node has finished executing.
When a message is pushed, it will be automaticall
Define a LangGraph task using the task function.
Tasks can only be called from within an entrypoint or from within a StateGraph. A task can be called like a regular function with the following diff
Attach formatted agent names to the messages passed to and from a language model.
This is useful for making a message history with multiple agents more coherent.
The root graph paused. Static interrupts can have an empty payload list.