Send
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. Importantly, the sent state can differ from the core graph’s state, allowing for flexible and dynamic workflow management.One common use case is a “map-reduce” workflow where your graph invokes the same node multiple times in parallel with different states, before aggregating the results back into the main graph’s state.Defined in: langgraph/types.py:289Attributes
The name of the target node to send the message to.
The state or message to send to the target node.
Methods
Initialize a new instance of the
Send class.Parameters:node(str): The name of the target node to send the message to.arg(Any): The state or message to send to the target node.
Usage Example
Command
One or more commands to update the graph’s state and send messages to nodes.The
Defined in:
Command primitive enables dynamic control flow by allowing nodes to:- Update the graph’s state
- Resume from interrupts
- Navigate to specific nodes
- Send messages to nodes with custom inputs
Defined in:
langgraph/types.py:368Attributes
Graph to send the command to. Supported values:
None: the current graphCommand.PARENT: closest parent graph
Update to apply to the graph’s state.
Value to resume execution with. To be used together with
interrupt(). Can be:- Mapping of interrupt ids to resume values
- A single value with which to resume the next interrupt
Can be one of the following:
- Name of the node to navigate to next (any node that belongs to the specified
graph) - Sequence of node names to navigate to next
Sendobject (to execute a node with the input provided)- Sequence of
Sendobjects
Class Variables
Special constant to target the parent graph in a command.
Usage Example
interrupt
Interrupt the graph with a resumable exception from within a node.The
interrupt function enables human-in-the-loop workflows by pausing graph execution and surfacing a value to the client. This value can communicate context or request input required to resume execution.Important: You must enable a checkpointer for interrupts to work, as the feature relies on persisting the graph state.Defined in: langgraph/types.py:420Parameters
The value to surface to the client when the graph is interrupted.
Returns
On subsequent invocations within the same node (same task to be precise), returns the value provided during the first invocation.
Raises
On the first invocation within the node, halts execution and surfaces the provided value to the client.
How It Works
- First invocation: Raises a
GraphInterruptexception, halting execution. The providedvalueis sent to the client. - Resuming: A client must use the
Commandprimitive with aresumevalue to continue execution. - Re-execution: The graph resumes from the start of the node, re-executing all logic.
- Multiple interrupts: If a node contains multiple
interruptcalls, LangGraph matches resume values to interrupts based on their order in the node.
Usage Example
Interrupt
Information about an interrupt that occurred in a node.Added in: v0.2.24
Changed in: v0.4.0 (added
Changed in: v0.6.0 (removed
Defined in:
Changed in: v0.4.0 (added
id property)Changed in: v0.6.0 (removed
ns, when, resumable, interrupt_id)Defined in:
langgraph/types.py:161Attributes
The value associated with the interrupt.
The ID of the interrupt. Can be used to resume the interrupt directly.
Methods
Create an
Interrupt from a namespace string.Parameters:value(Any): The interrupt valuens(str): Namespace string
InterruptRetryPolicy
Configuration for retrying nodes.Added in: v0.2.24
Defined in:
Defined in:
langgraph/types.py:119Attributes
Amount of time that must elapse before the first retry occurs. In seconds.
Multiplier by which the interval increases after each retry.
Maximum amount of time that may elapse between retries. In seconds.
Maximum number of attempts to make before giving up, including the first.
Whether to add random jitter to the interval between retries.
List of exception classes that should trigger a retry, or a callable that returns
True for exceptions that should trigger a retry.Usage Example
CachePolicy
Configuration for caching nodes.Defined in:
langgraph/types.py:145Attributes
Function to generate a cache key from the node’s input. Defaults to hashing the input with pickle.
Time to live for the cache entry in seconds. If
None, the entry never expires.Usage Example
Overwrite
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 InvalidUpdateError.Defined in: langgraph/types.py:547Attributes
The value to write directly to the channel, bypassing any reducer.
Usage Example
StateSnapshot
Snapshot of the state of the graph at the beginning of a step.Defined in:
langgraph/types.py:268Attributes
Current values of channels.
The name of the node to execute in each task for this step.
Config used to fetch this snapshot.
Metadata associated with this snapshot.
Timestamp of snapshot creation.
Config used to fetch the parent snapshot, if any.
Tasks to execute in this step. If already attempted, may contain an error.
Interrupts that occurred in this step that are pending resolution.
PregelTask
A Pregel task.Defined in:
langgraph/types.py:223Attributes
Unique identifier for the task.
Name of the node this task executes.
Path to this task in the execution tree.
Error that occurred during task execution, if any.
Interrupts that occurred during task execution.
State snapshot for this task.
Result of the task execution, if completed.
Type Aliases
Durability
Durability mode for the graph execution.
'sync': Changes are persisted synchronously before the next step starts.'async': Changes are persisted asynchronously while the next step executes.'exit': Changes are persisted only when the graph exits.
langgraph/types.py:62All
Special value to indicate that graph should interrupt on all nodes.Defined in:
langgraph/types.py:70Checkpointer
Type of the checkpointer to use for a subgraph.
Trueenables persistent checkpointing for this subgraph.Falsedisables checkpointing, even if the parent graph has a checkpointer.Noneinherits checkpointer from the parent graph.
langgraph/types.py:73StreamMode
How the stream method should emit outputs.
"values": Emit all values in the state after each step, including interrupts. When used with functional API, values are emitted once at the end of the workflow."updates": Emit only the node or task names and updates returned by the nodes or tasks after each step. If multiple updates are made in the same step (e.g. multiple nodes are run) then those updates are emitted separately."custom": Emit custom data using from inside nodes or tasks usingStreamWriter."messages": Emit LLM messages token-by-token together with metadata for any LLM invocations inside nodes or tasks."checkpoints": Emit an event when a checkpoint is created, in the same format as returned byget_state()."tasks": Emit events when tasks start and finish, including their results and errors."debug": Emit"checkpoints"and"tasks"events for debugging purposes.
langgraph/types.py:95StreamWriter
Callable that accepts a single argument and writes it to the output stream.Always injected into nodes if requested as a keyword argument, but it’s a no-op when not using stream_mode="custom".Defined in: langgraph/types.py:111Utilities
ensure_valid_checkpointer
Validate that a checkpointer value is valid.Parameters:
checkpointer(Checkpointer): The checkpointer to validate
Checkpointer - The validated checkpointerRaises: TypeError if the checkpointer is invalidDefined in: langgraph/types.py:82