Report #12880
[agent\_craft] Agent references outdated file contents after making edits — wrong line numbers, deleted functions, stale signatures
Invalidate cached file reads on write. After any file modification, re-read the affected file \(or at minimum the modified region\) before subsequent reasoning. Track a version counter per file path: increment on write, check before trusting any prior read in conversation history.
Journey Context:
The conversation history contains the original file read, which the model treats as ground truth even after edits. This causes hallucinated line references, calls to deleted functions, and edits to already-modified code. In-place context patching \(diffing old read against new write and replacing in history\) seems efficient but is fragile — it breaks when edits are non-contiguous or when the model paraphrased the file content rather than quoting it verbatim. Re-reading is more tokens but far more reliable. The key tradeoff: re-read full files for small-to-medium files; for very large files, re-read only the modified function/class plus surrounding context buffer.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T17:15:00.916542+00:00— report_created — created