Repository navigation
feat(core): add FileReadCache and short-circuit unchanged Reads #3717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
ae045d9
fdebb89
a97e556
0471799
d36f8b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,6 +62,7 @@ import { SubagentManager } from '../subagents/subagent-manager.js'; | |
| import type { SubagentConfig } from '../subagents/types.js'; | ||
| import { BackgroundTaskRegistry } from '../agents/background-tasks.js'; | ||
| import { BackgroundShellRegistry } from '../services/backgroundShellRegistry.js'; | ||
| import { FileReadCache } from '../services/fileReadCache.js'; | ||
| import { | ||
| DEFAULT_OTLP_ENDPOINT, | ||
| DEFAULT_TELEMETRY_TARGET, | ||
|
|
@@ -365,6 +366,14 @@ export interface ConfigParameters { | |
| telemetry?: TelemetrySettings; | ||
| gitCoAuthor?: boolean; | ||
| usageStatisticsEnabled?: boolean; | ||
| /** | ||
| * If true, disables the per-session FileReadCache short-circuit | ||
| * (file_unchanged placeholder). Useful for sessions that may undergo | ||
| * context compaction or transcript transformation, where the model | ||
| * cannot reliably retrieve a previously-emitted full file content | ||
| * from prior tool results. Defaults to false (cache active). | ||
| */ | ||
| fileReadCacheDisabled?: boolean; | ||
| fileFiltering?: { | ||
| respectGitIgnore?: boolean; | ||
| respectQwenIgnore?: boolean; | ||
|
|
@@ -547,6 +556,7 @@ export class Config { | |
| private subagentManager!: SubagentManager; | ||
| private readonly backgroundTaskRegistry = new BackgroundTaskRegistry(); | ||
| private readonly backgroundShellRegistry = new BackgroundShellRegistry(); | ||
| private readonly fileReadCache = new FileReadCache(); | ||
| private extensionManager!: ExtensionManager; | ||
| private skillManager: SkillManager | null = null; | ||
| private permissionManager: PermissionManager | null = null; | ||
|
|
@@ -601,6 +611,7 @@ export class Config { | |
| private readonly telemetrySettings: TelemetrySettings; | ||
| private readonly gitCoAuthor: GitCoAuthorSettings; | ||
| private readonly usageStatisticsEnabled: boolean; | ||
| private readonly fileReadCacheDisabled: boolean; | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion] Result: the documented safety net is theoretical. An operator who needs to disable the cache during an incident has to ship a config change + restart, not flip a runtime knob. Fix: drop — claude-opus-4-7 via Qwen Code /review (test run)
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Acknowledged but not fixed in this PR. The two failure modes the JSDoc and placeholder advertise are now handled differently:
What's left is the genuine "incident response" use case — an oncall wanting to disable the cache live without redeploying. That's real but lower-priority. Adding it cleanly requires dropping I'd rather defer to a follow-up once we have hit-rate data telling us whether the live disable is actually needed. Happy to file a tracker issue. If you'd prefer to land this PR with the runtime knob already wired in, say the word and I'll add the cli binding before merge. 中文版本承认问题,但本 PR 不修。 JSDoc 和 placeholder 列的两个失效场景现在分别有自动化处理:
剩下的是"事故响应"场景——oncall 想运行时关闭 cache 不重启。这是真需求但优先级较低。加进来要 drop readonly + 加 倾向先合本 PR,等真实 hit-rate 数据证明运行时开关有需求时再做 follow-up。可以开 tracker issue。如果你坚持本 PR 要带运行时开关,告诉我我就先加 cli 绑定再 merge。 |
||
| private geminiClient!: GeminiClient; | ||
| private baseLlmClient!: BaseLlmClient; | ||
| private cronScheduler: CronScheduler | null = null; | ||
|
|
@@ -752,6 +763,7 @@ export class Config { | |
| email: 'qwen-coder@alibabacloud.com', | ||
| }; | ||
| this.usageStatisticsEnabled = params.usageStatisticsEnabled ?? true; | ||
| this.fileReadCacheDisabled = params.fileReadCacheDisabled ?? false; | ||
| this.outputLanguageFilePath = params.outputLanguageFilePath; | ||
|
|
||
| this.fileFiltering = { | ||
|
|
@@ -2496,6 +2508,28 @@ export class Config { | |
| return this.backgroundShellRegistry; | ||
| } | ||
|
|
||
| /** | ||
| * Session-scoped cache that tracks Read / Edit / WriteFile operations | ||
| * on files. One instance per Config, which means each subagent that | ||
| * creates its own Config inherently starts with an empty cache. | ||
| */ | ||
| getFileReadCache(): FileReadCache { | ||
| return this.fileReadCache; | ||
| } | ||
|
|
||
| /** | ||
| * When true, ReadFile / Edit / WriteFile must bypass the session | ||
| * FileReadCache entirely and behave as if it did not exist (no | ||
| * `file_unchanged` placeholder, no future prior-read enforcement). | ||
| * Intended as an escape hatch for sessions where the cache's "model | ||
| * has already seen this content earlier in the conversation" | ||
| * assumption is unreliable — e.g. after context compaction or | ||
| * transcript transformation. | ||
| */ | ||
| getFileReadCacheDisabled(): boolean { | ||
| return this.fileReadCacheDisabled; | ||
| } | ||
|
|
||
| /** | ||
| * Whether interactive permission prompts should be auto-denied. | ||
| * True for background agents that have no UI to show prompts. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.