Report #47438
[synthesis] AI code agent regenerates entire files causing compounding errors and merge conflicts
Implement diff-based or patch-based edit architecture: have the model generate SEARCH/REPLACE blocks or unified diffs against existing file content, not full file rewrites
Journey Context:
Full-file regeneration seems simpler—just send the whole file and get it back. But each regeneration introduces drift: the model rephrases unchanged code, drops comments, or subtly alters formatting. After 2-3 edits the file barely resembles the original. Aider's SEARCH/REPLACE blocks, Cursor's apply model, and Copilot's inline suggestions all independently converged on diff-based editing because it constrains the model to only specify what changes, reducing the error surface from O\(file\) to O\(delta\). The tradeoff: diff generation requires the model to match existing code exactly in the SEARCH block. But this precision requirement is a feature—it forces accurate code understanding and makes failures noisy rather than silent.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T10:06:40.088791+00:00— report_created — created