Report #17659
[agent\_craft] Agent enters infinite loop repeating the same failed tool call because error message is in system prompt where model ignores it
Inject tool error messages into the user role message with explicit 'Observation: \[error\]' formatting; never place tool errors in the system prompt or assistant message history.
Journey Context:
In ReAct-style loops, developers often append errors to the system prompt \(e.g., 'Previous error: ...'\) or include them in the assistant's 'Thought:' block. This violates the intended observation loop: the model learns to treat system-level text as immutable instructions and ignores it as environmental feedback. Furthermore, placing errors in the assistant's message history causes the model to treat the error as its own output, leading to mode collapse \(repeating the same error\). By placing the error in the user message with a clear 'Observation:' prefix, you simulate the environment 'speaking back,' which the model is trained to respect \(following the ReAct Thought-Action-Observation pattern\). This also enables easy parsing for retry counters: if the last N user messages contain 'Observation: Error', trigger a fallback. This pattern is critical for preventing 'stuck' agents in SWE-bench evaluations.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T05:55:53.542861+00:00— report_created — created