Skip to content

fix(usage): price OpenCode Go models missing cost estimates - #4898

Merged
lidge-jun merged 2 commits into
lidge-jun:devfrom
agentHits:agentHits/opencode-go-cost
Sep 17, 2026
Merged

lidge-jun merged 2 commits into
lidge-jun:devfrom
agentHits:agentHits/opencode-go-cost

Conversation

@agentHits

@agentHits agentHits commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • OpenCode Go usage showed ~$0 / em dashes instead of estimated cost for five served model ids: qwen3.8-max, qwen3.8-flash, deepseek-v4.1-flash, glm-5.3-flash, muse-spark-1.3-contributor.
  • Root cause: these ids have no opencode-go jawcode bundle row, and the model-level vendor fallback only searches jawcode metadata, never expected-price overlays — so resolveMatchedPrice returned null and the Usage estimated-cost column plus the per-model breakdown rendered an em dash for every request through them.
  • Fix: five exact opencode-go/<model> rows in EXPECTED_PRICE_OVERLAYS reusing each vendor's own published list price as a verified-derived estimate (Go itself is subscription-billed): Qwen3.8-Max 2/6, Qwen3.8-Flash 0.16/0.47, DeepSeek V4.1-Flash peak-window 0.30/1.20 with cache-hit 0.006, GLM 5.3 Flash from the z.ai USD table, Muse Spark 1.3 Contributor tier. No GUI code changed — the existing estimatedCostUsd path now receives a number instead of null.
  • Before/after for the reported case (qwen3.8-flash, 1.7k tokens): before — no cost (); after — ~$0.0003 estimated.

Verification

  • bun test tests/usage/usage-cost.test.ts — 98 pass / 0 fail (includes new test 17h covering all five ids plus an end-to-end estimateRequestCost check, and the overlay membership count 121 → 126).
  • bun run typecheck — clean.
  • bun test tests/usage — 695 pass / 1 fail; the single failure (usage-summary.test.ts › custom usage windows › intraday endpoints) reproduces on the clean tree without this change, so it is pre-existing and unrelated.
  • No GUI code touched, so no UI screenshot applies (the displayed numbers flow through the unchanged estimatedCostUsd rendering).

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • All CI tests are green on my local testing.

  • I pushed my PR to the latest dev commit.

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

Summary by CodeRabbit

  • New Features

    • Added cost estimates for DeepSeek V4.1-Flash and Qwen3.8-Flash, including input, output, and cache rates.
    • Added pricing coverage for five OpenCode Go models: Qwen3.8-Max, Qwen3.8-Flash, DeepSeek V4.1-Flash, GLM-5.3-Flash, and Meta Muse Spark Contributor.
    • Estimates include vendor list-price sourcing and caveats for unpublished cache rates and peak-window pricing.
  • Tests

    • Added coverage confirming pricing resolution and request cost estimates for OpenCode Go models.

@github-actions

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Sep 17, 2026
@coderabbitai

coderabbitai Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 07eccef5-59d5-47c3-bd30-f544125e510e

📥 Commits

Reviewing files that changed from the base of the PR and between 7195106 and c0e711f.

📒 Files selected for processing (2)
  • src/usage/expected-prices.ts
  • tests/usage/usage-cost.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

The change adds DeepSeek V4.1-Flash and Qwen3.8-Flash pricing data, five opencode-go overlays, and tests for model resolution, source caveats, request-cost estimation, and overlay membership.

Changes

OpenCode Go pricing

Layer / File(s) Summary
Pricing tuples and OpenCode Go overlays
src/usage/expected-prices.ts
Adds DeepSeek V4.1-Flash peak-window pricing and Qwen3.8-Flash pricing. Adds five verified-derived opencode-go overlays using vendor list pricing.
Pricing resolution and membership tests
tests/usage/usage-cost.test.ts
Tests five OpenCode Go model resolutions, pricing-source caveats, qwen3.8-flash request-cost estimation, and the increase from 121 to 126 overlay keys.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to c0e71

The added OpenCode Go model estimates are covered by resolution, membership, and cost-calculation tests, with no concrete merge-blocking risk identified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding missing cost estimates for OpenCode Go models. It matches the pricing overlays and usage-cost test updates.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

⏳ DRAFT

  • review readiness checklist open (0/4 boxes ticked).

What to do

  • Tick all four boxes in the PR description once you're done (currently 0/4).

Review readiness checklist

  • ⬜ All CI tests are green on my local testing.
  • ⬜ I pushed my PR to the latest dev commit.
  • ⬜ I resolved all correct Codex and CodeRabbit findings.
  • ⬜ My PR is ready for review.

0/4 boxes ticked.

Automatic draft conversion failed. Please convert this pull request to a draft manually until every box above is ticked.

@github-actions
github-actions Bot marked this pull request as draft September 17, 2026 09:32
@lidge-jun

Copy link
Copy Markdown
Owner

리뷰 · 우선순위 76 / 80

이 PR은 OpenCode Go로 실제로 나가는 다섯 모델 id의 Usage 추정 비용이 비어 보이던 구멍을 메운다. 대상 id는 qwen3.8-max, qwen3.8-flash, deepseek-v4.1-flash, glm-5.3-flash, muse-spark-1.3-contributor다. 지금 dev HEAD는 484dcf5c1(패키지 2.58.0, tip #4881 — L3 retry·admission·combo-recovery 플랜)이다. 바로 아래에는 #4865(어댑터 소유 재시도 전송을 request send budget에 청구), #4894(providers 문서에서 transientRetryOn5xx가 안 닿는 곳), 그리고 이전 tip이던 #4880 L4 / #4879 L6 플랜이 있다. 이 PR의 base는 a1fe84b31라 tip보다 docs·어댑터 3커밋 뒤다. 건드리는 파일은 src/usage/expected-prices.tstests/usage/usage-cost.test.ts뿐이라 #4865/#4881과 코드 충돌 가능성은 낮다. types.ts/config.ts 분할 캠페인과도 무관하다. draft이고 readiness 체크리스트가 아직 비어 있다.

증상은 Usage 화면에서 추정 비용이 ~$0이나 대시(—)로 보이는 것이다. 요청은 opencode-go로 잘 나갔고 토큰도 쌓이는데, 모델별 비용 칸만 비었다. 원인은 가격 찾기 순서에 있다. resolveMatchedPrice는 사용자 오버레이 → jawcode 번들(해당 프로바이더) → EXPECTED_PRICE_OVERLAYS → jawcode 모델 단위 vendor fallback 순이다. vendor fallback은 jawcode 메타데이터만 보고, expected-price 오버레이는 절대 빌려 쓰지 않는다. 이 다섯 id는 opencode-go jawcode 번들 행이 없고, 모델 단위 fallback에도 안 걸린다. 그래서 resolveMatchedPrice("opencode-go", …)가 null을 돌려주고, 기존 GUI의 estimatedCostUsd 경로는 숫자 대신 빈 값을 그렸다. GUI를 고칠 필요는 없다. 가격 표에 행만 생기면 같은 렌더가 숫자를 보여 준다.

고치는 방식은 데이터다. EXPECTED_PRICE_OVERLAYSopencode-go/<model> 정확한 다섯 행을 넣는다. 각 행은 벤더가 공개한 리스트 가격을 그대로 쓴다. Go 자체는 구독 과금이라 상태 표기는 verified-derived다. 이미 z.ai Coding Plan·Devin 같은 구독 표면에 리스트 가격을 추정으로 붙이던 규칙과 같다. Qwen3.8-Max는 tip에 이미 있는 QWEN38_MAX(2/6, cache 0)를 재사용하고, Qwen3.8-Flash는 새 상수 QWEN38_FLASH(0.16/0.47, cache 0)를 만든다. DeepSeek V4.1-Flash는 피크 창(베이징 09:30–24:00) 리스트 0.30/1.20·cache-hit 0.006을 쓰고, 오프피크 할인은 넣지 않는다(Devin 기간 한정 프로모와 같은 규칙). GLM 5.3 Flash는 tip의 GLM_53_FLASH를, Muse Spark Contributor는 META_MUSE_SPARK_13_CONTRIBUTOR를 재사용한다. PR 본문 예시(qwen3.8-flash · 1.7k input)는 이전 — → 이후 약 $0.0003이다.

테스트도 가격 경로에 맞춰 있다. 새 케이스 17h가 다섯 id의 resolveMatchedPricecost4·source: "expected"·verified-derived인지 확인하고, Flash 행 sourceRef에 「cache rates unpublished」/「off-peak」 문구가 남는지, estimateRequestCost end-to-end가 1.7k × 0.16 / 1e6인지까지 본다. 멤버십 카운트는 tip의 121 → 126으로 올리고, 기대 키 목록에 다섯 opencode-go/…를 넣었다. PR 작성자 기준으로 usage-cost.test.ts 98 pass, typecheck clean, tests/usage는 695 pass / 1 fail인데 그 한 건(usage-summary intraday endpoints)은 이 변경 없는 clean tree에서도 난다고 한다. GUI/스크린샷은 해당 없음이 맞다. tip의 오버레이 행 수도 아직 121이라, tip rebase 후에도 126 카운트 가정이 그대로 성립한다.

주의할 점은 세 가지다. 첫째, base가 tip보다 뒤라 exact-head CI 전에 tip(484dcf5c1)에 맞춰야 한다. 둘째, draft + readiness 체크리스트 미완료라 지금 merge gate는 BLOCKED다. 셋째, DEEPSEEK_PRICING 소스 문자열은 아직 「V4 Flash alias transition scheduled 2026-07-24」를 품고 있는데, 이번 행은 V4.1-Flash다. 동작은 문제 없고, 출처 문장만 조금 낡았다. 캐시·오프피크를 고의로 비운 선택은 테스트로 잠가 두었으니 유지하는 편이 맞다.

라인 src/usage/expected-prices.ts (신규 DEEPSEEK_V41_FLASH) - 피크 창 0.30/1.20·cacheRead 0.006·cacheWrite 0. 오프피크는 주석·source에만 남기고 cost4에는 안 넣음.
라인 src/usage/expected-prices.ts (신규 QWEN38_FLASH/QWEN38_FLASH_PRICING) - 0.16/0.47, cache 0. Max와 같이 공개 cache 요금이 없어 리셀러 숫자를 빌리지 않음.
라인 src/usage/expected-prices.ts EXPECTED_PRICE_OVERLAYS (+5 opencode-go 행) - 전부 verified-derived. Max/Flash/DeepSeek/GLM/Muse Contributor. GUI 변경 없음.
라인 tests/usage/usage-cost.test.ts 테스트 17h - 다섯 id resolve + Flash sourceRef 문구 + estimateRequestCost 1.7k 토큰 합계.
라인 tests/usage/usage-cost.test.ts 테스트 16 - 멤버십 121→126과 기대 키 다섯 개 추가. tip도 아직 121이라 rebase 후에도 산술이 맞음.
경로 src/usage/cost.ts resolveMatchedPriceExact / resolveModelLevelPrice - 이번 PR이 안 고침. vendor fallback이 오버레이를 안 보는 계약이 그대로라, Go 전용 exact 오버레이가 맞는 수정임.

메인테이너의 판단이 필요한 지점

너의 추천
KEEP — tip(484dcf5c1)에 맞춘 뒤 exact-head CI(특히 tests/usage/usage-cost.test.ts)가 초록이고 draft·readiness를 닫으면 머지. 가격 데이터만의 작은 구멍 메우기라 types/config 분할에 무효화되지 않는다. 닫지 말고 랜딩한다. DeepSeek 소스 문자열 정리는 있으면 좋고 없어도 머지를 막지 않는다. GUI 스크린샷은 해당 없음.

이 댓글은 grok-bot이 작성했습니다

@agentHits
agentHits force-pushed the agentHits/opencode-go-cost branch from e67d11d to 9a69bef Compare September 17, 2026 10:50
agentHits added a commit to agentHits/opencodex that referenced this pull request Sep 17, 2026
@github-actions
github-actions Bot marked this pull request as ready for review September 17, 2026 11:44
Five opencode-go ids (qwen3.8-max, qwen3.8-flash, deepseek-v4.1-flash, glm-5.3-flash, muse-spark-1.3-contributor) have no jawcode bundle row and no vendor-level fallback, so the Usage estimated-cost column and per-model breakdown rendered an em dash for every request through them. Add exact provider/model expected-price overlays reusing each vendor published list price as a verified-derived estimate (Go itself is subscription-billed).
@agentHits
agentHits force-pushed the agentHits/opencode-go-cost branch from 9a69bef to 7195106 Compare September 17, 2026 14:30
@github-actions
github-actions Bot marked this pull request as draft September 17, 2026 14:31
@github-actions
github-actions Bot marked this pull request as ready for review September 17, 2026 14:31
@github-actions
github-actions Bot marked this pull request as draft September 17, 2026 18:52
@agentHits
agentHits marked this pull request as ready for review September 17, 2026 19:20
@github-actions
github-actions Bot marked this pull request as draft September 17, 2026 19:21
@agentHits

Copy link
Copy Markdown
Contributor Author

Hi @lidge-jun — flagging a CI infrastructure issue on this PR, not a code issue.

Facts on head c0e711fd: all lanes are green except two macOS jobs that never start — macos 1/2 and npm-global macos-latest have sat in queued since 18:48Z (checked again at 19:30Z, 40+ minutes, still queued, zero started). Everything else (~25 checks) passed.

Why it matters: the readiness gate and the freshness automation both require terminal check states before this PR can leave draft. As long as these two jobs hang in queue, the PR is stuck regardless of the code being green — the automation keeps logging "CI still running, waiting" every 30 minutes and cannot tick the checklist.

Could you take a look at the macOS runner availability / concurrency / queue configuration on your side? If those two lanes are not needed for this change (usage-price data + one test file), skipping them here would also unblock the PR. Thank you!

@lidge-jun
lidge-jun marked this pull request as ready for review September 17, 2026 19:44
@lidge-jun
lidge-jun merged commit 53d00cc into lidge-jun:dev Sep 17, 2026
31 checks passed
@agentHits
agentHits deleted the agentHits/opencode-go-cost branch September 17, 2026 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants