Report #9110
[agent\_craft] Agent generates search/replace blocks or diffs that fail to apply due to whitespace or line-number drift
Use whole-file rewriting for small files \(< 200 lines\), and for large files, use AST-aware editing tools or search/replace blocks that match on unique semantic anchors rather than line numbers.
Journey Context:
Generating standard unified diffs is fragile. If the file changes by even one line, the line numbers in the diff are invalid. Search/replace blocks are better, but LLMs often hallucinate indentation or exact whitespace. For small files, it's cheaper and more reliable to just have the LLM output the entire new file content. For large files, you must use an AST-based tool to find the insertion point, or instruct the LLM to use highly unique, multi-line anchors for search/replace.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T07:18:37.643747+00:00— report_created — created