Repository navigation
Description
Description
Bug: session cost is always 0 (status bar shows $US 0.00) since 2026-10-30 ~06:36 UTC
Versions: 2.2.3 (channel latest) — same behaviour on 2.2.2 and 2.2.0 Platform: Windows 11, OpenCode desktop app (build 2.2.3) Provider used: opencode-go (also reproduced with provider opencode) Model used: opencode-go/minimax-m3.1-flash (variant max); also reproduced with opencode/qwen3.6-plus
Symptom
The session cost in the status bar reads $US 0.00, even though the token counter next to it works normally. Every assistant message is persisted with cost: 0:
-- read-only, on ~/.local/share/opencode/opencode.db
SELECT COUNT(*) FROM session_message
WHERE type = 'assistant' AND json_extract(data,'$.cost') > 0;
-- 11853 (all before the cut-off)
SELECT time_created, json_extract(data,'$.cost') AS cost,
json_extract(data,'$.tokens.input') AS inp,
json_extract(data,'$.tokens.output') AS out,
json_extract(data,'$.tokens.cache.read') AS cache
FROM session_message
WHERE type = 'assistant' AND json_extract(data,'$.cost') > 0
ORDER BY time_created DESC LIMIT 3;
-- 2026-10-30 06:36 UTC 0.001491522 in=444 out=46 cache=718961
When it started
2026-10-30 06:36 UTC — last assistant message with a non-zero cost.
2026-10-30 06:37:28 UTC — the background service was (re)started as version=2.2.2 (previous: 2.1.4). In the same second the service applied 8 database migrations (session_allowance, drop_session_allowance, blob, drop_session_pending, schedule, session_part, session_time_busy, schedule_checks) and created the two cache rows models-dev:v2:catalog and models-dev:v2:catalog:meta in the kv table.
2026-10-30 06:39 UTC — first message with cost: 0. Every message since, in every session, has cost: 0.
2026-10-30 07:18 UTC — service restarted as version=2.2.0; the counter stayed at 0.
2026-10-30 13:33 UTC — service restarted as version=2.2.3 (the version the update channel offers); the counter is still 0 — including in a brand-new session created after the update, and with a different provider (opencode instead of opencode-go) and a different model (qwen3.6-plus).
What still works
Token counters per message and per session (input, output, cache.read, reasoning) are correct and keep being written.
The price table is intact and reachable: GET https://opencode.ai/inference/go/v1/models returns 28/28 models with a cost field (e.g. minimax-m3.1-flash: input 0.15, output 0.6, cache.read 0.015 per 1M tokens).
The client does know how to compute the cost: an old message (2026-10-30 06:36 UTC, model muse-spark-1.3-contributor) has cost = 0.001491522, which is exactly 444×0.1/1e6 + 46×0.2/1e6 + 718961×0.002/1e6. So the arithmetic is right — the price lookup is what returns nothing.
Expected behaviour
The session cost in the status bar and the cost field of each assistant message should be computed from the reported tokens and the model's price (the same way it was up to 2026-10-30 06:36 UTC).
Notes for triage
The last version in which the cost was still computed: 2.1.4 (and 2.2.0 before the 2.2.2 run on 2026-10-30 06:37 UTC).
The change coincides with the 2.2.2 startup, its 8 database migrations and the two new kv cache rows (models-dev:v2:catalog, models-dev:v2:catalog:meta). The cached catalog itself contains no opencode-go entry (the Go prices come from the provider's own model list), so a price lookup that consults only the cached catalog would find nothing for Go models — but the symptom also affects non-Go models, so a shared lookup path is likely involved.
Restarting the service, deleting sessions, or creating a new session does not change the behaviour.
How to reproduce the check
Open OpenCode, start a session, send one message.
Quit/inspect ~/.local/share/opencode/opencode.db (read-only) and run: SELECT json_extract(data,'$.cost') FROM session_message WHERE type='assistant' ORDER BY time_created DESC LIMIT 3; → all rows return 0.
Compare with the same query filtered by json_extract(data,'$.cost') > 0 → the newest row is from 2026-10-30 06:36 UTC.
Plugins
No response
OpenCode version
2.2.3 and 2.2.2, 2.2.0
Steps to reproduce
SELECT json_extract(data,'$.cost') FROM session_message
WHERE type='assistant' ORDER BY time_created DESC LIMIT 3;
Screenshot
No response
Operating System
No response
Terminal
Windows 11
Activity
opencodejr commentedon Oct 30, 2026
Thanks for the detailed report and the database queries, they made this easy to trace.
I think this is a duplicate of #59634, which reports the same thing on the Windows desktop app: since 2.2.0,
opencode-gosessions record their tokens normally but savecost = 0.The $0 is intended. Since #58562 (shipped in 2.2.0), OpenCode stores the cost the OpenCode gateway reports for each request, and a reported 0 counts as the real cost. The catalog price is only used when the gateway reports nothing. Usage within your Go plan is covered by the subscription, so the gateway reports
cost: 0. That's why the price lookup appears to return nothing even though the price list is intact. The non-zero values you saw on 2.1.4 were estimates at list prices, not amounts charged. You can see how much of your Go allowance you've used in the desktop Usage dialog (or with/usagein the TUI).Possible duplicates and related issues, ordered by likelihood:
One thing that may be different: you also saw 0 with
opencode/qwen3.6-plus. If that model is free, or the request was covered by your Go plan, 0 is expected there too. If that request was actually charged to your Zen balance (check Console > Activity) and the app still shows $0, please reply with that, because that would be a different problem.The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different.
RMAYANG146 commentedon Oct 31, 2026
Same symptom, but my cut-off is two days earlier than the one reported here.
opencode-go, modeldeepseek-v4.1-flash, varianthighcost: 0, per-messagecost: 0, tokens recorded normallyAcross 50 stored sessions, 24 have a non-zero cost and all of them were created before 2026-10-28 06:31 UTC.
After that timestamp, zero sessions have a non-zero cost, including sessions on 10-29 and 10-31 and a
kimi-k2.7-codesession.GET /api/sessionreturns"cost": 0whiletokens.input,tokens.output,tokens.reasoningandtokens.cache.readkeep increasing. Example: during one session after upgrading the CLI from 2.1.4 to 2.2.5,input tokens grew by 15,284 and cache-read by 2,725,632, and
coststayed exactly 0. So the version skew wasnot the cause and the issue reproduced after the upgrade.
variantis not a factor: the costed sessions from 10-26/10-27 also usevariant: "high".Model prices are present locally (
opencode modelslistsopencode-go/deepseek-v4.1-flashat 0.15 / 0.60 /0.003 per Mtok), so this is not a missing-price-data situation.
The account's console usage does keep being consumed while the app shows $0.00.
opencodejr commentedon Oct 31, 2026
We haven't heard back in the day since we suggested this was a duplicate, so I'm closing it as a duplicate of #59634. That issue covers the same thing: since 2.2.0, the desktop app shows $0.00 for OpenCode Go sessions while tokens are still recorded.
Quick recap: since #58562, OpenCode saves the cost the gateway reports for each request. Usage within your Go plan is covered by the subscription, so it's reported as $0. You can check your Go allowance in the desktop Usage dialog. #59861 (with PR #59864) tracks an optional estimate from list prices, and #59653 tracks saving the Go allowance each session used. You can follow or upvote either one.
If
opencode/qwen3.6-plusor another Zen model still shows $0 for requests that were actually charged to your Zen balance (check Console > Activity), please reply with the model and roughly when it happened and we can reopen this, because that would be a different problem.