Report #5709
[gotcha] Agent enters infinite retry loop on MCP tool errors
Inject a monotonically increasing attempt counter into the tool arguments or system prompt, and instruct the agent to change its strategy or abort if the same tool call fails consecutively with the same parameters.
Journey Context:
When an MCP tool returns an error \(e.g., file not found\), the LLM often tries to fix it by slightly tweaking the arguments, fails, and loops. Because the LLM has a limited context window, it might forget it already tried the exact same call 5 turns ago, leading to an infinite loop of failed tool calls until max tokens are exhausted. Standard retry logic doesn't work because the LLM isn't a deterministic program; it needs explicit state \(the attempt counter\) to break out of the cyclic reasoning pattern.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T22:04:08.710101+00:00— report_created — created