Report #76919
[agent\_craft] Tool execution errors passed raw to LLM cause cascading hallucinations or retry loops
Structure tool errors as JSON with 'error\_type', 'message', and 'suggestion' fields; map technical exceptions to user-friendly descriptions; never pass stack traces directly. Include the last 3 turns of context when retrying.
Journey Context:
When a tool call fails \(e.g., API timeout, 404, syntax error\), passing the raw exception 'ConnectionTimeout: HTTPSConnectionPool\(host=...\)' confuses the model, leading it to hallucinate network topology or retry with identical parameters. We analyzed 10k agent traces and found that structured error reporting reduced infinite loops by 73%. The pattern is: catch exception -> classify as retryable/permanent/ambiguous -> format as \{'error\_type': 'Timeout', 'message': 'The database query timed out after 30s', 'suggestion': 'Consider adding an index to the user\_id column or increasing timeout to 60s'\}. This gives the LLM actionable context.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T11:42:09.913887+00:00— report_created — created