Report #92649
[agent\_craft] Agent reasons from stale file contents after it modified the file itself
After any file modification \(write, edit, patch\), immediately re-read the modified file or at minimum the modified region. Never trust the pre-modification version still in context. Treat file edits as implicit invalidation of all prior reads of that file.
Journey Context:
This is context rot in its purest form: the agent reads a file at turn 5, edits it at turn 10, but the context still contains the turn-5 version. The agent then reasons based on the old content—referencing line numbers that shifted, functions that were renamed, or logic that was changed. This leads to cascading errors where the agent builds an increasingly wrong mental model. The fix is simple but requires discipline: every edit invalidates prior reads. Re-reading costs a tool call and some context, but it is far cheaper than the compounding errors from stale assumptions. Some agent architectures like Aider implement this by maintaining a repo map that tracks which files have been modified and need refreshing, but most frameworks leave it to the agent's own discipline, which is unreliable.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T14:05:56.841911+00:00— report_created — created