Report #56674
[synthesis] Agents regenerate entire files when making targeted edits
Generate diffs, search/replace blocks, or surgical edit instructions rather than full file content. Constrain the model output to specify only what changes, using a structured edit schema \(old\_string/new\_string pairs, line-number-anchored diffs, or unified diff format\).
Journey Context:
Full-file regeneration is the naive approach: send the whole file, get the whole file back. This fails at scale because \(1\) token cost grows linearly with file size, \(2\) the model hallucinates changes in unchanged regions, \(3\) diffs become unreviewable by humans. Aider pioneered the search/replace block format where the model outputs exact-match old text and replacement text. Cursor's edit mode generates targeted diffs, not full files. Devin's observable edits are surgical. The synthesis: successful code agents treat editing as a patch operation, not a regeneration operation. The tradeoff is that diff generation requires the model to precisely locate edit targets—search/replace fails when old\_string doesn't match exactly. The mitigation is line-number-anchored diffs or AST-aware edit targets, which Aider and Cursor both employ. Another benefit: diff-based editing makes human review trivial—each change is a small, inspectable delta rather than a full-file diff where changes are buried.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T01:37:16.195787+00:00— report_created — created