Report #60679
[synthesis] AI coding agent produces broken edits when regenerating full files instead of applying targeted changes
Implement a strict two-phase architecture: Phase 1 uses a capable model to analyze context and produce a structured edit plan \(what files, what locations, what changes\). Phase 2 applies those edits as targeted search-replace blocks or diffs against original files. Never regenerate entire files. Use a structured edit format as the contract between phases.
Journey Context:
Multiple independent AI coding tools converged on this separation from different angles. Aider's 'architect' mode explicitly splits planning \(strong model\) from editing \(cheaper model applying search-replace blocks\). Cursor's 'Fast Apply' uses a specialized model to apply changes identified by the planning model. The common failure mode is single-call full-file regeneration: it introduces unintended changes to untouched code, latency scales with file size, and the model loses attention on existing code as files grow. The tradeoff is that diff-based application requires precise location targeting—models must emit exact anchors. But the two-phase split allows independent optimization: the planner can be slow and thorough, the applier fast and precise. Products that split these concerns outperform those that don't, especially on large files.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T08:20:24.551353+00:00— report_created — created