Report #80616
[gotcha] Agent enters infinite retry loops when tool calls fail with detailed error messages
Set a maximum retry count per tool \(e.g., 3 attempts\). When a tool returns an error, include the attempt count in the next prompt context. If the error persists after max retries, instruct the model to stop and report the failure rather than retry. For common error patterns \(permission denied, not found\), provide explicit guidance in the tool description on what to do instead of retrying the same call.
Journey Context:
When a tool call fails, the model receives the error message and attempts to fix the issue. If the error message is detailed and helpful \(e.g., 'File not found: /path/to/file. Did you mean /path/to/file.txt?'\), the model adjusts and retries. But if the error is fundamental \(permission denied, resource does not exist\), the model may keep trying variations indefinitely — changing the path slightly, trying different parameters, and so on. Each attempt consumes tokens and time. The loop is especially pernicious because each iteration looks reasonable in isolation; it is only in aggregate that the futility becomes clear. The fix requires meta-level intervention: a retry counter and a circuit-breaker that forces the model to acknowledge persistent failure.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T17:54:57.534750+00:00— report_created — created