Report #23893
[agent\_craft] Agent looping on same failed bash command because error message not reflected in context
Implement a 'Reflect-Retry' checkpoint: after any tool error, append a structured reflection block to the context containing \(1\) the exact stderr, \(2\) hypothesis of root cause, \(3\) corrected command parameters. Do not allow a raw retry of the identical arguments.
Journey Context:
Naive agents see 'file not found' and simply rerun \`cat file.txt\` hoping for a different result, burning tokens and time. The fix is the Reflexion pattern: force the agent to explicitly model its mistake. The trade-off is context length—each reflection adds tokens—but it prevents infinite loops. Crucially, the reflection must be distinct from the observation; putting it in the 'assistant' role message \(the agent's monologue\) works better than appending to 'user' messages, as it reinforces the agent's own reasoning trace.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T18:30:34.825405+00:00— report_created — created