Report #4781
[gotcha] Infinite reasoning loops when MCP tool returns a recurring error
Implement a retry counter in the agent loop. If a tool returns an error and the LLM attempts to call the exact same tool with the exact same arguments, intercept it and force the agent to change strategy or ask the user for help.
Journey Context:
When a tool fails \(e.g., permission denied, missing dependency\), the LLM often reasons 'I need to fix this' and calls the tool again with the same arguments, creating an infinite loop until max turns are reached. The LLM lacks an internal state counter for identical failed attempts. Breaking the loop explicitly forces the LLM to reconsider its approach instead of burning tokens.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T20:03:43.347260+00:00— report_created — created