October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

Why LangGraph Agents Loop or Repeat Tool Calls—and How to Stop Them

Trace the first repeated transition to tell a routing cycle from an unbounded retry, stale state, or checkpoint replay—and apply the fix that fits.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When a LangGraph agent repeats a tool call, inspect the graph’s transitions and state before changing the model or raising a limit. The usual causes are a route that never reaches a terminal node, an unbounded retry path, or state that remains eligible for another pass. A resumed checkpoint can also replay a node, so side-effecting tools need protection against duplicate effects.

Find the first repeated transition

Reproduce the run and identify the node and tool invocation that repeat. Inspect the transitions and relevant state immediately before and after the first repeated cycle. This distinguishes a control-flow loop from a retry, stale state, or a node replay.

As an Amazon Associate I earn from qualifying purchases.

For a trace, follow the execution sequence node by node. LangChain’s Thinking in LangGraph describes tracing and debugging; LangSmith is an optional observability tool for examining execution behavior. The trace is evidence about the graph’s actual path, not proof that the model alone caused it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check whether routing can reach a terminal route

A LangGraph workflow needs a reachable stop condition. A cycle can keep routing between nodes until the graph reaches its step limit. The GRAPH_RECURSION_LIMIT documentation defines the error as: “Your LangGraph StateGraph reached the maximum number of steps before hitting a stop condition.” An unintended cycle is one common cause; a genuinely complex workflow can also require many iterations.

  1. Starting at the first repeated node, follow each outgoing edge, conditional edge, and Command-based route.
  2. Identify the condition that should end the workflow and confirm the state can make that condition true.
  3. Check that the successful route reaches END or an explicit done/terminal node, rather than returning to an earlier node.
  4. Check each conditional route’s possible results. A route that omits the expected result, or a condition that never changes, can make the terminal branch unreachable.

LangGraph’s Graph API overview illustrates routing to a done node once a count reaches a threshold. Use an equivalent explicit stopping route for your workflow; the condition and the state update that satisfies it should be easy to verify.

Bound retries and make recovery change the next decision

A tool-to-agent transition is not automatically a bug. The agent may need to inspect a result, choose another tool, or recover from an error. LangChain’s Thinking in LangGraph explains that routing can happen inside nodes through Command objects and shows error context being returned to the agent.

The key question is whether another attempt has a reason to succeed. Preserve useful error details so the agent can choose a different action, correct its input, or stop. A transient failure may justify a retry; an invalid request or persistent failure may instead need to be surfaced, routed to recovery, or handed to a person.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Set an explicit attempt bound or other stopping rule for every retry path.
  • Change the input, tool choice, or recovery route when the previous attempt provides information that should alter the next decision.
  • When the error cannot be recovered from automatically, route to a terminal or human-review path instead of cycling back unchanged.

Verify state updates and reducers

Inspect the state fields that control routing, including counters, messages, and errors. A node update may not replace a value: a reducer can merge or accumulate updates. For example, with an accumulating reducer, returning an empty list may leave earlier values in place rather than clear them. If replacement is intended, use overwrite semantics and confirm the state after the update.

Pay particular attention to a continuation condition such as “attempts remain” or “work remains.” If the field it reads is accumulated, not reset, or not updated on the route you expect, the condition may stay true and send execution around again. The Graph API documentation covers reducers and state updates.

Protect tools from checkpoint replay

A repeated external effect is not always caused by a routing cycle. When an interrupted or checkpointed run resumes, a node can run again from its beginning. If that node charges a card, sends a message, or writes to an external service, the action may be attempted again.

Make side-effecting operations safe to repeat. Depending on the tool, use an idempotency key, an upsert, or a read-before-write check. Do not assume graph execution guarantees exactly-once effects outside the graph. LangGraph’s Graph API overview discusses checkpointing and idempotency.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose the fix that matches the evidence

What the trace or state shows Likely issue Correction Trade-off or caution
The same route repeats and the terminal condition is not reached. Cycle, missing terminal route, or unreachable condition. Repair the edge or condition; ensure a reachable route to END or a done node. Increasing the step limit would let the cycle run longer, not fix it.
An error returns to the agent and the same attempt recurs without useful change. Unbounded or ineffective error-recovery loop. Bound attempts; change course using error context, or surface or hand off the error. Retries can help transient failures, but repeating an unchanged failing action has no stopping logic.
A continuation field remains true or old values survive an apparent reset. Reducer or state-update behavior does not match the intended replacement. Correct the reducer or use overwrite semantics; verify the resulting state. Changing routes without correcting state can leave the condition true.
A node’s external action occurs again after an interrupted run resumes. Checkpoint replay. Make the operation idempotent or check for an existing effect before writing. Graph-level routing fixes do not prevent duplicate external effects on replay.
The route, stop condition, retries, and state updates are correct, but a legitimate workflow still reaches the limit. The expected workflow needs more steps. Raise recursion_limit appropriately for the application. A higher limit also permits an accidental cycle to run longer before the guard stops it.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Use recursion_limit as a guardrail, not a repair

First inspect the repeated transitions, terminal routes, retry behavior, and state progress. Raise recursion_limit only when those checks show that the workflow is correct and genuinely needs more steps. LangGraph documents the limit as a way to accommodate complex graphs, but changing it does not make a broken cycle terminate. The documentation reviewed here does not establish a numeric default, so use the value and configuration guidance for the LangGraph version in your application.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.