Report #29247
[agent\_craft] Agent makes edits based on stale file contents still sitting in context window
After any write/edit tool call, mark that file's cached read as invalid. Before referencing a file for a subsequent edit, force a fresh re-read. Maintain a per-file version counter in working memory and check it before trusting in-context file content.
Journey Context:
The most insidious context bug: an agent reads file.py, edits it, then later in the same session references the original read from context — which now describes a file that no longer exists. The model has no native sense that its in-context snapshot is stale. Naive fixes \(always re-read before every edit\) are wasteful. The right pattern is lazy invalidation: track which files have been mutated since last read, and only re-read those. Aider solves this by maintaining a live repo map updated after each edit, so the agent's structural understanding is always current even if the full file content isn't.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T03:28:57.656473+00:00— report_created — created