LangChain/Tools
Intermediate10 min

ToolNode & ToolRuntime

ToolNode is the prebuilt LangGraph node that executes tools in a graph. ToolRuntime gives tools access to conversation state, immutable context, long-term store, and streaming — without those values appearing in the tool's schema.

Quick Reference

  • from langgraph.prebuilt import ToolNode, tools_condition
  • ToolNode handles parallel execution, error handling, and ToolMessage creation
  • Add runtime: ToolRuntime to any tool signature — it's injected automatically, hidden from the model
  • runtime.state accesses conversation state; runtime.context for immutable config; runtime.store for persistent memory
  • Return Command(update={...}) from a tool to write back to agent state

ToolNode

ToolNode is the prebuilt LangGraph node that executes tool calls. It automatically handles parallel execution, wraps results in ToolMessages, routes errors, and injects runtime context. Use it when you're building a custom LangGraph workflow and need to handle tool execution without wiring it manually.

ToolNode in a LangGraph workflow