Repository navigation
Description
Is your feature request related to a problem? Please describe.
OpenCode v2 (since 2.2.0, #58562) records the cost the provider reports and treats a reported zero as authoritative (packages/core/src/session/usage.ts). OpenCode Go is subscription-billed, so the gateway reports cost: 0 and v2 stores zero even though requests consume real credit.
The plugin reads that stored value, so on v2:
- the sidebar "Cost estimation" shows
$0.00; /model-usagerenders Go models as· free(no price per 1M) becauseModelUsage.totalCostis 0;- session/period totals and exports containing Go usage are zero.
v1 is unaffected (it computes list prices). This is upstream behaviour, not a plugin regression — tracked in docs/opencode-v1-to-v2-migration.md §13.11.
Describe the solution you'd like
Decide how the plugin should report cost for subscription providers on v2. Options to evaluate:
- Keep the authoritative stored cost and label it (e.g. "covered by OpenCode Go") so
$0.00is not read as a bug. - Offer an explicit, clearly-labelled list-price estimate derived from the model catalog (input / output+reasoning / cache read / cache write), mirroring OpenCode's own
calculateCostand the opt-inexperimental.cost-estimate(upstream PR #59864). Prefer a pure helper + tests; keep it opt-in so exported/DB-visible cost stays the authoritative number. - Persist/report the Go allowance a session consumed (upstream #59653) if the host exposes it.
Describe alternatives you've considered
- Local estimate applied unconditionally (rejected for now: it invents a number the host did not bill and diverges from stored/exported cost).
- Waiting for upstream to change cost accounting (maintainers currently consider
$0intended).
Additional context
Verified on OpenCode 2.2.3, session ses_e726d4816ffeFKS76cCb6Ugzek (opencode-go/gpt-6-luna): 25 assistant messages, session_v2.cost = 0, tokens { input: 72, output: 5532, reasoning: 24261, cache: { read: 1319320, write: 120199 } } ≈ $0.043 at catalog rates ($0.10 / $0.50 per 1M, $0.01 cache read, $0.125 cache write). The same database's v1 message rows for the same provider still carry non-zero cost.
Upstream reports/status: #59627 (closed not_planned), #59634 (open), #60052 / #59812 (closed duplicate), #60624 (open, duplicate of #59634), #59861 (open feature request), PR #59864 (open, opt-in experimental.cost-estimate, display-only).
Media
N/A
Activity