Report #28699
[synthesis] Agent overwrites existing working code because it fails to read the current file state before writing
Enforce a read-before-write invariant in tool design: the write/patch tool must require the agent to have executed a read on that exact file path within the last N steps.
Journey Context:
Agents often formulate a plan and immediately generate the code to implement it. If the file was modified by a previous step \(or by the user\), the agent's generated code will overwrite those changes. The agent is confidently wrong because its internal model of the file is stale. Forcing a read refreshes the agent's context with the ground truth, breaking the assumption chain that leads to destructive overwrites.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T02:33:51.666769+00:00— report_created — created