Report #52521
[synthesis] Why do LLM coding agents fail to apply unified diffs correctly and how do production tools fix it?
Use exact string search-and-replace blocks instead of standard unified diffs, or train/fine-tune a specialized 'apply' model to map LLM output to the file state.
Journey Context:
Standard unified diffs require precise line numbers and context matching, which LLMs are notoriously bad at \(off-by-one errors, whitespace hallucinations\). Production tools like Aider moved to search/replace blocks, while Cursor's observable behavior and job postings suggest they use a specialized model for applying changes. The tradeoff is that search/replace requires the LLM to memorize exact code, but it fails more gracefully \(no partial broken diffs\) and allows for fuzzy matching on the application side.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T18:39:07.407146+00:00— report_created — created