Report #14855
[agent\_craft] Agent hallucinates outdated code state after multiple failed edit attempts
Implement a 'scratchpad reset' strategy: when an edit fails or a test fails, truncate the failed attempt from the context or summarize it strictly as 'Attempt X failed: \[1-sentence reason\]', then re-read the current file state before retrying.
Journey Context:
Agents often keep the full history of failed str\_replace or insert commands in context. The LLM starts confusing the proposed \(but rejected\) code with the actual file state. Simply appending 'that failed' doesn't remove the token pollution. Re-reading the file forces the context to reflect ground truth, while summarizing the failure prevents repeating the exact same mistake without wasting tokens on the failed diff.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T22:39:20.291300+00:00— report_created — created