Description
Opencode's pricing estimate is incorrect when a model with with tiered context pricing and your session goes into the higher tier. The local cost estimates use the price of smaller context for the entire session, resulting in a cost estimate that is lower than what it should be.
For example, the session that I discovered this showed $3.37 in opencode's UI, but the real price was $3.71. The longer the session, the wider the discrepancy.
Testing with grok 4.6, which has different pricing for > 200k, the model calls reported in Zen differed from what is stored in the local sqlite database.
Plugins
No response
OpenCode version
1.18.18
Steps to reproduce
For testing with Zen:
Use a model that has tiered context pricing, such as grok 4.6 or one of the gpt 5.6 models. Have a session go into the higher tiered pricing. Compare local session pricing vs Zen's UI.
WITH ranked_calls AS (
SELECT
ROW_NUMBER() OVER (ORDER BY time_created, id) AS call_number,
time_created,
data
FROM message
WHERE session_id = 'ses_ff50d39fbffe2mOJcly5gtxQyW'
AND json_extract(data, '$.role') = 'assistant'
AND (
COALESCE(json_extract(data, '$.tokens.input'), 0) +
COALESCE(json_extract(data, '$.tokens.cache.read'), 0) +
COALESCE(json_extract(data, '$.tokens.cache.write'), 0) +
COALESCE(json_extract(data, '$.tokens.output'), 0) +
COALESCE(json_extract(data, '$.tokens.reasoning'), 0)
) > 0
)
SELECT
call_number,
strftime('%b %d, %H:%M', time_created / 1000, 'unixepoch', 'localtime') AS date,
json_extract(data, '$.modelID') AS model,
COALESCE(json_extract(data, '$.tokens.input'), 0) +
COALESCE(json_extract(data, '$.tokens.cache.read'), 0) +
COALESCE(json_extract(data, '$.tokens.cache.write'), 0) AS input,
printf('$%.4f', COALESCE(json_extract(data, '$.cost'), 0)) AS cost,
substr('ses_ff50d39fbffe2mOJcly5gtxQyW', -8) AS session
FROM ranked_calls
WHERE call_number >= (
SELECT MAX(call_number) - 9 FROM ranked_calls
)
ORDER BY call_number DESC;
Screenshot and/or share link
Zen pricing:

Local sqlite pricing:
Operating System
No response
Terminal
No response
Description
Opencode's pricing estimate is incorrect when a model with with tiered context pricing and your session goes into the higher tier. The local cost estimates use the price of smaller context for the entire session, resulting in a cost estimate that is lower than what it should be.
For example, the session that I discovered this showed $3.37 in opencode's UI, but the real price was $3.71. The longer the session, the wider the discrepancy.
Testing with grok 4.6, which has different pricing for > 200k, the model calls reported in Zen differed from what is stored in the local sqlite database.
Plugins
No response
OpenCode version
1.18.18
Steps to reproduce
For testing with Zen:
Use a model that has tiered context pricing, such as grok 4.6 or one of the gpt 5.6 models. Have a session go into the higher tiered pricing. Compare local session pricing vs Zen's UI.
Screenshot and/or share link
Zen pricing:

Local sqlite pricing:
Operating System
No response
Terminal
No response