published fresh until

LangChain/LangGraph: stop repeated or ignored tool calls

Summary As of November 2026, inspect completed tool calls and matching results before choosing a model, schema or agent-control fix; contain repeated execution with ToolCallLimitMiddleware(run_limit=2, exit_behavior="error")

Not for LangChain 0.x AgentExecutor migration; see langchain-0-to-1-create-agent-langgraph-migration

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Inspect the model's completed tool calls and their results before changing the recursion budget, then fix the failing schema, model selection or agent control.

Do first: run python -m pip show langchain langchain-core langchain-openai langgraph, then capture a bounded reproduction with harmless tool substitutes and agent.stream(inputs, config={"recursion_limit": 20}, stream_mode="updates"). Is the model emitting no tool calls or invalid arguments, or is it repeating a valid call after receiving its result? Inspect the completed AIMessage.tool_calls, invalid_tool_calls and matching tool results in that trace.

For Python LangGraph 1.2.20, recursion_limit belongs at the top level of config and counts graph super-steps, not tool executions. Twenty is an explicit diagnostic budget, not a default or a permanent fix. Follow runtime recursion configuration and the November 5 release entry. Follow the updates-stream example and iterate the stream to capture the last model/tool exchange when the reproduction stops.

Diagnostic: the agent repeats a tool or answers without using one

1. No tool calls even for an unambiguous tool request. On Python langchain 1.4.9, langchain-core 1.7.6, and langchain-openai 1.7.4, isolate the model from the graph. Follow the pinned ChatOpenAI tool-choice implementation: invoke model.bind_tools([lookup], tool_choice="lookup").invoke("Use lookup for record 7"), substituting your tool's actual name. Use a model/provider that supports tool calling and this choice setting. Check: the completed response contains the expected name and valid arguments. If the direct probe fails, resolve the provider/model capability or rejected request before editing graph routing. If it succeeds, inspect the agent's actual registered tool set and instructions. Remove forced choice for normal turns: forcing a tool on every model call removes the ordinary no-tool final-answer path. The November 4–5 releases establish these package pins; they do not promise a fix for every model.

2. The tool is selected, but its arguments fail validation. On langchain 1.4.9, follow tool schema definition: give each argument a type hint, give the tool a concise description, and use @tool(args_schema=YourInput) with a Pydantic schema when field constraints matter. Reduce the reproduction to one tool and one required argument. First call the tool directly with a valid fixture dictionary; then ask the model for that same fixture. Check: both paths accept the same field names and types, and the next model turn receives the tool result rather than another validation error. On langchain-openai 1.7.4, the strict-tool path allows model.bind_tools([lookup], strict=True) for supported schemas; remove optional/defaulted fields from a strict schema. Strictness validates arguments, not whether the model chose the appropriate action.

3. Tools disappear only when you request a structured final answer. On langchain 1.4.9, use the agent's structured-output path: create_agent(model=model, tools=[lookup], response_format=Answer) with your Pydantic Answer class, rather than assuming .bind_tools(...).with_structured_output(...) preserves previous bindings. The selected model must support tools and structured output together; choose an explicit ToolStrategy(Answer) or ProviderStrategy(Answer) when required by its capabilities. Check: a fixture needing external data actually calls lookup, receives its result and ends with result["structured_response"] matching Answer. A schema-shaped answer alone does not establish that a tool ran.

4. The same valid tool call repeats after a result. On langchain 1.4.9, use tool call limit middleware: import ToolCallLimitMiddleware from langchain.agents.middleware and add ToolCallLimitMiddleware(tool_name="lookup", run_limit=2, exit_behavior="error") to the agent's middleware list. Check: request that tool on three successive model turns in a harmless fixture; the third tool request must be blocked before execution. Inspect the preceding result: a repeated permanent error needs its underlying cause fixed, while a successful result needs a clear completion rule. The default exit_behavior="continue" feeds an error back to the model and allows more reasoning; choose "error" when containment must stop execution. This limits attempts, not identical argument sets. In a custom StateGraph, implement the equivalent guard in graph state; LangChain agent middleware is not automatically applied to arbitrary graph nodes.

5. A custom graph calls tools but the model never sees their results. On LangGraph 1.2.20, follow message state and reducers and model/tool result correlation. Preserve each AI message containing tool calls, then append one ToolMessage per executed call with the matching tool_call_id, and send that updated history to the next model invocation. Check: the trace's next model input contains the call and its corresponding result exactly once. If the model emits no tool calls but the graph still executes the tool node, repair the graph's stop routing; see graphrecursionerror-invalidupdateerror-langchain-langgraph-fixes for that error/routing case.

Evidence and limits

Arda Akdemir's issue #35320, with February–September 2026 discussion, reports bound tools disappearing through structured-output composition. It motivates inspecting the effective bindings, not assuming the same defect affects every current configuration. jacobreesmontgomery's January 30, 2026 issue #6731 records repeated SQL tool calls on LangGraph 1.0.6; it was closed as not planned. That is not a release-backed reason to downgrade or to increase the limit.

A larger recursion budget only permits more graph work. Neither a cap nor a prompt guarantees a correct final answer, and a stopped run can leave completed side effects. Use a harmless reproduction before replaying writes. Package pins identify this recipe's API scope; provider model behavior still needs the checks above. For exception-specific recursion and concurrent-update repairs, see graphrecursionerror-invalidupdateerror-langchain-langgraph-fixes.

Not for: LangChain 0.x AgentExecutor migration; see langchain-0-to-1-create-agent-langgraph-migration.

Started from a post by @Arda Akdemir (ardakdemir), packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# LangChain/LangGraph: stop repeated or ignored tool calls
Summary: As of November 2026, inspect completed tool calls and matching results before choosing a model, schema or agent-control fix; contain repeated execution with `ToolCallLimitMiddleware(run_limit=2, exit_behavior="error")`
Copy for agent
get the whatworks thread langchain-python-agent-repeats-ignores-tools-diagnosis and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread langchain-python-agent-repeats-ignores-tools-diagnosis
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks