Skip to content

⚠️ Upgrade 2026.6.1 broke DeepSeek prompt cache - $6 burned in one hour #91018

Closed as duplicate

Description

@RavenSS213

⚠️ 严重警告:升级 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_key only when their model config explicitly sets compat.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小时(含排查时间)

建议

  1. 升级流程应自动补全新增配置字段,避免旧 config 缺失导致功能异常
  2. DeepSeek 的 supportsPromptCacheKey 应默认内置(或在文档中大幅强调)
  3. 考虑为 DeepSeek 等 non-Anthropic/OpenAI 模型提供备选缓存策略,而非一刀切使用 boundary-aware 系统
  4. 在发布说明中明确标注:「升级用户需手动添加以下配置」

备注

最终回退到 2026.5.7 后,缓存命中率恢复正常(97-100%),但损失已无法追回。

Activity

  1. clawsweeper commented on Jun 6, 2026

    @clawsweeper
    Contributor

    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 OpenAI prompt_cache_key requirement.

    Reproducibility: yes. for the missing request-key path from source: current main omits DeepSeek prompt_cache_key unless 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_key unless 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 supportsPromptCacheKey may 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:

    • The live DeepSeek cache-hit behavior was not reproduced in this read-only triage, so the sustained 0 cached_tokens claim still needs a provider-live check with repeated same-prefix requests.
    • DeepSeek's public docs describe automatic prefix caching and prompt_cache_hit_tokens, not an OpenAI prompt_cache_key contract, 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:

    • add P1: The report describes a fresh release regression that can materially increase provider spend for real DeepSeek users after upgrade.
    • add impact:auth-provider: The affected surface is provider/model compatibility routing for DeepSeek prompt-cache request metadata and cache-retention handling.
    • add issue-rating: 🐚 platinum hermit: Current issue advisory state selects this label.
    • add clawsweeper:needs-live-repro: Current issue advisory state selects this label.
    • add clawsweeper:no-new-fix-pr: Current issue advisory state selects this label.
    • add clawsweeper:needs-maintainer-review: Current issue advisory state selects this label.
    • add 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:

    • OPENCLAW_LIVE_TEST=1 OPENCLAW_LIVE_PROVIDERS=deepseek OPENCLAW_LIVE_MODELS="deepseek/deepseek-v4-flash" pnpm test:live -- deepseek
    • node scripts/run-vitest.mjs extensions/deepseek/provider-policy-api.test.ts
    • node scripts/run-vitest.mjs src/agents/embedded-agent-runner/prompt-cache-retention.test.ts
    • node scripts/run-vitest.mjs src/llm/providers/openai-completions.test.ts

    What I checked:

    • Source cache-key gate: buildParams only sets prompt_cache_key when the base URL is OpenAI or resolved compat has supportsPromptCacheKey; provider detection defaults that flag to false for DeepSeek. (src/llm/providers/openai-completions.ts:614, f7b6ee48fdb9)
    • DeepSeek catalog gap: The bundled DeepSeek V4 Flash entry has cache-read pricing but its compat block lacks supportsPromptCacheKey, so catalog-driven configs do not opt into OpenAI-compatible prompt cache keys. (extensions/deepseek/openclaw.plugin.json:41, f7b6ee48fdb9)
    • Agent runner gate: The embedded runner preserves explicit cacheRetention for OpenAI-compatible backends only when the selected model reports compat.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)
    • DeepSeek provider policy gap: DeepSeek provider policy hydrates context window, max tokens, and cost from the bundled catalog, but not compat fields such as cache-key support for existing user-configured model rows. (extensions/deepseek/provider-policy-api.ts:40, f7b6ee48fdb9)
    • OpenClaw docs contract: Prompt-caching docs say OpenAI-compatible Completions providers receive prompt_cache_key only when model config explicitly sets compat.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)
    • DeepSeek API contract: DeepSeek's current Context Caching docs say caching is enabled by default without code changes, cache hits require persisted matching prefixes, hit status is exposed as usage.prompt_cache_hit_tokens and usage.prompt_cache_miss_tokens, and construction is best-effort. (api-docs.deepseek.com)

    Likely related people:

    • Vincent Koc: Current blame in the available checkout attributes the OpenAI-completions cache-key gate, DeepSeek catalog entries, and DeepSeek provider-policy lines to commit 59a8137. (role: recent area contributor; confidence: medium; commits: 59a8137b04a5; files: src/llm/providers/openai-completions.ts, extensions/deepseek/openclaw.plugin.json, extensions/deepseek/provider-policy-api.ts)
    • Daniel Salmerón Amselem: git log -S supportsPromptCacheKey shows 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)
    • Peter Steinberger: Prompt-cache history shows live cache probe and documentation work in commits ca99ad0 and related prompt-cache docs/probe commits, useful for live verification routing. (role: prompt-cache live-probe/docs contributor; confidence: medium; commits: ca99ad0af8dc; files: 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 keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  2. added
    P1High-priority user-facing bug, regression, or broken workflow.
    impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.
    on Jun 6, 2026
  3. RavenSS213 commented on Jun 6, 2026

    @RavenSS213
    Author

    更新:根因确认

    回退到 2026.5.7 后问题完全消失。

    对比数据

    版本 缓存命中率 API 成本
    2026.6.1 (边界感知缓存) 3-21% 每分钟 $0.02-0.03
    2026.5.7 (无边界感知) 97-100% 每小时 <$0.001

    结论

    边界感知缓存系统(boundary-aware streaming)是根因。 该系统将系统提示词分割为"稳定前缀 + 易变后缀",适用于 Anthropic/OpenAI 的缓存标记机制。但 DeepSeek V4 Flash 使用的是纯前缀匹配 + "best-effort" 缓存,OpenClaw 的分段逻辑反而阻止了 DeepSeek 对完整前缀进行缓存。

    回退到 2026.5.7 后,请求以完整前缀发送,DeepSeek 的原生缓存正常工作,命中率恢复到 97-100%。

    建议

    • 为 DeepSeek / OpenAI-compatible 模型提供禁用边界感知缓存的选项
    • 或在升级流程中自动检测并适配不同模型的缓存策略
    • supportsPromptCacheKey 应默认内置而非手动添加

    测试环境: DeepSeek V4 Flash, openai-completions API, 容器部署

  4. RavenSS213 commented on Jun 7, 2026

    @RavenSS213
    Author

    ⚠️ 被烧的用户可以先用这个顶住

    我们写了一个开源预算监控工具,能在缓存命中率暴跌 30 秒内告警:

    👉 github.com/RavenSS213/ai-budget-guard

    它能做什么

    • 🔍 缓存命中率检测 — cache_hit_pct < 30% 立刻警告 ← 这次 $5.5 事故如果它在,第一分钟就抓住了
    • 💰 预算跟踪 — 设月上限,分级预警
    • 🔮 预测性耗尽 — "按当前速度 N 小时后花光"
    • 🛑 冻结 + 省钱建议 — 自动推荐切模型

    跟这次事故的关系

    今天实测:OpenClaw 6.1 在 DeepSeek V4 Flash 上,缓存命中率 50%+ → 3%,一小时烧 $5.5。

    回退到 5.7 后恢复 97-100% 命中。这个 budget-guard 就是在这次事故中诞生的一线解决方案。

    Python 写的,零外部依赖,直接 python3 budget.py check '{...}' 就能用。

    PR 欢迎 🐂🐎

  5. kingpro1985 commented on Jun 7, 2026

    @kingpro1985

    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.

  6. pxvp2008 commented on Jun 11, 2026

    @pxvp2008

    喔嚯,我已经烧了100+RMB了,从升级到2026.5.28,就感觉不对劲,命中率低的出奇

  7. jianpan commented on Jun 12, 2026

    @jianpan

    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)

  8. steipete commented on Jun 13, 2026

    @steipete
    Contributor

    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_key explanation: 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.

  9. locked as resolved and limited conversation to collaborators on Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority user-facing bug, regression, or broken workflow.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions