When an AI agent repeats a tool call, inspect what changed between attempts: the arguments, the returned evidence, the state available to the next model call, and the condition that would end the task. An iteration ceiling limits how long a failure can continue. It does not fix missing evidence, a lost tool result, or a broken exit rule.
For someone evaluating an agent workflow, the important question is not simply “How many times did it call search?” It is “What new information could the next call provide?”
Separate a useful loop from a stuck loop
Repeated calls are not automatically mistakes. A search can follow pagination, a job-status check can wait for completion, and a corrected query can recover from an overly narrow filter. Each needs a reason to continue and a bounded stopping rule.
A suspicious loop repeats equivalent inputs against unchanged state and receives equivalent results, yet makes no progress toward the required output. Compare the meaning of arguments, not just their spelling. Two slightly different queries can retrieve the same documents.
LangChain’s recursion-limit troubleshooting guide distinguishes an unintended cycle from a complex graph that legitimately needs more steps. Reaching the limit alone does not establish which case occurred. A framework step limit is also not necessarily a one-for-one count of tool requests.
AMF recommends diagnosing the sequence before increasing its allowance.
Read the trace, not just the final answer
A trace is a record of the workflow’s events. For this diagnosis, collect:
- The task and its explicit completion requirements.
- The tool name and structured input for each attempt.
- The tool’s status and relevant result, including errors or pagination markers.
- The state update after the result and the information passed into the next model call.
- The next selected action and the runtime rule that allowed or rejected it.
- Tool-call count, elapsed time, model usage and final stop reason.
Retain evidence identifiers or redacted excerpts rather than copying secrets or unnecessary personal data into logs. Access to diagnostic records should be limited to the people who need them.
You do not need a model’s private chain of thought. Observable inputs, outputs, state transitions and enforcement decisions are enough to test many concrete failure hypotheses. A model-generated explanation of its behavior is not a substitute for those records.
A hypothetical policy-search failure
Suppose an internal assistant must draft an answer about a company’s equipment-return policy. It may search an approved document collection and produce a draft, but publication requires an editor.
The workflow is:
Question → search approved documents → inspect evidence → draft with sources → editorial review.
A failed run might contain this illustrative trace. The values are invented, not results from a deployed system.
Attempt 1
Tool: search_policy
Input: {"query":"equipment return window","collection":"approved-policies"}
Result: {"status":"ok","matches":[]}
State: evidence=[], searches_used=1
Next action: search_policy with identical input
Attempt 2
Tool: search_policy
Input: {"query":"equipment return window","collection":"approved-policies"}
Result: {"status":"ok","matches":[]}
State: evidence=[], searches_used=2
Runtime decision: stop
Stop reason: repeated_no_progress
Output: "No supporting policy found. Draft answer withheld."
The trace shows that the tool returned successfully but found no evidence. It does not show that no policy exists anywhere. The collection might be wrong, the indexing incomplete, or the query mismatched to the document’s terminology.
The stop protects the budget. The investigation still needs to determine why retrieval failed.
For this hypothetical workflow, a reasonable next attempt could use a documented synonym or inspect collection coverage, if authorized. Repeating the same search without a changed hypothesis adds little. If the needed document is unavailable, return the missing-evidence finding instead of inventing a policy.
Match the fix to the failure
The result never reaches the next decision
Inspect the actual state or messages supplied to the next model call. If the tool returned the policy but the runtime discarded it, changing models is not the first fix.
Repair the result-to-context handoff, then replay the case. A useful regression check asserts that the next decision receives the evidence identifier and relevant text.
The tool contract is confusing
An ambiguous parameter name, unclear error, or unexplained pagination token can produce repeated misuse. Make the schema and result contract explicit, then test valid inputs, empty results and failures.
Anthropic’s engineering guidance on effective agents emphasizes clear tool interfaces and observation of environmental feedback. This is vendor guidance, not proof that a particular interface change will improve your system.
The exit condition cannot be satisfied
A workflow that requires a source-backed answer but offers no outcome for “source unavailable” can keep searching indefinitely.
Add explicit outcomes such as completed, missing evidence, permission required and budget exhausted. A stop should preserve useful findings and tell the user what is still unresolved. Do not mark an unsupported answer as completed merely because the loop ended.
The agent ignores information it actually received
Only after checking retrieval, state and tool contracts should you isolate the model’s decision-making. Try a clearer task instruction or a different model against the same cases. Keep the workflow and evaluation criteria fixed so you can attribute a difference.
See when an agent should escalate to another model for the broader routing decision.
Put the limit outside the model’s promise
Anthropic describes maximum iteration counts as one stopping condition for maintaining control. AMF’s implementation recommendation is to enforce budgets in the runtime, rather than depend on an instruction that asks the model to stop.
Use separate bounds for tool calls, elapsed time and any meaningful spending allowance. Choose limits from the task’s expected work and consequences, not a universal magic number.
A no-progress detector can complement those limits, but it needs exceptions for authorized polling, pagination and other legitimate repetition. It should compare relevant state and results, not reject every repeated tool name.
The permission check is independent. If this policy assistant attempts to publish its draft, the runtime should reject the write because editorial authorization is absent, even on the first iteration. A loop budget is not an approval gate. The trace should record the attempted action, the denied permission and the fact that publication did not occur.
For a reusable way to describe that boundary, see tool access versus agent permission.
Test containment and repair separately
First test containment: does the workflow stop within its configured bounds, preserve evidence, and report the right unresolved outcome?
Then test repair: on a fixed set of cases, does the changed system complete more tasks correctly without introducing unacceptable latency, cost or unauthorized actions?
Include a successful retrieval, an empty result, a transient failure, a lost-state simulation, legitimate repeated polling and an attempted unapproved write. Record completion rate and answer correctness separately from tool calls, elapsed time, tokens and cost. A cheaper run that stops before producing a required answer is not automatically better.
Change one layer at a time where practical: prompt, model, tool contract or workflow. Keep the failed trace as a regression case. These are proposed tests, not tests executed for this article.
One question to answer without notes
An agent hits its iteration ceiling after searching eight times. What evidence would tell you whether to raise the limit?
A defensible answer names the tool inputs and results, state transitions, completion rule and progress between calls. Raising the ceiling is reasonable only when the trace shows necessary, productive work that the existing limit cuts short. When nothing changes, a larger budget usually buys a longer version of the same failure.
Provenance and limitations
Written for Agent Model Fit with AI-assisted research, synthesis and drafting. Primary documentation was checked November 13, 2026. The diagnostic checklist, workflow and examples are AMF recommendations, not a benchmark, product certification or universal safety guarantee. No agent implementation was executed for this guide. Framework defaults and APIs can change; consult the linked documentation for your installed version.