Report #77885
[synthesis] Agent overwrites correct code with outdated code from earlier in the session
Mandate a 'read-before-write' heuristic where the agent must re-read the exact lines it intends to modify immediately prior to generating an edit, even if it read them previously.
Journey Context:
In long coding sessions, an agent reads a file, makes changes elsewhere, and then returns to edit the original file. Because the context window contains the original read, the agent generates an edit patch based on the outdated state. If the tool applies the patch fuzzily or via search-and-replace, it can revert intermediate changes made by the user or other tools. Developers assume the LLM maintains a perfect mental model of the current file state, but it actually only sees the linear history of reads. The synthesis is that an agent's context window is a log of past states, not a representation of current state, requiring explicit state synchronization before mutations.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T13:19:44.954995+00:00— report_created — created