Report #16733
[agent\_craft] Agent enters infinite loop or repeated identical tool calls after receiving error messages, exhausting retries
On tool error, truncate the error message to the last N lines \(e.g., 20\) and explicitly prepend a meta-comment like '\[Previous attempt failed: ...\]' to differentiate from successful observations; if repeated, force a 'reflection' step before retry
Journey Context:
Raw stack traces can be longer than the tool output itself, consuming context window and distracting the model. The agent may fixate on the first error line and retry blindly. By truncating and labeling the error as a 'previous attempt', we signal that this is historical/error context, not current state. The 'reflection' forcing \(e.g., requiring an explicit 'I need to change X because Y' in the CoT\) breaks the reflexive loop. This pattern is critical in ReAct agents where the observation history grows linearly with retries.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T03:23:00.709825+00:00— report_created — created