You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
5.6 Luna on opencode zen tui showing half the price being shown on web version #39891
Ive attached screenshots for both, and the one on web seem more correct. Its misleading, makes costs in tui appear much less than they actually are. Findings from my triage are below.
The TUI is not “about half by rounding.” It is subtracting Luna’s cache-write tokens from a total that never contained them as extra, and the web is not doing that subtraction.
Those 2,950 write tokens were already inside 82,307. Subtracting them again leaves 3 tokens at the input rate instead of 2,953. Anthropic looks right because its inputTokensis exclusive of cache, so the same minus does not eat a second copy.
The web path does not subtract the write. Zen only removes the cache read:
One row is small. A long session is thousands of those writes, which is the “TUI looks like half the web” screenshot.
This is not an OpenAI bug. 3 + 79,354 + 2,950 = 82,307 is internally consistent. The bug is applying the exclusive split (input − read − write) to a provider whose inputTokens is already inclusive. Handle it on the OpenAI / Luna mapper: if noCache + read + write == inputTokens, take noCache as fresh and do not subtract write a second time.
Activity
tejush1998 commentedon Jul 31, 2026
Logged this in opencode in packages/opencode/src/session/llm.ts :
Response from openai luna :
Meanwhile opencode usage shows:
As you can see above inputTokens: 82307 vs 85257
Diff = cache_write_tokens = 2950 (inputTokens from openai is exclusive of cacheWriteTokens)
Problem?
the getUsage function in packages/opencode/src/session/session.ts :
assumes cacheWriteInputTokens to be part of inputTokens
This shows in tui as low billing than it actually is, because cacheWrites are eating into the freshTokens total
Anthropic works properly:
Opencode usage correctly showing totalInput : 23335, which matches the above inputTokens
Question: So this is an upstream issue need to be reported to OpenAI? Or should we handle it? Would love to contribute
Zaczero commentedon Aug 18, 2026
The TUI is not “about half by rounding.” It is subtracting Luna’s cache-write tokens from a total that never contained them as extra, and the web is not doing that subtraction.
Your own capture is enough:
So
inputTokensis already the whole prompt: fresh + read + write. It is not exclusive of the write.TUI then shows:
getUsagethen does the Anthropic split:Those 2,950 write tokens were already inside
82,307. Subtracting them again leaves 3 tokens at the input rate instead of 2,953. Anthropic looks right because itsinputTokensis exclusive of cache, so the same minus does not eat a second copy.The web path does not subtract the write. Zen only removes the cache read:
plus 2,950 at the write rate. Same tokens, two bills on the web, one bill (write only) on the TUI.
On this request that is 2,950 tokens at Luna’s input price that the TUI never charges:
One row is small. A long session is thousands of those writes, which is the “TUI looks like half the web” screenshot.
This is not an OpenAI bug.
3 + 79,354 + 2,950 = 82,307is internally consistent. The bug is applying the exclusive split (input − read − write) to a provider whoseinputTokensis already inclusive. Handle it on the OpenAI / Luna mapper: ifnoCache + read + write == inputTokens, takenoCacheas fresh and do not subtract write a second time.opencode/packages/ai/src/protocols/openai-chat.ts
Lines 582 to 589 in 9e22c40
thdxr commentedon Oct 11, 2026
Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (
opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊