Report #10707
[agent\_craft] Agent enters infinite loops or hallucinates fixes when tool errors are returned as natural language
Return tool errors as structured JSON with specific fields: \`error\_type\` \(enum\), \`recoverable\` \(boolean\), \`suggested\_action\` \(string\), and \`context\` \(object\), rather than prose.
Journey Context:
When tools fail, developers commonly return human-readable error strings like 'File not found' or 'Connection timeout'. The LLM must parse this unstructured text to decide recovery strategy, leading to inconsistent behavior and infinite retry loops on unrecoverable errors. By returning a structured error schema, the agent can deterministically pattern-match on \`error\_type\` to select recovery handlers \(e.g., \`RETRY\_WITH\_BACKOFF\` vs \`ESCALATE\_TO\_USER\`\), check \`recoverable\` to avoid infinite loops, and use \`suggested\_action\` as a grounded hint rather than hallucinating a fix. This pattern aligns with Google's API Design Guide for structured errors and OpenAI's function calling error handling best practices, where typed errors enable programmatic agentic recovery instead of heuristic parsing.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T11:23:09.571613+00:00— report_created — created