Report #4739
[agent\_craft] Agent enters infinite loop or gives up after first tool error \(e.g., FileNotFoundError, SyntaxError\)
Implement a tiered error handler: \(1\) Parse error type—if SyntaxError/ValidationError, fix arguments; if Timeout/NetworkError, retry with backoff; if PermissionError, abort and ask user. \(2\) Never retry the exact same call >1 time; on second failure, mutate arguments based on error message content.
Journey Context:
Naive agents treat all errors as fatal or retry identically until max iterations. Anthropic's tool-use docs note that models can recover from errors if the error message is fed back into context, but without a strategy, the model tends to repeat the same incorrect call. LangChain's 'RetryParser' implements similar logic but for output parsing, not tool execution. The key insight is categorizing errors into 'user fixable' \(permissions, missing files\) vs 'agent fixable' \(syntax, wrong args\). For agent-fixable errors, the error message often contains the exact fix needed \(e.g., 'invalid column name' suggests checking schema\). The pattern is: catch exception → classify → if retryable, append error to chat history with explicit 'You made an error, please fix and retry' prefix → track retry count.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T19:59:42.141679+00:00— report_created — created