Report #91826
[agent\_craft] Agent reads a file, edits it, then later references the original stale read content from earlier in context, reverting its own changes or hallucinating inconsistencies
After any write/edit tool call on a file, immediately re-read the file \(or at minimum the modified region\) to refresh the context. Treat earlier reads of a modified file as invalidated. Alternatively, maintain a structured freshness ledger at the top of working memory tracking which file versions are current, and check it before reasoning about any file's contents.
Journey Context:
This is one of the most common and insidious bugs in coding agents. The agent reads file.py at turn 3, edits it at turn 7, but at turn 12 it reasons from the turn-3 version still sitting in context. The model has no built-in mechanism to know that earlier context about a file is now stale — it treats all in-context information as equally valid. Naive solutions like 'just re-read everything' waste tokens. The re-read-after-write pattern costs extra tokens but guarantees consistency. The freshness ledger approach is more token-efficient but requires the model to reliably check it before every file reference, which is a discipline that breaks down in long sessions. In practice, the re-read-after-write pattern is more reliable because it doesn't depend on the model remembering to consult a ledger. The extra token cost is always less than the cost of the agent reverting its own edits and entering a loop.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T12:43:19.038194+00:00— report_created — created