Tools in the Graph
If the model both 'decides' and 'executes' inside one node, you cannot interrupt before a refund or retry a failed HTTP call. Split think and act.
A doctor writes a prescription (assistant). The pharmacy fills it (ToolNode). They are not the same room — and you can stop the prescription before it is filled.
Visual Workflows
Start here — scroll inside each diagram frame to explore, then use + / − to zoom up to 200% if needed.
Overview
Scroll inside the frame to explore · use + / − to zoom up to 200%
Scroll inside the frame to explore · use + / − to zoom up to 200%
One tool call, one observation
Scroll inside the frame to explore · use + / − to zoom up to 200%
ToolNode writes tool messages into state. The assistant sees them on the next turn.
Which tools belong here
Scroll inside the frame to explore · use + / − to zoom up to 200%
Lookup and refund are tools. 'Be helpful' is not a tool. Prompt text is not a tool.
Key Takeaways
- 1.A tool is a typed function the model may call. ToolNode is the prebuilt node that actually runs those functions. The assistant node binds tools to the LLM. It does not execute them. Execution is a different station.
- 2.tools_condition looks at the last AI message: tool calls → ToolNode, otherwise Finish. Give each tool a tight schema. A tool named do_anything is how agents wander.
- 3.Bind tools on the chat model, then add_node('tools', ToolNode(tools)). Route with tools_condition.
- 4.Tool args should be validated (Pydantic). Side-effect tools (email, refund) belong behind a human gate in the next modules — not free-fire from ToolNode.
Learn elsewhere
- →Tool Calling — Phase 7
- →Human-in-the-Loop
Real Example
Scenario
User: 'Refund order 4411.' Assistant emits create_refund(order_id=4411). ToolNode would hit finance — unless you insert an interrupt before that tool. That interrupt is the next chapter's cousin (HITL).
What you would do
Start with one read-only tool (lookup_order). Add write tools only after checkpoints and interrupts exist in your head.
Commands
Commands to Remember
ToolNode(tools) # execute, do not decidemodel.bind_tools(tools) # assistant may request callstools_condition # tool calls vs FinishRead-only tools first, write tools behind a gate
Cheat Sheet
Quick recap
quick ref- •Bind on the model
- •Execute in ToolNode
- •Route with tools_condition
- •Gate writes
Common Mistakes
- ✕Executing tools inside the assistant node so you cannot pause before a side effect
- ✕One mega-tool instead of lookup vs refund
- ✕No schema on arguments, so the model passes garbage
