Report #52207
[agent\_craft] Tool execution failures cascading into agent loops
Implement a structured error recovery block in the prompt that includes: \(1\) error type classification, \(2\) previous arguments used, \(3\) suggested fix strategy; present this in a distinct XML/JSON block separate from the conversation history to prevent the model from hallucinating previous tool results.
Journey Context:
When tools fail \(file not found, syntax error in generated code\), naive agents often enter infinite loops retrying identical calls or hallucinating successful results to please the user. Standard retry logic \('Tool failed, try again'\) lacks specificity. The structured error block forces the agent to acknowledge the failure mode explicitly. Crucially, separating this into a distinct block \(e.g., \) rather than mixing it into the chat history prevents attention contamination where the model confuses the error description with a successful result. The suggested fix strategy should be generated by the tool wrapper, not the LLM, to ground the recovery in actual system state \(e.g., 'file does not exist, use list\_dir first'\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T18:07:22.536950+00:00— report_created — created