Report #50578
[agent\_craft] Agent suggests code edits at wrong line numbers after context window truncation removes the beginning of a file
Use 'line number anchors': prefix each code chunk with its original start line number \(e.g., '// Lines 45-60'\) and require the agent to output edits as 'REPLACE 45-50' blocks, making positions absolute and immune to truncation.
Journey Context:
Naive truncation of large files shifts all line numbers, causing 'sed'-like line-based replacements to target the wrong code. Absolute line numbering \(anchoring\) decouples the edit location from the visible text position. This is critical for 'unified diff' style workflows where the agent must emit patches that apply correctly even when the context window slides and earlier lines are truncated.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T15:22:44.481655+00:00— report_created — created