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
Thanks for the context here. I did a careful shell check against current
main, and this is already implemented.Close as implemented: the remaining credible root cause was full-resend prompt-prefix byte instability, and current main now fixes that shared LLM-boundary path while the DeepSeek cache-key theory was explicitly ruled out by live verification.
I found the merged PR that appears to have closed this: #90811: fix(agents): stabilize user-turn serialization across turns to preserve prompt cache.
So I’m closing this as already implemented rather than keeping a duplicate issue open.
Review details
Best possible solution:
Keep the shipped LLM-boundary byte-stability fix as the canonical resolution and avoid adding unsupported DeepSeek prompt_cache_key behavior.
Do we have a high-confidence way to reproduce the issue?
Yes for the historical regression: the merged cache-stability PR includes live proof and a regression test for current-vs-historical byte drift. Current main no longer exposes the failing source path because the boundary normalization fix is present.
Is this the best way to solve the issue?
Yes: the shared LLM-boundary fix is the right layer for full-resend prompt-cache stability, while adding DeepSeek-specific prompt_cache_key support was live-tested and rejected as ineffective.
Security review:
Security review: Non-PR issue triage; no patch security review applies.
AGENTS.md: found and applied where relevant.
What I checked:
src/agents/embedded-agent-runner/run/attempt.llm-boundary.ts:315, 44e6caff5401)src/agents/embedded-agent-runner/run/attempt.llm-boundary.cache-stability.test.ts:66, 44e6caff5401)src/llm/providers/openai-completions.ts:1197, 44e6caff5401)Likely related people:
src/agents/embedded-agent-runner/run/attempt.llm-boundary.ts,src/agents/embedded-agent-runner/run/attempt.llm-boundary.cache-stability.test.ts)src/agents/embedded-agent-runner/run/attempt.ts,src/agents/embedded-agent-runner/run/attempt.llm-boundary.ts)src/agents/embedded-agent-runner/run/attempt.llm-boundary.ts,src/gateway/server-methods/agent-timestamp.ts)src/llm/providers/openai-completions.ts,extensions/deepseek/models.ts)Codex review notes: model internal, reasoning high; reviewed against 44e6caff5401; fix evidence: merged PR #90811, release v2026.6.5-beta.2, commit 1af55bc6654f.
kingpro1985 commentedon Jun 7, 2026
I saw this while looking at custom model/provider setup issues: "⚠️ 升级 2026.6.1 后 DeepSeek Prompt Cache 完全失效,一小时烧掉约 $6".
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.
phoebusluckymail-cpu commentedon Jun 7, 2026
5.22升级到6.1版本一样被坑了,缓存命中骤降。
JAVA-LW commentedon Jun 9, 2026
可以试试套一层1flowbase,手动构建上下文
https://github.com/taichuy/1flowbase
10 remaining items
xingchen-c commentedon Jun 17, 2026
所以实际上这个问题实际上是还没有被完全修复?目前还不能升级到最新的OpenClaw版本?
Alex-zbz commentedon Jun 17, 2026
我删除了旧的openclaw,重新下载了新的,使用的一天内,上午缓存命中率可以达到90%以上,下午却开始急剧下降,甚至将一整天的命中比例拉低至50%,消耗巨大。
RavenSS213 commentedon Jun 17, 2026
目前官方升级文档中并没有明确的说已经修复deepseek缓存命中率,而且6.8我们尝试了升级最新版本也一样token爆燃,重新安装也无效
Yijian-quiet commentedon Jun 18, 2026
今天才注意到这个问题。。。。
Alex-zhouzi commentedon Jun 18, 2026
没招了,怎么折腾都不行,用不起了
RavenSS213 commentedon Jun 18, 2026
对于还在关注这个 issue 的朋友们,统一回复一下:
当前状态: 这个 issue 被 clawsweeper[bot] 自动关闭了(2026-06-06),bot 的判断是"已经在 main 分支实现",但实际的 DeepSeek 缓存问题并没有被真正修复。
多位用户的实测反馈:
建议: 在 OpenClaw 官方发布说明明确标注 "已修复 DeepSeek 缓存问题" 之前,留在 2026.5.7 是最明智的选择。回退后缓存命中率恢复 97-100%,这是目前唯一稳定可用的版本。
@maintainers: 这个 issue 需要重新打开。bot 的自动分类在此案例中做出了错误的根因判断——问题不是序列化稳定性,而是 OpenClaw 的边界感知缓存与 DeepSeek 的纯前缀匹配缓存不兼容。请重新评估并考虑针对 DeepSeek 等 non-Anthropic/OpenAI 模型提供备选缓存策略。
RavenSS213 commentedon Jun 18, 2026
@steipete — 抱歉直接打扰。这条 issue 被 clawsweeper[bot] 自动关闭了,但问题完全没有解决(见上方多位用户的实测数据)。由于仓库设置了 reopen 限制,我们(issue 作者和受影响的用户)无法自行重新打开。
能否麻烦你帮忙 reopen 这条 issue?你之前在 thread 中的实测已经证明问题仍未修复 — "Direct DeepSeek API test with an 18,010-token repeated prompt" 虽然确认了 DeepSeek 自身缓存可用,但 OpenClaw 的边界感知实现与 DeepSeek 的纯前缀匹配机制之间的不兼容问题仍然存在。
另外,我想统一回复一下其他关注此 issue 的朋友们:
在 OpenClaw 官方发布说明明确标注 "已修复 DeepSeek 缓存问题" 之前,留在 2026.5.7 是最明智的选择。 回退后缓存命中率恢复 97-100%,日花费回到正常水平(¥3-5/天)。升级到任何 6.x 版本目前都会导致缓存命中率骤降(实测降至 50-71%),日花费暴涨 10-12 倍。