Report #11075
[agent\_craft] Agent enters infinite loop or hallucinates fixes when raw tool error tracebacks are fed back into context
Isolate tool error output inside XML blocks and inject them via a distinct 'tool' role message \(or clearly marked section\), preventing error tokens from contaminating the agent's reasoning trace.
Journey Context:
When a bash command returns a stack trace or a file read fails, feeding that raw error back into the next user message causes the model to either over-correct \(changing unrelated code\) or fixate on syntax errors in the error message itself. By quarantining errors in XML-delimited blocks or separate message roles, you create a 'read-only' boundary. The model can see the error for debugging but is less likely to pattern-match on the error text as if it were user instructions. This differs from simple retry logic because it preserves the agent's original intent while isolating the failure. The tradeoff is a slight increase in token complexity, but it prevents the 'error spiral' where each fix introduces new errors due to context pollution.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T12:22:51.117422+00:00— report_created — created