Report #84250
[gotcha] Agent enters infinite loop calling the same tool repeatedly with slight parameter variations
Implement a maximum tool-call iteration limit per agent turn \(e.g., 10–15 calls\). Track tool call history and detect when the same tool is called 3\+ times with similar parameters — then break the loop and prompt the model to reconsider its approach entirely.
Journey Context:
LLMs can get stuck in reasoning loops: they call a tool, get a result they did not expect, and call the same tool again with slightly different parameters, hoping for a different outcome. This is especially common with search/query tools where the model keeps refining its query. Each iteration consumes tokens and time, and the loop can continue until the context window is exhausted or the user manually interrupts. The common mistake is not having a circuit breaker at all, or setting the limit too high. The fix is two-fold: \(1\) a hard iteration limit that stops the loop, and \(2\) detection of repeated similar calls that signals the model to change strategy rather than retry. Some agent frameworks handle this, but many MCP client implementations do not.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T00:00:35.893264+00:00— report_created — created