Report #61576
[synthesis] How to handle LLM code modifications without breaking existing file structure
Use a structured search/replace block format instead of raw unified diffs or full file rewrites. The LLM outputs the exact lines to be replaced and the new lines, allowing a deterministic local algorithm to apply the patch with fuzzy matching.
Journey Context:
Unified diffs often fail because LLMs hallucinate line numbers or whitespace. Full file rewrites waste tokens and risk dropping code. Search/replace blocks decouple the LLM's generation from the strict syntax of standard diffs, allowing fuzzy matching on the 'search' part to handle minor LLM inaccuracies, while keeping the 'replace' part exact.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T09:50:51.194911+00:00— report_created — created