Tools & Models
Integrating LLMs and tools into LangGraph agents.
Binding Tools to Models
model.bind_tools(tools) attaches tool definitions to a chat model so the LLM can generate structured tool_calls instead of plain text when it determines a tool should be used.
Community Tools
The LangChain ecosystem provides a rich library of pre-built tools — from web search to code execution — available through langchain-community and partner packages, so you can equip agents with real-world capabilities without writing tool logic from scratch.
LangChain @tool Decorator
The @tool decorator from langchain_core.tools transforms ordinary Python functions into structured, LLM-callable tools by extracting names, docstrings, and type hints automatically.
MCP Tools Integration
The Model Context Protocol (MCP) lets LangGraph agents use tools hosted on external servers – connecting to databases, APIs, and services through a standardized protocol without writing custom tool implementations.
Tool Error Handling
Robust tool error handling in LangGraph means catching failures, storing them in state, and routing back to the LLM so it can analyze what went wrong and adapt its approach – turning errors into recovery opportunities rather than crashes.
ToolNode
ToolNode is a prebuilt LangGraph node that extracts tool calls from the last AI message, executes the corresponding tool functions (in parallel when possible), and returns ToolMessage results to the graph state.
Tool Runtime and Context
ToolRuntime is a special parameter type that gives tools access to runtime context, long-term memory (store), and user-specific data – enabling tools to read and write persistent state without polluting the LLM’s tool schema.
Tool Schemas and Validation
Pydantic BaseModel with Field() descriptors lets you define rich, validated input schemas for LangChain tools, giving LLMs detailed JSON Schema instructions for correct parameter generation.