OpenAI Prompt Cache Diagnostics GA 怎么读 miss 原因
2026 年 9 月 8 日 Responses API 为 GPT-5.6+ 推出 Prompt Cache Diagnostics GA:对比上次 response 的 cache 复用、miss 原因与排查建议。Agent 长 session 降本必看。

2026 年 9 月 8 日,OpenAI API Changelog 将 Prompt Cache Diagnostics 标为 GA,面向 Responses API 上 GPT-5.6 及更新支持的模型。它让你对比「相对上一次 response」的 cache 命中率、miss 原因,并按文档 troubleshooting 提高 prefix 复用,对 Agents API 长任务、Codex 类多 turn 编程 Agent 的账单直接影响 input 价。
和 Claude Code 的 /cost prompt_cache 有何异同
Anthropic 在 Claude Code 2.1.260+ 给 /cost 加了 per-session prompt-cache 行(hit ratio、misses、re-cached tokens),并修复 OAuth refresh 后 tool 重渲染导致 ~ hourly cache miss 的 bug。
OpenAI 侧 Prompt Cache Diagnostics 在 Responses API 层输出结构化 diagnostic,强调与上一 response 对比,适合 server-side Agent loop,而不是终端 UI。
两边共同原则:前缀 byte-stable 才便宜;换 system prompt、工具列表、MCP 挂载都会 invalidate。
Diagnostics 解决什么痛点
Agent harness 每 turn 重发巨大 prefix(Claude Code ~33k 见 Token 开销实测)。若 cache silently miss,你会看到「任务没变大,bill 翻倍」。
Diagnostics 典型输出维度(以 changelog 描述为准):
相对 prior response 的 cache reuse 比例
miss 原因分类(prefix 变化、TTL、模型不支持等)
跟进 troubleshooting guidance 改 prompt / tool 顺序
团队可把 diagnostic 打进 Agents API 的 observability pipeline,与 Sentry MCP 等并列,见本站 Sentry MCP 调试 思路。
实操:提高 hit rate 的四条
固定 system + tools 顺序
不要在 turn 之间增删 tool definition;MCP 动态挂载放 session 外预热。避免无意义 prefix 抖动
时间戳、随机 id 不要进 system prompt;session metadata 放 user 消息层。长任务用 compaction 而非换 session
Agents API 自带 context compaction;Claude Code 用/compact或 auto-compact,但 compaction 本身可能 rewrite prefix,看 diagnostic 是否 accept。网关勿 strip cache headers
Override Base URL 接 Cursor 或自建 proxy 时,剥离 cache 相关字段会导致假 miss。
Cursor 用户要不要关心
Cursor 内置 Agent 的 cache 行为不透明;BYOK + Override 时部分路径你能在网关 log 里看到 OpenAI/Anthropic cache 字段,但不如 Diagnostics GA 完整。
若 OpenAI 11 月后在 Cursor picker 收缩,更多团队会迁到 Agents API + 自 observability,Diagnostics 会从「高级项」变「默认项」。断供语境见 迁移清单。
与 9 月限额政策的交叉
Cache hit 不增加「周 cap 次数」,但降低 token 计费与 latency。9/14 Claude 周 cap 收紧后,OpenAI 侧仍可按 token 付费,Diagnostics 是 同样美元买更多 turn 的杠杆,见 限额总表。