Nodes
A node is a Python function that owns one unit of work. It reads state and returns an update. The function may be synchronous or asynchronous.1
Tiny example
Section titled “Tiny example”def classify_ticket(state: TicketState) -> dict: urgent = "production" in state["message"].lower() return {"priority": "high" if urgent else "normal"}
builder.add_node("classify_ticket", classify_ticket)Good node boundaries match failure boundaries:
- Read one input.
- Perform one understandable operation.
- Return a small update.
Failure note
Section titled “Failure note”If the last operation in a large node fails, the node attempt may run again from its beginning. Separate external services into separate nodes, and make writes idempotent.2
Related
Section titled “Related”Footnotes
Section titled “Footnotes”-
LangChain, Graph API overview. ↩
-
LangChain, Thinking in LangGraph. ↩