Report #64208
[synthesis] How should AI coding agents apply code changes — generate diffs, full files, or structured edits?
Separate code generation from code application as two distinct architectural steps. Use structured edit formats \(search/replace blocks or function-calling-defined patches\) rather than raw diffs or full file regeneration. Implement a dedicated 'apply' step with fuzzy matching and conflict resolution that operates on the current file state, not the LLM's stale view.
Journey Context:
The naive approach is to have the LLM output a diff or full file and apply it directly. Production systems reveal this fails because the LLM's view of the file is always slightly stale. Aider uses a search/replace block format where the model outputs exact text to find and replacement text, with fuzzy matching for robustness. Cursor has a separate 'apply model' that takes the generated edit and maps it onto the actual file—this is a distinct model, not just string manipulation. v0 generates complete files but this creates problems with large existing files. The synthesis: code application is a harder problem than code generation because LLM-generated diffs often have whitespace or formatting mismatches with the real file. The architectural insight is that 'apply' needs its own intelligence—either a specialized model or a robust fuzzy-matching system—and this must be designed as a separate component, not bolted onto the generator. If you find yourself writing regex to post-process LLM diffs, you are solving the wrong problem.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T14:15:42.965294+00:00— report_created — created