Skip to main content
Send runs the same node once per item with a custom input when the item count is known only at runtime (map-reduce). Command updates state and chooses the next node in one return. For ordinary sequences, branches, and loops, see Control flow. For concepts, see Send and Command on the Graph API overview.

Use Send for map-reduce

Return one or more Send objects from a conditional edge. Each Send names a target node and passes that invocation’s input. LangGraph runs those invocations in parallel. When workers write the same state key, use a reducer so updates merge (for example, concatenating lists). The worker below does not receive the full graph state. Send passes { "subject": ... } as that run’s input, so the worker schema includes subject even though the overall state does not.
Dashed edges are Send fan-out: one generate_joke invocation per subject. Stream node updates (this example has no chat model, so there are no message tokens to iterate):

Combine control flow and state updates with Command

Return a Command from a node when that step must both update state and choose what runs next. For routing alone, prefer conditional edges. Shape of a Command return (full graph below):
The end-to-end example uses three nodes: A, then B or C. Node A updates state and picks the next node with Command, so the graph has no conditional edges between A, B, and C.
Build the StateGraph. Control flow lives in node_a, so there are no conditional edges between A, B, and C.
Annotate the return type as Command with the possible destinations, for example Command[Literal["node_b", "node_c"]]. That declaration is required for graph rendering and tells LangGraph that node_a can navigate to node_b and node_c.
Dashed edges are Command routes from node_a. Repeated invokes take different paths (A → B or A → C) based on the random choice in node A.
From a node inside a subgraph, route to a node in the parent graph with graph=Command.PARENT:
The example below turns node A into a single-node subgraph and adds it to a parent graph that still contains B and C.
State updates with Command.PARENT When a subgraph node updates a key that exists in both the parent and subgraph state schemas, define a reducer for that key on the parent. See the example below.

Use inside tools

Return Command(update=...) from a tool to write graph state (for example, customer lookup results) during a turn. The fragment below assumes get_user_info / getUserInfo and a message history key named messages. Complete the imports and helpers in your app.
When returning Command from a tool, include messages (or whichever state key holds the message history) in Command.update, and that list must contain a ToolMessage. LLM providers require an AI message with tool calls to be followed by tool result messages.
For tools that return Command, prefer the prebuilt ToolNode, which propagates those objects into graph state. In a custom tool-calling node, propagate Command returns from tools yourself.

Resume after an interrupt

Use Command as input to invoke / stream only to resume after an interrupt (resume=..., optionally with update while resuming). Do not pass Command(update=...) alone to continue a conversation: any Command as input resumes from the latest checkpoint, not from START. Pass a plain state update to start a new turn. For the full anti-pattern example, see Input to invoke or stream. For interrupt patterns, see Interrupts.

See also