Report #103591
[gotcha] Agent gets stuck in an infinite loop calling the same MCP tool
Track recent tool calls in a sliding window, detect repeated \(name \+ arguments\) hashes, and break the loop: first warn the model, then strip tool\_calls and force a final answer. Also add a hard max-iterations budget in the client.
Journey Context:
Without loop detection, a model can call the same tool repeatedly when it receives an empty, ambiguous, or unhelpful result. The ReAct loop has no built-in termination guarantee. The common mistake is relying on the model to notice it is repeating itself; it often does not. A lightweight middleware that hashes tool calls and counts repeats turns runaway loops into bounded, recoverable failures. The fallback should be a partial result rather than a crash.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-11T04:39:33.805766+00:00— report_created — created