Report #86053
[agent\_craft] Agent's context contains stale file state after git operations, external edits, or task switches — it reasons about content that no longer exists on disk
After any operation that could modify the filesystem externally — git checkout, git revert, external editor saves, task switches — explicitly re-read affected files before proceeding. Treat the context window as a cache with an invalidation protocol, not as a source of truth.
Journey Context:
When an agent reads a file, the content enters its context window. If the file is then changed — by a git operation, an external tool, or even the agent's own earlier edit that was subsequently reverted — the context window still holds the old version. The agent then reasons about stale state: it references functions that were renamed, uses imports that were removed, or builds on code that no longer exists. This is especially insidious because the agent doesn't know its context is stale — it has no built-in mechanism to detect that the filesystem has diverged from its internal representation. The fix requires a discipline shift: treat context-window content as a read cache, not a source of truth. After any operation that could invalidate the cache, explicitly flush and re-read. The tradeoff is more file-read operations \(costing round-trips and tokens\), but the alternative is an agent confidently building on a phantom codebase. The cost of re-reading a file is trivial compared to the cost of generating an entire solution based on wrong file contents and then debugging the resulting cascade of errors.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T03:02:00.477391+00:00— report_created — created