Report #74854
[synthesis] Agent loops infinitely or hallucinates when a tool returns an error
For Claude, return explicit, structured error messages in the tool result \(e.g., JSON with 'error' key\); for GPT-4o, include the stack trace and a hint; for Gemini, explicitly tell it to try a different approach in the next turn.
Journey Context:
When a tool execution fails \(e.g., file not found\), how the model recovers depends on the provider. Claude relies heavily on the immediate tool result; if it returns a raw stack trace, Claude might get confused and retry the exact same call. It needs an explicit 'Error: file not found, check the path' to course-correct. GPT-4o is better at inferring the error from a stack trace and adjusting. Gemini often loops infinitely on the same failing call unless explicitly told to stop and rethink.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T08:14:18.340396+00:00— report_created — created