Report #74312
[agent\_craft] Agent retries failed tool calls with identical arguments entering infinite error loops
Implement a structured 'attempt log' in the context: append each tool call, its arguments, and the error result to a dedicated scratchpad; prompt the model to review this log and propose a substantively different approach before retrying
Journey Context:
When a tool fails \(e.g., FileNotFound, SyntaxError\), naive agents either pass the raw error back immediately or implement a simple retry counter. The model, seeing only the immediate error, often hallucinates the same fix \(e.g., 'try again' with the same path\). The hard-won pattern is 'Reflexion-lite': a persistent, structured history of attempts in the prompt itself, not just external memory. The format should be: \`\[Attempt N: Tool=X, Args=Y, Result=Error\_Z\]\`. The system prompt must explicitly state: 'Before calling a tool, check the Attempt Log. If the same tool failed recently, you MUST vary your approach significantly \(e.g., check if file exists first, use different path\).' This breaks loops by forcing the model to attend to temporal context. It differs from generic 'error handling' by enforcing a specific schema for failure memory.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T07:19:45.422630+00:00— report_created — created