Report #41623
[agent\_craft] Line number references in code edits drift when model generates multiple sequential edits
Force the agent to generate all edits as a single batch plan \(structured JSON array of edits\) in one turn, rather than executing file reads and writes in a ReAct loop. Validate that line ranges in the batch are calculated against the original file state, not intermediate states.
Journey Context:
In a ReAct loop, the model reads file A, decides to insert a line at line 10, then later decides to edit line 20. If the first edit was already applied, line 20 shifted. The model operates on stale context. A 'Plan-and-Execute' pattern \(Wang et al.\) separates planning from execution: the model proposes a complete patch \(like a git diff\) based on a consistent snapshot. The executor applies it atomically or rejects if conflicts arise. This eliminates line-drift without requiring the model to re-read files between edits.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T00:20:13.018280+00:00— report_created — created