fix(opencode): add Claude model aliases for dot-notation version names#868
fix(opencode): add Claude model aliases for dot-notation version names#868sunmingyang666 wants to merge 1 commit intoryoppippi:mainfrom
Conversation
OpenCode uses dot notation for Claude version numbers (e.g. claude-opus-4.6), but LiteLLM uses hyphens (e.g. claude-opus-4-6). Without these aliases, cost calculation silently falls back to zero for all Claude models.
📝 WalkthroughWalkthroughAdded seven alias mappings for Claude model variants using hyphenated naming conventions to enable pricing lookups. The mappings translate dot-notation names (4.5, 4.6) to hyphenated forms (4-5, 4-6) while maintaining existing alias entries. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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. Comment |
Summary
OpenCode uses dot notation for Claude model version numbers (e.g.
claude-opus-4.6,claude-sonnet-4.5), but LiteLLM uses hyphens (e.g.claude-opus-4-6,claude-sonnet-4-5). This mismatch causes cost calculation to silently fall back to zero for all Claude models used through OpenCode.Problem
When OpenCode records usage for Claude models, the
modelIDstored in the database uses dot notation:claude-opus-4.6claude-sonnet-4.5claude-sonnet-4.6claude-opus-4.5claude-haiku-4.5However, LiteLLM's pricing dataset uses hyphen notation (
claude-opus-4-6,claude-sonnet-4-5, etc.). TheLiteLLMPricingFetcher.getModelPricing()method cannot find a match, so costs are reported as $0.Note:
github_copilot/claude-opus-4.6does exist in LiteLLM but withNaNpricing — this is a separate upstream issue. TheproviderIDfield in OpenCode is stored separately and is not used in the model name lookup, socreateMatchingCandidates()never constructs thegithub_copilot/prefixed name. Our aliases correctly map the bare model names.Changes
Added 5 Claude model aliases to
MODEL_ALIASESinapps/opencode/src/cost-utils.ts:claude-haiku-4.5claude-haiku-4-5claude-opus-4.5claude-opus-4-5claude-opus-4.6claude-opus-4-6claude-sonnet-4.5claude-sonnet-4-5claude-sonnet-4.6claude-sonnet-4-6Verification
pnpm --filter @ccusage/opencode run build)pnpm --filter @ccusage/opencode run test— 6/6)pnpm --filter @ccusage/opencode run lint)modelIDin OpenCode's SQLite DB is stored as bare name without provider prefixSummary by CodeRabbit