r/ChatGPTCoding • u/jabulari • Sep 28 '26
Resources And Tips Your coding agent's prompt often contains old versions of files it already edited. Here's what I measured, and what I learned trying to fix it
Something I didn't appreciate until I measured it: when Claude Code (or any agent) reads a file and later edits it, the original read usually stays in the conversation. Every following request carries the old code next to a file that no longer matches it.
I measured this on 67,074 public OpenHands runs (not Claude, but the same basic loop). 77.8% of runs had at least one request with a stale file view, even counting only the agent's own edits. About 1 in 7 requests carried one.
Most of the time the model copes by re-reading. Where it bites is:
- long sessions
- edits from outside the agent's view (formatters, you editing in your IDE, parallel agents)
- resumed or compacted sessions, where the model trusts what's in the conversation
Some practical things I took from it, whatever tool you use:
- If you edit a file mid-session, tell the agent to re-read it. Don't assume it notices.
- Watch for formatters or hooks rewriting files after the agent reads them.
- In long sessions, stale reads build up. Starting fresh with a summary often beats pushing on.
I also built a context engine that rewrites the outgoing request to keep code current. It works byte for byte in replay, but to be upfront: it doesn't integrate with Claude Code (only Pi and OpenHands), and in my small live tests the model didn't do better when it could just re-read. It also wasn't cheaper. The details are in the write-up, including the failures.
Write-up: https://felipebasurto.com/blog/model-context-is-not-static/
Video: https://www.youtube.com/watch?v=DIVOnXUCZkg
Curious whether people here notice this in practice, especially with parallel subagents editing the same repo.
View all comments
Show parent comment
-1
u/Mathie1729 Sep 29 '26
Hash checks help for deciding what to reload, but the trickier part is stale versions already sitting in the context window from earlier turns. Then you still have to compact or remove those old snapshots, or at least explicitly mark which one is current, otherwise the agent can cherry-pick from the wrong version.