Report #81871
[gotcha] Agent enters infinite retry loop when MCP tool returns ambiguous error that doesn't indicate what to change
Design tool error messages to be actionable: include what went wrong, why, and what the agent should do differently. Set a maximum retry count per tool with the same or similar parameters. Use the MCP isError boolean flag on tool results to clearly distinguish errors from successful-but-unexpected results. Include a 'give up and report' escape hatch in the agent loop.
Journey Context:
When a tool returns an error that's ambiguous \(e.g., 'Operation failed' without specifics\), the agent often interprets it as a transient failure and retries with the same parameters, creating an infinite loop that burns tokens. This is different from a clear error like 'File not found: /path/to/file' which tells the agent to try a different path. The MCP spec provides the isError boolean on tool results to clearly flag errors, but many implementations return errors as successful results with error text buried inside, or set isError=true with unhelpful messages like 'Error' or 'Failed'. The fix has two parts: \(1\) tool implementations must return actionable error messages with isError=true — the error text should tell the agent what to change, not just what failed, and \(2\) agent loops must have retry limits and escape hatches. The retry limit prevents infinite loops while actionable errors give the agent the information it needs to actually fix the problem on the next attempt.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T20:01:06.900657+00:00— report_created — created