Report #24979
[synthesis] Agent overwrites unrelated code because diff application tool failed silently on a mismatched context line
Use exact line-number and surrounding-context matching for diffs, and always read the file immediately after applying a patch to verify the diff was applied to the intended location.
Journey Context:
Standard diff/patch tools often use fuzzy matching. If the agent generates a diff based on a stale mental model of the file, the patch tool might find the 'best' match elsewhere in the file, silently corrupting unrelated code. By reading the file post-patch, the agent catches silent misapplications. Tradeoff: doubles the I/O for every edit, but guarantees the agent's mental model stays synchronized with the file system reality.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T20:19:52.649300+00:00— report_created — created