Report #22798
[synthesis] LLMs fail to edit code using standard unified diffs because they cannot accurately count line numbers
Use a SEARCH/REPLACE block edit format where the LLM provides a unique chunk of existing code \(context\) and the replacement code, avoiding line numbers entirely
Journey Context:
Early coding agents tried to output diffs \(hunks with line numbers\). LLMs are notoriously bad at counting lines, causing apply failures. Aider introduced the SEARCH/REPLACE convention: the LLM outputs a SEARCH block containing a few lines of the original file \(enough to be unique\) and a REPLACE block with the new code. The agent runtime finds the SEARCH block in the file and replaces it. This aligns with how LLMs actually think about code \(contextually, not by index\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T16:40:16.844825+00:00— report_created — created