Repository navigation
Description
⚠️ 严重警告:升级 2026.6.1 后 Prompt Cache 失效,一小时烧掉 ~$6
环境
- 升级路径: 2026.5.7 → 2026.5.28 → 2026.6.1
- 模型: DeepSeek V4 Flash (
deepseek/deepseek-v4-flash) - 部署: 容器环境 (PRoot/Android)
- API 方式:
openai-completions
问题描述
从 2026.5.7 升级到 2026.6.1 后,DeepSeek 的 Prompt Cache 完全失效。
关键指标
- 缓存命中率从 50%+ 暴跌到 3-21%(OpenClaw 本地估算,实际 DeepSeek 返回 0 缓存命中)
- 24小时内累计 2500万+ 次缓存未命中
- 一小时烧掉 ~$6 USD(约 ¥40+ RMB),其中绝大部分是调试/摸索阶段浪费的
- DeepSeek API 从未返回
prompt_tokens_details.cached_tokens字段,说明服务端根本不认缓存 key
根因分析
① 缺少 supportsPromptCacheKey: true
2026.6.1 引入了 "boundary-aware" 缓存系统。文档明确说明:
"OpenAI-compatible Completions providers receive
prompt_cache_keyonly when their model config explicitly setscompat.supportsPromptCacheKey: true."
但对于旧版本升级上来的用户,这个字段不会自动补入 config,需要手动添加。全新安装的用户可能通过 wizard 自动配置好了,但升级用户直接被坑。
② 修复后仍然无效
即使通过 openclaw config set 正确添加了 supportsPromptCacheKey: true,DeepSeek V4 Flash 仍然不返回任何缓存命中信息。OpenClaw 文档也承认:
"DeepSeek cache construction is best-effort and can take a few seconds. An immediate follow-up may still show
cached_tokens: 0"
实际上是 0 cached_tokens 持续了整个会话。
③ 边界感知缓存与 DeepSeek 不适配
OpenClaw 的边界感知系统将系统提示词分为 "稳定前缀 + 易变后缀",适用于 Anthropic/OpenAI 的缓存标记机制。但 DeepSeek 使用的是纯前缀匹配 + best-effort 缓存,边界分割反而阻止了 DeepSeek 对完整前缀进行缓存。
损失统计
| 项目 | 数值 |
|---|---|
| 升级前余额 | ~$3 (¥20+) |
| 升级后余额 | ~$0.11 (¥0.80) |
| 总损失 | ~$6 (¥40+) |
| 缓存未命中 | 2500万+ tokens |
| 时间跨度 | < 1小时(含排查时间) |
建议
- 升级流程应自动补全新增配置字段,避免旧 config 缺失导致功能异常
- DeepSeek 的
supportsPromptCacheKey应默认内置(或在文档中大幅强调) - 考虑为 DeepSeek 等 non-Anthropic/OpenAI 模型提供备选缓存策略,而非一刀切使用 boundary-aware 系统
- 在发布说明中明确标注:「升级用户需手动添加以下配置」
备注
最终回退到 2026.5.7 后,缓存命中率恢复正常(97-100%),但损失已无法追回。
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jun 6, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 6, 2026, 6:02 PM ET / 22:02 UTC.
Summary
Keep open: current main does not prove this DeepSeek cache regression is fixed, and source inspection shows DeepSeek is not currently opted into the cache-key path that OpenClaw documents for OpenAI-compatible Completions providers. The full production symptom still needs DeepSeek-live proof because DeepSeek documents automatic prefix caching and
prompt_cache_hit_tokens, not an OpenAIprompt_cache_keyrequirement.Reproducibility: yes. for the missing request-key path from source: current main omits DeepSeek
prompt_cache_keyunless model config explicitly opts in. No for the full production symptom: this review did not run a DeepSeek-live repeated-prefix cache test.Next step
A maintainer should decide the DeepSeek cache-key/cache-shaping contract and require live provider proof before a repair PR changes provider behavior.
Review details
Best possible solution:
Keep this open for a provider-owner investigation that runs DeepSeek-live repeated-prefix proof, then updates DeepSeek model metadata/provider policy or cache shaping only if the upstream behavior proves that is the right contract for fresh and upgraded configs.
Do we have a high-confidence way to reproduce the issue?
Yes for the missing request-key path from source: current main omits DeepSeek
prompt_cache_keyunless model config explicitly opts in. No for the full production symptom: this review did not run a DeepSeek-live repeated-prefix cache test.Is this the best way to solve the issue?
Unclear: adding
supportsPromptCacheKeymay address part of the source-visible OpenClaw gate, but DeepSeek's documented cache behavior is prefix-based and the report says manual opt-in still did not restore hits. The best fix needs live provider proof plus a maintainer decision at the DeepSeek provider boundary.AGENTS.md: found and applied where relevant.
Remaining risk / open question:
0 cached_tokensclaim still needs a provider-live check with repeated same-prefix requests.prompt_cache_hit_tokens, not an OpenAIprompt_cache_keycontract, so enabling request keys or changing DeepSeek cache shaping needs maintainer confirmation.Codex review notes: model gpt-5.5, reasoning high; reviewed against f7b6ee48fdb9.
Label changes
Label changes:
P1: The report describes a fresh release regression that can materially increase provider spend for real DeepSeek users after upgrade.impact:auth-provider: The affected surface is provider/model compatibility routing for DeepSeek prompt-cache request metadata and cache-retention handling.issue-rating: 🐚 platinum hermit: Current issue advisory state selects this label.clawsweeper:needs-live-repro: Current issue advisory state selects this label.clawsweeper:no-new-fix-pr: Current issue advisory state selects this label.clawsweeper:needs-maintainer-review: Current issue advisory state selects this label.clawsweeper:needs-product-decision: Current issue advisory state selects this label.Label justifications:
P1: The report describes a fresh release regression that can materially increase provider spend for real DeepSeek users after upgrade.impact:auth-provider: The affected surface is provider/model compatibility routing for DeepSeek prompt-cache request metadata and cache-retention handling.Evidence reviewed
Acceptance criteria:
What I checked:
buildParamsonly setsprompt_cache_keywhen the base URL is OpenAI or resolved compat hassupportsPromptCacheKey; provider detection defaults that flag to false for DeepSeek. (src/llm/providers/openai-completions.ts:614, f7b6ee48fdb9)supportsPromptCacheKey, so catalog-driven configs do not opt into OpenAI-compatible prompt cache keys. (extensions/deepseek/openclaw.plugin.json:41, f7b6ee48fdb9)cacheRetentionfor OpenAI-compatible backends only when the selected model reportscompat.supportsPromptCacheKey: true, so DeepSeek rows without that compat flag can lose the cache-retention signal before transport. (src/agents/embedded-agent-runner/prompt-cache-retention.ts:36, f7b6ee48fdb9)extensions/deepseek/provider-policy-api.ts:40, f7b6ee48fdb9)prompt_cache_keyonly when model config explicitly setscompat.supportsPromptCacheKey: true; the same page notes DeepSeek cache construction is best-effort and should be verified with repeated same-prefix requests. Public docs:docs/reference/prompt-caching.md. (docs/reference/prompt-caching.md:108, f7b6ee48fdb9)usage.prompt_cache_hit_tokensandusage.prompt_cache_miss_tokens, and construction is best-effort. (api-docs.deepseek.com)Likely related people:
src/llm/providers/openai-completions.ts,extensions/deepseek/openclaw.plugin.json,extensions/deepseek/provider-policy-api.ts)git log -S supportsPromptCacheKeyshows commit 687ede5 adding the prompt-cache compatibility opt-out surface that this issue now depends on. (role: prompt-cache compatibility contributor; confidence: medium; commits: 687ede50a5ac; files:src/config/types.models.ts,src/config/zod-schema.core.ts,src/agents/provider-attribution.ts)docs/reference/prompt-caching.md,src/agents/live-cache-test-support.ts,src/agents/pi-embedded-runner.cache.live.test.ts)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.RavenSS213 commentedon Jun 6, 2026
更新:根因确认
回退到 2026.5.7 后问题完全消失。
对比数据
结论
边界感知缓存系统(boundary-aware streaming)是根因。 该系统将系统提示词分割为"稳定前缀 + 易变后缀",适用于 Anthropic/OpenAI 的缓存标记机制。但 DeepSeek V4 Flash 使用的是纯前缀匹配 + "best-effort" 缓存,OpenClaw 的分段逻辑反而阻止了 DeepSeek 对完整前缀进行缓存。
回退到 2026.5.7 后,请求以完整前缀发送,DeepSeek 的原生缓存正常工作,命中率恢复到 97-100%。
建议
supportsPromptCacheKey应默认内置而非手动添加测试环境: DeepSeek V4 Flash, openai-completions API, 容器部署
RavenSS213 commentedon Jun 7, 2026
我们写了一个开源预算监控工具,能在缓存命中率暴跌 30 秒内告警:
👉 github.com/RavenSS213/ai-budget-guard
它能做什么
跟这次事故的关系
今天实测:OpenClaw 6.1 在 DeepSeek V4 Flash 上,缓存命中率 50%+ → 3%,一小时烧 $5.5。
回退到 5.7 后恢复 97-100% 命中。这个 budget-guard 就是在这次事故中诞生的一线解决方案。
Python 写的,零外部依赖,直接
python3 budget.py check '{...}'就能用。PR 欢迎 🐂🐎
kingpro1985 commentedon Jun 7, 2026
I saw this while looking at custom model/provider setup issues: "⚠️ Upgrade 2026.6.1 broke DeepSeek prompt cache - $6 burned in one hour".
If it helps your testing, CloudGPU exposes a hosted OpenAI-compatible endpoint that can route to GPT, Claude, Gemini, DeepSeek, Kimi and GLM behind one API key.
Base URL: https://gpuapis.com/api/v1
Setup guide: https://gpuapis.com/use-cases/deepseek-gemini-claude-api/
I can share a small test key/credit and a cURL request if you want to verify it in your current client before doing any integration work.
pxvp2008 commentedon Jun 11, 2026
喔嚯,我已经烧了100+RMB了,从升级到2026.5.28,就感觉不对劲,命中率低的出奇
jianpan commentedon Jun 12, 2026
The deepseek cache miss issue started from 2026.5.28.
The change: One comparison sign flipped in tool-result-truncation sort order.
2026.5.26: newest first → return a.index - b.index (stable prefix, cache-friendly)
2026.5.28+: oldest first → return a.index - b.index (rewrites prefix, cache-hostile)
steipete commentedon Jun 13, 2026
Closing as an exact duplicate of #91016 so the DeepSeek cache investigation stays in one place.
Current live evidence rules out the proposed
prompt_cache_keyexplanation: DeepSeek produced 17,920 cache-hit tokens on an identical repeated prefix without that field, and adding the field did not change the hit count. The canonical issue remains open for controlled OpenClaw prefix-stability testing across the affected versions.