Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(runtimes): price Claude Opus 5.5 at its own tier (#8808)
Bohan Jiangff8b28549780
diff --git a/packages/views/runtimes/utils.test.ts b/packages/views/runtimes/utils.test.tsindex 8d78d317cf..d532ee9d4f 100644--- a/packages/views/runtimes/utils.test.ts+++ b/packages/views/runtimes/utils.test.ts@@ -265,6 +265,30 @@ describe("estimateCost", () => {}});+ it("prices Opus 5.5 at its own 4/20 tier with 0.05x cache reads, not Opus 5's", () => {+ // Opus 5.5 is cheaper than Opus 5 ($4 / $20, $5 cache write) and prices+ // cache reads at 0.05x input ($0.20) instead of the usual 0.1x. Copilot+ // reports it dotted, so every spelling must reach the 5.5 row.+ for (const model of [+ "claude-opus-5-5",+ "claude-opus-5-5[1m]",+ "claude-opus-5.5",+ "anthropic/claude-opus-5-5",+ ]) {+ expect(+ estimateCost({+ ...zeroUsage,+ model,+ input_tokens: 1_000_000,+ output_tokens: 1_000_000,+ cache_read_tokens: 1_000_000,+ cache_write_tokens: 1_000_000,+ }),+ ).toBeCloseTo(4 + 20 + 0.2 + 5, 5);+ expect(isModelPriced(model)).toBe(true);+ }+ });+it("prices each dotted Codex catalog SKU at its own tier, not gpt-5", () => {// Every dotted minor version is priced independently. The resolver does// exact-match-after-date-strip (no startsWith fallback), so each rowdiff --git a/packages/views/runtimes/utils.ts b/packages/views/runtimes/utils.tsindex 472de94aa8..bd6f590e6e 100644--- a/packages/views/runtimes/utils.ts+++ b/packages/views/runtimes/utils.ts@@ -218,10 +218,12 @@ const MODEL_PRICING: Record<// no future-dated pricing support yet, so update the row when the// post-intro $3 / $15 rate takes effect. Fable 5 and 5.1 are Mythos-class// SKUs at 10/50 (5.1 prices cache reads at 0.025x input, a quarter of the- // usual 0.1x); Opus 4.5 through Opus 5 stay on the lower 5/25 Opus tier. --+ // usual 0.1x); Opus 4.5 through Opus 5 stay on the lower 5/25 Opus tier,+ // and Opus 5.5 drops to 4/20 (cache reads at 0.05x input). --"claude-sonnet-5": { input: 2, output: 10, cacheRead: 0.20, cacheWrite: 2.50 },"claude-fable-5-1": { input: 10, output: 50, cacheRead: 0.25, cacheWrite: 12.50 },"claude-fable-5": { input: 10, output: 50, cacheRead: 1.00, cacheWrite: 12.50 },+ "claude-opus-5-5": { input: 4, output: 20, cacheRead: 0.20, cacheWrite: 5.00 },"claude-opus-5": { input: 5, output: 25, cacheRead: 0.50, cacheWrite: 6.25 },"claude-haiku-4-5": { input: 1, output: 5, cacheRead: 0.10, cacheWrite: 1.25 },"claude-sonnet-4-5": { input: 3, output: 15, cacheRead: 0.30, cacheWrite: 3.75 },diff --git a/server/internal/metrics/pricing.go b/server/internal/metrics/pricing.goindex 258c03045e..d57f5e94b8 100644--- a/server/internal/metrics/pricing.go+++ b/server/internal/metrics/pricing.go@@ -44,6 +44,7 @@ var modelPrices = map[string]ModelPrice{"anthropic:claude-sonnet-5": {Provider: "anthropic", Model: "claude-sonnet-5", InputPerM: 2.00, CacheReadPerM: 0.20, CacheWritePerM: 2.50, OutputPerM: 10.00},"anthropic:claude-fable-5-1": {Provider: "anthropic", Model: "claude-fable-5-1", InputPerM: 10.00, CacheReadPerM: 0.25, CacheWritePerM: 12.50, OutputPerM: 50.00},"anthropic:claude-fable-5": {Provider: "anthropic", Model: "claude-fable-5", InputPerM: 10.00, CacheReadPerM: 1.00, CacheWritePerM: 12.50, OutputPerM: 50.00},+ "anthropic:claude-opus-5-5": {Provider: "anthropic", Model: "claude-opus-5-5", InputPerM: 4.00, CacheReadPerM: 0.20, CacheWritePerM: 5.00, OutputPerM: 20.00},"anthropic:claude-opus-5": {Provider: "anthropic", Model: "claude-opus-5", InputPerM: 5.00, CacheReadPerM: 0.50, CacheWritePerM: 6.25, OutputPerM: 25.00},"anthropic:claude-opus-4.8": {Provider: "anthropic", Model: "claude-opus-4.8", InputPerM: 5.00, CacheReadPerM: 0.50, CacheWritePerM: 6.25, OutputPerM: 25.00},"anthropic:claude-opus-4.7": {Provider: "anthropic", Model: "claude-opus-4.7", InputPerM: 5.00, CacheReadPerM: 0.50, CacheWritePerM: 6.25, OutputPerM: 25.00},@@ -158,7 +159,12 @@ var modelAliasRules = []struct {// (claudeVersionEnd) so neither can swallow the other's ids.{regexp.MustCompile(`claude-fable-5[-.]1` + claudeVersionEnd), "anthropic:claude-fable-5-1"},{regexp.MustCompile(`claude-fable-5` + claudeVersionEnd), "anthropic:claude-fable-5"},- {regexp.MustCompile(`claude-opus-5`), "anthropic:claude-opus-5"},+ // Opus 5.5 is cheaper than Opus 5 ($4 / $20) and prices cache reads at+ // 0.05x input, so the two need separate rows. Both rules end at their own+ // version (claudeVersionEnd), the same as the Fable pair above, so the+ // Opus 5 rule cannot swallow 5.5 ids and bill them at Opus 5 rates.+ {regexp.MustCompile(`claude-opus-5[-.]5` + claudeVersionEnd), "anthropic:claude-opus-5-5"},+ {regexp.MustCompile(`claude-opus-5` + claudeVersionEnd), "anthropic:claude-opus-5"},{regexp.MustCompile(`claude-opus-4[-.]8`), "anthropic:claude-opus-4.8"},{regexp.MustCompile(`claude-opus-4[-.]7`), "anthropic:claude-opus-4.7"},{regexp.MustCompile(`claude-opus-4[-.]6`), "anthropic:claude-opus-4.6"},diff --git a/server/internal/metrics/pricing_test.go b/server/internal/metrics/pricing_test.goindex 71eba8e8d3..dc20548e28 100644--- a/server/internal/metrics/pricing_test.go+++ b/server/internal/metrics/pricing_test.go@@ -496,3 +496,61 @@ func TestPriceForModelAliasAnthropicFable51(t *testing.T) {}}}++func TestPriceForModelAliasAnthropicOpus55(t *testing.T) {+ // Opus 5.5 is its own SKU at $4 / $20 with cache reads at 0.05x input+ // ($0.20). An Opus 5 alias that did not stop at the version would swallow+ // the `-5` suffix and bill 5.5 at Opus 5's 5/25 tier, so every spelling+ // below must land on the Opus 5.5 row specifically.+ opus55 := ModelPrice{Provider: "anthropic", Model: "claude-opus-5-5", InputPerM: 4, CacheReadPerM: 0.2, CacheWritePerM: 5, OutputPerM: 20}+ opus5 := ModelPrice{Provider: "anthropic", Model: "claude-opus-5", InputPerM: 5, CacheReadPerM: 0.5, CacheWritePerM: 6.25, OutputPerM: 25}+ cases := []struct {+ model string+ want ModelPrice+ }{+ {model: "claude-opus-5-5", want: opus55},+ {model: "anthropic/claude-opus-5-5", want: opus55},+ {model: "anthropic:claude-opus-5-5", want: opus55},+ // Copilot reports Claude models dotted.+ {model: "claude-opus-5.5", want: opus55},+ // Claude Code reports the 1M-context variant with a bracketed suffix.+ {model: "claude-opus-5-5[1m]", want: opus55},+ {model: "claude-opus-5-5-20260901", want: opus55},+ {model: "claude-opus-5-5-latest", want: opus55},+ {model: "claude-opus-5-5-20260901[1m]", want: opus55},+ // Opus 5 must keep resolving to its own row in every suffix form the+ // frontend resolver also strips.+ {model: "claude-opus-5", want: opus5},+ {model: "claude-opus-5[1m]", want: opus5},+ {model: "claude-opus-5-20260401", want: opus5},+ {model: "claude-opus-5-latest", want: opus5},+ }++ for _, tc := range cases {+ got, ok := PriceForModelAlias(tc.model)+ if !ok {+ t.Fatalf("PriceForModelAlias(%q) did not resolve", tc.model)+ }+ if got != tc.want {+ t.Fatalf("PriceForModelAlias(%q) = %+v, want %+v", tc.model, got, tc.want)+ }+ }++ // Another Opus 5 minor is a distinct SKU at an unknown rate: it must stay+ // unmapped rather than borrow Opus 5's or 5.5's tier, matching the+ // frontend's exact-key lookup.+ for _, model := range []string{+ "claude-opus-5-1",+ "claude-opus-5.6",+ "claude-opus-5-55",+ "claude-opus-5-5x",+ "claude-opus-5-5-latest-preview",+ "claude-opus-5-5[1m]junk",+ "claude-opus-5[1m][2m]",+ "claude-opus-5-5[1m][2m]",+ } {+ if got, ok := PriceForModelAlias(model); ok {+ t.Errorf("PriceForModelAlias(%q) resolved to %+v; want unmapped", model, got)+ }+ }+}