Report #15629
[agent\_craft] Agent loses track of current file state after multiple sequential edits \(Context Rot\)
Re-read the modified file from disk after N edits or before the next major logic step, rather than relying on the accumulated patch/diff history in the context window.
Journey Context:
Agents often apply patches sequentially. The context fills with diff markers, old code, and rejected attempts. The model starts hallucinating based on the old state because the attention mechanism is diluted across multiple versions of the same file. Re-reading the file \(even though it costs tokens\) resets the ground truth, preventing cascading syntax errors. Alternatives like maintaining an internal AST diff are brittle; brute-force re-reading is more reliable for LLMs.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T00:41:27.475086+00:00— report_created — created