Command
A node returns Command when it must update state and choose the next node in one decision. Command(resume=...) is also the input used to resume an interrupt.1
Tiny example
Section titled “Tiny example”from typing import Literalfrom langgraph.types import Command
def decide(state: RefundState) -> Command[Literal["approve", "review"]]: next_node = "approve" if state["eligible"] else "review" return Command( update={"decision_recorded": True}, goto=next_node, )| Field | Meaning |
|---|---|
update |
State changes from this node |
goto |
Next node or nodes |
resume |
Value returned by a paused interrupt() |
graph=Command.PARENT |
Route from a subgraph to its parent |
Failure note
Section titled “Failure note”Do not combine goto with a normal outgoing edge unless both destinations should execute. Command(resume=...) is input for a paused graph; normal new input should remain a plain state dictionary.
Related
Section titled “Related”Footnotes
Section titled “Footnotes”-
LangChain, Graph API overview — Command. ↩