CodeWhale icon indicating copy to clipboard operation
CodeWhale copied to clipboard

Incorrect total cost display in TUI: shows much higher amount than actual DeepSeek platform consumption (possible saved/cache hit calculation bug)

Open caiyilian opened this issue 6 months ago • 4 comments

Bug Description

The total cost displayed in the codewhale-tui interface is significantly higher than the actual consumption shown on the DeepSeek Open Platform dashboard. 

Steps to Reproduce

  1. Use the latest Windows version of CodeWhale
  2. Run codewhale-tui and check the total cost displayed in the status bar
  3. Compare this value with the "Monthly Consumption" figure on the DeepSeek Open Platform console 

Actual Behavior

  • CodeWhale TUI status bar shows: ¥53.90 (as shown in the first screenshot)
  • DeepSeek Open Platform actual monthly consumption: ¥15.13 (as shown in the second screenshot)
  • There is a discrepancy of over 3.5x between the two values 

Expected Behavior

The total cost displayed in the TUI should accurately match the actual consumption billed by DeepSeek. 

Additional Context

I noticed that the latest update appears to have added a "saved" indicator in the status bar (partially visible in the first screenshot). I suspect this issue may be related to the calculation of cache hit savings:

  • It seems the TUI might be incorrectly calculating the total cost by not properly accounting for the discounted pricing of cached tokens
  • Or alternatively, the "saved" amount is being added to the total cost instead of subtracted from it
  • The cache hit feature on DeepSeek charges significantly less for repeated tokens, which may not be correctly reflected in CodeWhale's internal cost calculation 

Screenshots

  1. CodeWhale TUI status bar showing incorrect total cost:
Image
  1. DeepSeek Open Platform dashboard showing actual monthly consumption:
Image



Environment

  • OS: Windows
  • CodeWhale version: latest (as of June 2, 2026)
  • Model: DeepSeek V4

caiyilian avatar Jun 02 '26 02:06 caiyilian

Thanks @caiyilian for the screenshots and for calling out the cache-hit angle. I checked this against the v0.8.50 branch and the current DeepSeek pricing page. The cost calculator is already using the current V4-Pro rates after the 2026-05-31 cutoff, including separate cache-hit/cache-miss input prices, so this does not look like the old #2489 4x pricing-table bug in the current branch.

One thing your screenshot likely exposed is a footer-legibility issue: the optional account-balance chip was labeled bal, and on narrow footers the balance chip can remain visible while session cost is dropped. That can make remaining account balance look like total spend. I harvested that into #2504: the English chip now says balance ¥... instead of bal ¥... so it is harder to confuse with session spend.

I am leaving this open until we confirm the actual installed version and which footer chip was visible. Could you please retest with the next build and share:

  • codewhale-tui --version
  • whether the footer text says balance, cost, or both
  • /cost, /tokens, and /cache output after one short V4-Pro turn

If /cost itself still differs from the platform usage on v0.8.50, we should treat that as a real remaining accounting bug rather than a display-label issue.

Hmbown avatar Jun 02 '26 02:06 Hmbown

Thanks again @caiyilian. I traced the inflated cost display to a cache-telemetry mixing case and opened #2630 for v0.8.52. The fix keeps DeepSeek prompt_cache_hit_tokens and OpenAI-style cached_tokens accounting from being combined inconsistently, which is the path that could overstate cached input cost.

Hmbown avatar Jun 03 '26 10:06 Hmbown

The cache-accounting fix from #2630 is now merged to main and will be part of v0.8.52. Sorry this took a messy path through the release work; the concrete fix is to keep the selected cache-hit telemetry source consistent when deriving cache-miss tokens, which should avoid overstating cached input cost. I am leaving this open until v0.8.52 is published and you can retest against the same DeepSeek dashboard comparison.

Hmbown avatar Jun 03 '26 10:06 Hmbown

@Hmbown Thanks so much for tracking down the actual root cause and fixing it quickly.

caiyilian avatar Jun 03 '26 11:06 caiyilian