langchain-ai/langgraph · error · ValueError
Number of tools in the model.bind_tools() and tools passed…
Error message
Number of tools in the model.bind_tools() and tools passed to create_react_agent must match Got {len(tools)} tools, expected {len(bound_tools) - num_builtin} What it means
Raised by create_react_agent validation when the tools bound to the model via model.bind_tools() do not match in count the tools passed to create_react_agent. The agent registers its own tool node, so the bound tool list must align (minus built-in tools).
Solutions
- Pass the same tool set to both bind_tools() and create_react_agent(tools=...)
- Do not pre-bind tools on the model; let create_react_agent bind them
- Account for built-in tools when counting (num_builtin)
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py:194 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of langchain-ai/langgraph@38031739e5 (2026-08-26).
Data as JSON: /api/errors/c62e3d064285de2b.
Report an issue: GitHub.
Appendix: source
Thrown at libs/prebuilt/langgraph/prebuilt/chat_agent_executor.py:194
if isinstance(model, RunnableSequence):
model = next(
(
step
for step in model.steps
if isinstance(step, (RunnableBinding, BaseChatModel))
),
model,
)
if not isinstance(model, RunnableBinding):
return True
if "tools" not in model.kwargs:
return True
bound_tools = model.kwargs["tools"]
if len(tools) != len(bound_tools) - num_builtin:
raise ValueError(
"Number of tools in the model.bind_tools() and tools passed to create_react_agent must match"
f" Got {len(tools)} tools, expected {len(bound_tools) - num_builtin}"
)
tool_names = set(tool.name for tool in tools)
bound_tool_names = set()
for bound_tool in bound_tools:
# OpenAI-style tool
if bound_tool.get("type") == "function":
bound_tool_name = bound_tool["function"]["name"]
# Anthropic-style tool
elif bound_tool.get("name"):
bound_tool_name = bound_tool["name"]
else:
# unknown tool type so we'll ignore it
continue
bound_tool_names.add(bound_tool_name)View on GitHub (pinned to 38031739e5)