feat: cache diagnostics v1 — /cache-miss-report, doctor --cache, prefix hash evidence | 缓存诊断 v1#2188
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e0d128dff8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
e0d128d to
f520f05
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6426b6823f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6212f5e0ea
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Before I can review this series (#2188–#2192) I need the branch structure fixed — right now it's not reviewable as five PRs. The problem: all five PRs ( Please restructure into independent, single-feature PRs (preferred for fork PRs):
Each branched fresh from If you'd rather keep them stacked, that requires pushing the intermediate branches to this upstream repo and pointing each PR's base at the previous branch — but for a fork, independent branches off main is simpler. Let me know once they're split and I'll dig into each. |
6212f5e to
0256e1d
Compare
|
Updated the PR series as requested. The five fork branches are now independent branches off Branch heads now are:
I rechecked the GitHub PR file lists after pushing: each PR now shows only its own feature scope rather than the old 33-file cumulative diff. Verification run locally:
Root cause was branch topology: the branch names were separate, but all five remote heads pointed at the same stacked tip. I rebuilt and force-updated the fork heads with |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0256e1df82
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
esengine
left a comment
There was a problem hiding this comment.
Valuable feature — cache observability is squarely on-mission for a cache-first agent, and the reporting side is clean: doctor --cache / runCacheDoctorChecks (dynamic-prompt, MCP order, skills/memory, hooks, evidence) and /cache-miss-report read saved-session cacheDiagnostics evidence — all read-only, no behavior change. The session-meta cacheDiagnostics? field is backward-compatible (optional, absent on old sessions). Good.
One thing to confirm before I merge, since it's on the hot path: the loop now calls this.prefix.diagnosticHashes() before every API call. The prefix is immutable (only changes on addTool/removeTool/replaceSystem), so please confirm prefixDiagnosticHashes is memoized — computed once and invalidated on those mutations, like the existing _fingerprintCache — rather than re-hashing the full system+tools+few-shots prefix every turn. For a large prefix (30-50 MCP tools), re-hashing per turn would be exactly the kind of per-turn cost this product otherwise works hard to avoid. If it already caches off the same invalidation signal as the fingerprint, this is good to merge; if not, that's the one change I'd want. Could you point me at the diagnosticHashes implementation / confirm the caching?
|
Addressed the diagnostic hash memoization concern from review 4386489854 in e1e93e3. Implementation:
Regression coverage:
Verification:
|
…ics-v1 # Conflicts: # tests/ui-slash-suggestions.test.tsx
|
Resolved the branch conflicts by merging current Conflict handled:
Verification:
GitHub now reports |
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
esengine
left a comment
There was a problem hiding this comment.
Re-reviewed — the hot-path concern is resolved. diagnosticHashes is now memoized via _diagnosticHashesCache = new WeakMap<readonly ToolSpec[], PrefixDiagnosticHashes>(), keyed by the immutable tool snapshot and invalidated alongside the other prefix caches. Since this.tools() returns the stable frozen snapshot (#2162), the WeakMap hits the same key until a tool mutation, so the prefix is hashed once per prefix-state rather than every turn — no per-turn re-hash of the full system+tools. Combined with the read-only reporting (doctor --cache / cache-miss-report) and the backward-compatible session-meta field, this is good. CLEAN + CI green. Merging.
Summary
This PR introduces the first phase of cache diagnostics for Reasonix, providing real-time visibility into prompt cache performance. A new evidence layer captures per-turn prefix hashes and infers miss reasons, enabling developers and operators to understand why cache misses occur.
Key deliverables:
/cache-miss-reportslash command (aliases:/cache-report,/cache) for in-session cache diagnosticsreasonix doctor --cacheandreasonix doctor-cachefor cache-stability health checksSessionStatsfor live reporting within the dashboardcacheDiagnosticsfield概述
此PR为Reasonix引入了缓存诊断的第一阶段,提供对提示缓存性能的实时可见性。一个新的证据层捕获每轮的前缀哈希并推断未命中原因,使开发者和运维人员能够理解缓存未命中的根本原因。
主要交付内容:
/cache-miss-report斜杠命令(别名:/cache-report、/cache),用于会话内缓存诊断reasonix doctor --cache和reasonix doctor-cache,用于缓存稳定性健康检查SessionStats中,支持仪表盘内的实时报告cacheDiagnostics字段实现向后兼容的会话元数据Changes
src/telemetry/cache-diagnostics.ts— evidence layer for per-turn prefix hashes and miss reason inferencesrc/telemetry/stats.ts— store per-turn diagnostics in SessionStatssrc/cli/commands/doctor.ts— add cache-stability check modesrc/cli/index.ts— registerdoctor --cacheanddoctor-cacheCLI commandssrc/cli/ui/slash/commands.ts— register/cache-miss-reportslash commandsrc/cli/ui/slash/handlers/observability.ts— handle/cache-miss-reporthandlersrc/loop.ts— integrate cache diagnostics into the agent loopsrc/loop/types.ts— add CacheDiagnosticEntry typesrc/memory/runtime.ts— track cache diagnostics in runtime statesrc/memory/session.ts— backward-compatible cacheDiagnostics fieldsrc/transcript/log.ts— log cache diagnostic eventssrc/i18n/EN.ts,src/i18n/de.ts,src/i18n/zh-CN.ts— i18n keys.gitignore— add agent.md, bugs.md, todo.mdtests/cache-diagnostics.test.ts— comprehensive cache diagnostic teststests/doctor-json.test.ts,tests/slash.test.ts,tests/ui-slash-suggestions.test.tsx变更
src/telemetry/cache-diagnostics.ts— 每轮前缀哈希和未命中原因推断的证据层src/telemetry/stats.ts— 在SessionStats中存储每轮诊断数据src/cli/commands/doctor.ts— 添加缓存稳定性检查模式src/cli/index.ts— 注册doctor --cache和doctor-cacheCLI命令src/cli/ui/slash/commands.ts— 注册/cache-miss-report斜杠命令src/cli/ui/slash/handlers/observability.ts— 处理/cache-miss-report处理器src/loop.ts— 将缓存诊断集成到代理循环中src/loop/types.ts— 添加CacheDiagnosticEntry类型src/memory/runtime.ts— 在运行时状态中跟踪缓存诊断src/memory/session.ts— 向后兼容的cacheDiagnostics字段src/transcript/log.ts— 记录缓存诊断事件src/i18n/EN.ts,src/i18n/de.ts,src/i18n/zh-CN.ts— 国际化键值.gitignore— 添加agent.md、bugs.md、todo.mdtests/cache-diagnostics.test.ts— 全面的缓存诊断测试tests/doctor-json.test.ts,tests/slash.test.ts,tests/ui-slash-suggestions.test.tsxTest Plan
/cache-miss-reportslash command works interactively in a dev sessionreasonix doctor --cacheand verify JSON and text output formatsreasonix doctor-cacheand confirm it defaults to cache-only modecacheDiagnosticsload without errors测试
/cache-miss-report斜杠命令reasonix doctor --cache并验证JSON和文本输出格式reasonix doctor-cache并确认其默认仅运行缓存模式cacheDiagnostics的会话可以无错误加载Verification