Track per-session file-read history; return a file_unchanged placeholder when a file is read again with identical stat metadata. Cuts duplicate context bloat and acts as a correctness guard when a tool re-reads what the model has already seen.
Upstream PR
Why
Performance + correctness. Our turns regularly re-read the same file inside one conversation; this skips re-emitting identical content. Also reduces the chance the model hallucinates that a file changed when it didn't.
Scope / effort
Medium. Not free — needs a decision on how it interacts with our context-compaction path.
- New file:
fileReadCache.ts (~188 lines)
- Modifies:
config.ts (cache getter + fileReadCacheDisabled flag), read-file.ts, edit.ts, write-file.ts. We have local edits in read-file.ts and edit.ts.
- Compaction interaction: cache must be cleared on session start; when compaction summarizes prior content, the cache must invalidate or the model will see "file_unchanged" referring to content no longer in its context window.
- Upstream resets the cache in
config.startNewSession() — verify our compaction calls into the same lifecycle.
Prerequisites
Decide: ship with fileReadCacheDisabled: true default (safe; gather data) vs ship enabled (perf win, but verify compaction path).
Links
Track per-session file-read history; return a
file_unchangedplaceholder when a file is read again with identical stat metadata. Cuts duplicate context bloat and acts as a correctness guard when a tool re-reads what the model has already seen.Upstream PR
feat(core): add FileReadCache and short-circuit unchanged ReadsWhy
Performance + correctness. Our turns regularly re-read the same file inside one conversation; this skips re-emitting identical content. Also reduces the chance the model hallucinates that a file changed when it didn't.
Scope / effort
Medium. Not free — needs a decision on how it interacts with our context-compaction path.
fileReadCache.ts(~188 lines)config.ts(cache getter +fileReadCacheDisabledflag),read-file.ts,edit.ts,write-file.ts. We have local edits inread-file.tsandedit.ts.config.startNewSession()— verify our compaction calls into the same lifecycle.Prerequisites
Decide: ship with
fileReadCacheDisabled: truedefault (safe; gather data) vs ship enabled (perf win, but verify compaction path).Links