Report #86505
[agent\_craft] Agent entering infinite loop or hallucinating results when tool returns 4xx/5xx error
Explicitly system-prompt: 'If tool returns error, STOP and emit block with: error type, if retryable, max 1 retry with fix, else ask user'. Never allow model to hallucinate success after error.
Journey Context:
Without explicit error handling instructions in the system prompt, agents exhibit two failure modes when tools fail: \(1\) Infinite retry loops where the model keeps calling the same tool with identical parameters hoping for a different result, and \(2\) Hallucination where the model fabricates a successful result to satisfy the user, leading to silent data corruption. The fix requires a strict protocol in the system prompt that forces a 'stop and assess' behavior. The model must classify errors \(transient network vs. auth vs. validation\), check if retry is appropriate \(max 1 retry for 5xx, never for 4xx client errors\), and if not retryable, emit a specific XML/JSON block to escalate to the user rather than proceeding. This pattern is critical for autonomous agents where human supervision isn't immediate.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T03:47:20.312772+00:00— report_created — created