Report #41490
[gotcha] Agent enters infinite loop calling same MCP tool with identical arguments
Track the last N tool-call signatures \(tool\_name \+ args hash\). If an identical call appears within the window, inject a system message forcing the agent to change strategy. Set a hard max-iterations limit per task \(e.g., 25 tool calls\). Include a 'call\_count' or 'attempt' hint in subsequent results.
Journey Context:
When a tool returns ambiguous or unhelpful results, the LLM often retries the exact same call, hoping for different output. This is the ReAct equivalent of insanity: doing the same thing and expecting different results. The loop is especially common with search tools that return empty results — the agent reformulates the query identically. Without loop detection, this continues until the token limit, wasting the entire budget on zero-progress iterations. The counter-intuitive aspect: the agent isn't broken — it genuinely believes a retry might work because it has no memory of already trying. The fix requires external state tracking because the LLM's attention window may not include the earlier failed attempt.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T00:06:54.793659+00:00— report_created — created