Report #89898
[synthesis] AI agent regenerates entire files causing merge conflicts, losing unrelated changes, and bloating diffs
Never have the LLM write complete files. Implement targeted diff/patch application. Choose your diff format based on edit granularity: search/replace blocks for robustness across model outputs, specialized apply models for speed, inline decorations for seamless UX.
Journey Context:
The naive approach — ask the LLM to output the full modified file — fails in practice because it loses any changes the user made since the context was captured, produces massive diffs that are hard to review, and wastes tokens. Every successful product converges on diff-based editing, but the diff format is a critical architectural fork. Aider uses search/replace blocks: the model outputs the lines to find and the replacement lines. This is robust to model variation but verbose and can fail on fuzzy matches. Cursor uses a specialized 'apply' model that computes minimal diffs — fast but requires a second model inference. Copilot uses inline decorations — seamless UX but limited to small, localized changes. The synthesis: the diff format determines the agent's edit granularity and reliability profile. Search/replace is the most reliable general-purpose format; specialized apply models are faster but add architectural complexity and a second model dependency.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T09:29:15.101469+00:00— report_created — created