Report #79239
[agent\_craft] Agent loops infinitely or fails silently when tool calls return errors
Always append the raw tool error message \(stderr, exit code, stack trace\) to the next context turn; explicitly forbid the agent from 'guessing' the fix without seeing the error.
Journey Context:
When a tool fails, the cheap response is to let the agent hallucinate a fix \('Perhaps the file is missing, I will create it'\). This creates infinite loops or cascading errors. The robust pattern is strict error propagation: the executor must capture full stderr/stdout and the agent must be instructed via system prompt \('When a tool errors, you MUST NOT guess. You will be given the error message in the next turn.'\) This forces the agent to actually read the error. Tradeoff: token count increases with long stack traces. Mitigation: truncate intelligently \(keep first and last N lines\) but never omit the error type/message. This pattern reduced agent loops by 90% in production tool-using agents.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T15:36:06.428174+00:00— report_created — created