-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
[Bug]: DeepSeek V4 API returns usage.cost total as 0, causing Control UI Spend to show zero #97047
Copy link
Copy link
Closed
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.ClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:data-lossCan lose, corrupt, or silently drop user/session/config data.Can lose, corrupt, or silently drop user/session/config data.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.no-staleExclude from stale automationExclude from stale automation
Description
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.ClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:data-lossCan lose, corrupt, or silently drop user/session/config data.Can lose, corrupt, or silently drop user/session/config data.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.no-staleExclude from stale automationExclude from stale automation
Type
Fields
Priority
None yet
Summary
When using
deepseek/deepseek-v4-flash(ordeepseek/deepseek-v4-pro) via the official DeepSeek API, the DeepSeek V4 API returnsusage.cost.total: 0in completion responses. OpenClaw treats this 0 as a valid cost value and skips the fallback estimate-usage-cost logic, so the Control UI "Spend" section shows ¥0.00 for all V4 model usage.Steps to Reproduce
deepseek/deepseek-v4-flashas the default modelOr inspect the transcript:
Expected Behavior
DeepSeek V4 spend should be estimated from token counts and known pricing, since the API does not return cost directly. For example:
deepseek-v4-flash: input ¥0.14/10K tokens, output ¥0.28/10K tokensdeepseek-v4-pro: input ¥1.74/10K tokens, output ¥3.48/10K tokensActual Behavior
Spend shows ¥0.00 in Control UI for all DeepSeek V4 usage.
Root Cause
The
extractCostBreakdown()function insrc/infra/session-cost-usage.tsreturns{ total: 0, ... }from the API response. Downstream inscanTranscriptFile(), the cost aggregation logic checks:Since
isModelPricingKnown(cost)returnstrue(pricing IS configured/known), andcostTotal === 0(not undefined), both estimate paths are skipped. The 0 is accepted as fact.Possible Fix
In
extractCostBreakdown()or the downstream aggregation paths, treattotal: 0as an unknown/not-provided value rather than a valid zero-cost entry when token counts are non-zero.Environment
deepseek(official API at api.deepseek.com)deepseek/deepseek-v4-flash@openclaw/deepseek-provider(v2026.6.10)