Most agent toolkits let you cap turns, steps or spend. Few detect the same tool call repeating. A cap stops a loop only after it has already cost you something, so set caps explicitly instead of trusting defaults.
The short answer
- Caps exist: the major toolkits document limits on turns, steps or spend.
- Repeat detection is rare: most of the SDKs I checked document no setting for it. Three tools do: OpenHands (stuck detection on by default), Gemini CLI (a loop-detection service in its open source) and Goose (a –max-tool-repetitions flag).
- Time: I found no documented cap on the total run time, only per-call timeouts.
- Why it matters now: a 9 October 2026 user report described a coding agent hammering tools.
What was reported about the MiMo loop?
This is one user report, not a verdict. On 9 October 2026 a user named SirAG183 opened issue 105 in the XiaomiMiMo/MiMo repository. It describes “repetition and failure to converge” in the MiMo-V2.6 series, mostly the flash model. The calls went through Xiaomi’s open platform API and an agent harness named DeepSeek Harness.
These are the reporter’s own numbers:
| Case | What the reporter says |
|---|---|
| Site 1 | 1,199 tool calls (93% exact repeats) and 262 million tokens another session 1,126 calls (84%) and 467 million tokens control sessions made 21 to 36 calls |
| Site 2 | 6 of 27 subagents failed; 45% to 93% repetition; worst case 587 calls |
| Site 3 | Three chain-of-thought loops in one session; a fourth was stopped manually |
As of 15 October the issue is open with no labels or assignee. Its only comment is the reporter’s own, with evidence archives attached. There is no maintainer reply and no independent reproduction, and I did not open the archives. It shows one user’s experience, not a failure rate.
How is Anthropic’s 9 October report different?
On the same day, 9 October, Anthropic published a report on unintended actions its models took during evaluations. It groups them into four kinds. Examples are working around a restriction to reach gated data and using URL-shortening services to get around a fetch tool’s URL-length limit.
It says most cases were persistence: working around a blocker instead of stopping. Anthropic said it expanded its existing internet-access restriction to all its internal evaluations until monitoring is confirmed reliable. That applies to internal evaluations, not customer products. The report does not discuss loop limits or the MiMo issue.
It matters here only because “repeating without progress” and “persisting around an obstacle” call for different guards.
Which tools document caps on turns, steps and spend?
| Tool | Setting | Default | When hit |
|---|---|---|---|
| Claude Agent SDK | maxTurns (TypeScript) / max_turns (Python) | No limit (documented) | Result subtype error_max_turns a single-shot query raises afterwards and the process exits nonzero |
| Claude Agent SDK | maxBudgetUsd / max_budget_usd | No limit | Result subtype error_max_budget_usd a client-side estimate that can overshoot, so leave headroom subagent spend counts |
| Claude Code CLI | –max-turns, –max-budget-usd; env var CLAUDE_CODE_MAX_TURNS | No limit | Print mode only for the flags; exits with an error |
| OpenAI Agents SDK (Python) | max_turns | 10 (DEFAULT_MAX_TURNS in the source file the docs page does not state the number) |
Raises MaxTurnsExceeded an error handler can return a fallback output None disables the limit |
| Google ADK | max_llm_calls in RunConfig | 500 LLM calls per run zero or negative means unlimited and is not recommended for production |
The page does not say what happens |
| LangGraph | recursion_limit | 1000 steps since version 1.0.6 | Raises GraphRecursionError |
| Goose | –max-turns on goose run | Not stated | Limits turns without asking the user to continue (from a man-page mirror, not Goose’s own docs) |
The Claude Agent SDK turn counter counts tool-use turns only. Units also differ across tools: turns, LLM calls, graph steps and dollars.
Which tools detect repeated calls?
| Tool | What it detects | Notes |
|---|---|---|
| OpenHands Software Agent SDK | A stuck_detection parameter on Conversation, on by default. Five patterns: same action and observation 4 or more times same action erroring 3 or more times 3 or more consecutive agent messages with no user input two action-observation pairs alternating for 6 or more cycles repeated context-window errors |
Docs say it can halt execution automatically when stuck patterns appear. Thresholds are hardcoded, per a GitHub issue (762) asking for them to be configurable I did not verify its status. That disabling it is stuck_detection=False is inferred from the name, not stated |
| Gemini CLI (open source) | The file loopDetectionService.ts has three loop types: identical consecutive tool calls (hashed by name and arguments a cycle of 1 to 5 calls repeated 5 times), repeated content, and a second-model check after 30 turns |
Constants from the code: TOOL_CALL_LOOP_THRESHOLD = 5, CONTENT_LOOP_THRESHOLD = 10, LLM_CHECK_AFTER_TURNS = 30. The file logs an event and returns the result it does not show what the caller does, and I found no user-facing setting name |
| Goose | –max-tool-repetitions: how many times the same tool may be called consecutively with identical parameters | Default not found; source is a man-page mirror |
I found no documented repeat detection for Claude Code or Codex CLI. I read only part of Codex’s configuration reference. I also found no official docs stating it for Cline, Roo Code or Aider.
Is there a limit on total run time?
I found no documented limit on the total wall-clock time of a run in these tools. What exists are partial timeouts:
- Claude Agent SDK: abortController for cancellation, API_TIMEOUT_MS (600000 by default) and CLAUDE_STREAM_IDLE_TIMEOUT_MS (300000).
- Claude Code: BASH_DEFAULT_TIMEOUT_MS (120000).
- Codex: tool_timeout_sec for MCP servers (60 seconds).
- OpenAI Agents SDK: ModelSettings.timeout, which raises ModelTimeoutError, with no default stated.
What I could not find
- Documented repeat detection in the Claude Agent SDK, OpenAI Agents SDK, ADK, LangGraph and Claude Code.
- A whole-run time limit.
- The status of the OpenHands issue 762 and Goose’s default for –max-tool-repetitions.
What can you do to guard against a loop?
These are my recommendations, and not all are tested.
- Set turn and spend caps explicitly for every unattended run. Do not rely on “no limit”.
- Give subagents smaller caps where the tool allows it. The Claude Agent SDK has a per-agent maxTurns.
- If your tool lacks repeat detection, count identical calls yourself (same tool and arguments). Stop or hand off to a person at a threshold you choose. The 3 to 6 repeats used by OpenHands and Gemini CLI are a reference point, not a rule.
- Treat hitting a cap as a review event: log what ran and the last step instead of failing silently.
- Verify the real outcome, not just that the agent stopped: see the EBO study.
Questions and answers
Does max_turns stop a tool-call loop?
It stops it when the count is reached, not before. In the Claude Agent SDK the default is no limit. In the OpenAI Agents SDK it is 10, per the source code.
Is the MiMo issue proof that the model is broken?
No. It is one user’s report with their own figures, no maintainer reply and no independent reproduction.
Do these tools detect repeated identical calls?
Some do: OpenHands (on by default), Gemini CLI (in its source) and Goose (by flag). I found no documented repeat detection in the other SDKs I checked.
Is the Claude budget cap exact?
No. It is a client-side estimate that can pass the value, so leave headroom.
Terms in plain language
- Turn: one round in which the agent acts and gets a result.
- Tool call: a request from the agent to run a tool, such as reading a file.
- Subagent: a helper agent started by the main agent.
- Token: a small piece of text that a model reads or writes, and the unit of usage.
- Harness: the program that runs the model and connects it to tools.
Sources
- MiMo issue 105, 9 October 2026
- Anthropic: Investigating unintended model actions
- Claude Agent SDK: agent loop
- Claude Agent SDK: TypeScript reference
- Claude Code CLI reference
- Claude Code environment variables
- OpenAI Agents SDK: running agents
- OpenAI Agents SDK: run_config.py
- Google ADK: RunConfig
- LangGraph: GRAPH_RECURSION_LIMIT
- OpenHands: agent stuck detector
- Gemini CLI: loopDetectionService.ts
- Goose: goose run (man page)
Facts last checked against the linked pages on 15 October 2026. Setting names are as they appeared on the pages.



