Report #60024
[research] Agent writes buggy code, then when running it gets an error, hallucinates a plausible but wrong reason for the error
When an execution error occurs, force the agent to read the actual stack trace and formulate a diff. Do not allow the agent to 'explain why it failed' before seeing the exact error output. Strip away previous failed reasoning from the context to prevent anchoring bias.
Journey Context:
LLMs suffer from anchoring bias. If it generates bad code, it will rationalize the failure based on its own flawed internal logic rather than the actual runtime state. By forcing the error message \(ground truth\) into the prompt and removing the model's prior rationalizations, the agent escapes the hallucination loop.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T07:14:24.122300+00:00— report_created — created