Skip to content

upstream port: FileReadCache + short-circuit unchanged reads (#3717) #186

@mabry1985

Description

@mabry1985

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestupstream-portBackport from QwenLM/qwen-code upstream

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions