Repository navigation
v2.4.3
Codex App Transfer v2.4.3
中文
第三方 prompt cache 命中塌方修复 + Codex 内逐轮命中率趋势折线
修复第三方上游(GLM / WorkBuddy 等 OpenAI Chat 兼容网关)长会话 prompt cache 命中率从约 95% 塌到约 33% 的问题:每轮把大量本可命中的内容按未缓存重算,既慢又多耗额度。同时给 Codex 顶栏用量面板加了逐轮命中率趋势可视化。
- 根因与修复:tool 输出折叠每轮给同一条历史工具输出重新生成随机
artifact_id,折叠进历史的消息跨轮字节不稳定,打断上游按 messages 前缀做的缓存。改为按内容确定性生成(call_id+ kind + 原文 SHA-256)+ 落盘 UPSERT 幂等:同一输出跨轮 / 跨进程恒得同一 id、同内容不再每轮插新行(顺带治tool_artifacts.db膨胀),折叠消息跨轮字节稳定,命中率恢复到接近原生。原生 ChatGPT 走 Responses 透传不受影响。 - 命中率趋势:用量面板底部
缓存命中 X%可点,正下方弹固定宽度浮层显示当前对话逐轮命中率折线(左轴刻度 + 折线);轮数变化只改折线疏密、宽度恒定,点外部 / Esc / 滚动即关。 - 稳健性:关面板 / 升级重装注入脚本时一并回收浮层监听与残留节点,不在 Codex 页面泄漏。
验证:adapters / usage_tracker / 注入器单测全绿,fmt / clippy 干净,3 个审查 agent 复核。
English
Third-party prompt cache hit-rate collapse fix + per-turn hit-rate trend line in Codex
Fixes a bug where the prompt cache hit rate on third-party upstreams (GLM / WorkBuddy and other OpenAI-Chat-compatible gateways) collapsed from ~95% to ~33% in long conversations, re-billing large amounts of cacheable content as uncached (slower and costlier). Also adds a per-turn hit-rate trend to the Codex usage panel.
- Root cause and fix: tool-output folding regenerated a random
artifact_idfor the same historical output every turn, making the folded history message byte-unstable and breaking the upstream prefix-based cache. It is now derived deterministically from content (call_id+ kind + SHA-256 of the raw output) with an idempotent UPSERT on persistence: the same output always maps to the same id across turns/processes and identical content no longer inserts a new row each turn (also curbingtool_artifacts.dbgrowth). Folded messages are byte-stable across turns and hit rates recover to near-native. Native ChatGPT (Responses passthrough) is unaffected. - Hit-rate trend: the
Cache hit X%entry at the bottom of the usage panel is now clickable and opens a fixed-width popover below it with the conversation's per-turn hit-rate line (left-axis ticks + polyline); more turns only make the line denser while width stays constant, closing on outside-click / Esc / scroll. - Robustness: turning the panel off or reinstalling the injection on upgrade now cleans up the popover's global listeners and leftover nodes so nothing leaks into the Codex page; cumulative total and trend series are read in a single disk pass, adding no per-tick cost.
Verification: adapters / usage_tracker / injector unit tests all green, fmt / clippy clean, reviewed by 3 audit agents.