Report #10336
[agent\_craft] Agents loop infinitely or give up after a single tool execution error, failing to recover from transient API failures or argument mismatches
Implement a 'Reflexion' loop: 1\) Execute tool, 2\) On error, append the error message to the conversation history with a specific system prompt prefix like '\[REFLECTION\] The previous action failed with error:', 3\) Allow the model to generate a corrected tool call, 4\) Limit to N retries \(e.g., 3\) before escalating to user; explicitly pass the failed arguments back so the model can compare wrong vs right.
Journey Context:
Simple retry logic \(resending the same request\) often fails because the model doesn't know why it failed or how to fix it. Without the error feedback in the context window, the model is stateless between attempts. The Reflexion pattern treats the error as additional context, allowing the model to reason about the failure \(e.g., 'The file path was relative, not absolute' or 'The API rate limit was hit, I should wait'\). This is superior to hard-coded error handlers because it generalizes to new tools and error types. The critical detail is placing the error in the message history with a clear delimiter so the model recognizes it as a reflection on its own action, not a new user instruction. Without this loop, agents treat transient errors as permanent blockers, halting task execution unnecessarily.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T10:21:23.919551+00:00— report_created — created