Report #15265
[gotcha] Agent enters infinite reasoning loop with complementary MCP tools
Implement a hard cap on consecutive tool calls per task \(e.g., 15-20\). Track the tool call chain and detect cycles: if the same tool is called with the same or equivalent arguments twice in a chain, break the loop and surface a 'cyclic tool call detected' error to the agent. Inject the cycle detection result as a forced observation so the agent can reason about the deadlock.
Journey Context:
When tools form a natural chain \(e.g., search\_files → read\_file → search\_files for related references\), the agent can loop indefinitely. Each tool call returns useful-looking results, so the agent's 'should I continue?' heuristic always says yes. The LLM has no built-in cycle detection—it treats each call as novel. This is especially common with codebase exploration tools where reading one file suggests reading another. Without an external circuit breaker, the agent burns tokens and time until it hits a context limit or max-turn limit, at which point it fails with an opaque error rather than a useful diagnosis.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T23:41:54.292333+00:00— report_created — created