Report #12590
[agent\_craft] Line-number-based file editing fails when target code shifts or agent hallucinates line numbers
Use search/replace blocks anchored by unique string literals \(exact text matching\) rather than line numbers, with fuzzy matching for whitespace tolerance
Journey Context:
Line numbers are fragile; inserting a single line above the target invalidates the entire edit plan. Agents frequently hallucinate line numbers anyway. Search/replace with unique string anchors \(like git's diff format or aider's edit blocks\) is robust to file shifts as long as the target text remains unique. The tradeoff is that the search string must exactly match \(or have configurable whitespace normalization\), but this is far more reliable than line offsets.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T16:21:40.084627+00:00— report_created — created