Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(codex): add GPT-6.1 Sol fallback and current model pricing (MUL-7834) (#8996)
mrlonelyba30324e10df
diff --git a/packages/views/runtimes/utils.test.ts b/packages/views/runtimes/utils.test.tsindex d532ee9d4f..f1f4c92c89 100644--- a/packages/views/runtimes/utils.test.ts+++ b/packages/views/runtimes/utils.test.ts@@ -317,14 +317,18 @@ describe("estimateCost", () => {).toBeCloseTo(1.75 + 14, 5);});- it("prices the gpt-5.6 series per OpenAI's official cache-aware rates", () => {+ it("prices current Codex models per OpenAI's official cache-aware rates", () => {// Official announcement rates. 5.6 is the first OpenAI generation to bill- // cache writes separately: cacheRead = 0.1x input, cacheWrite = 1.25x+ // cache writes separately: cacheRead generally = 0.1x input (GPT-6.1+ // Sol uses 0.05x), cacheWrite = 1.25x// input. Cover every model x every token category so a wrong cache rate// can't hide behind an input-only assertion. `total` is 1M of each of the// four categories priced at its own rate.const cases = [{ model: "gpt-6-astra", input: 10, cacheRead: 1, cacheWrite: 12.5, output: 50, total: 73.5 },+ { model: "gpt-6.1-sol", input: 2, cacheRead: 0.1, cacheWrite: 2.5, output: 10, total: 14.6 },+ { model: "gpt-6-sol", input: 2, cacheRead: 0.2, cacheWrite: 2.5, output: 10, total: 14.7 },+ { model: "gpt-6-luna", input: 0.1, cacheRead: 0.01, cacheWrite: 0.125, output: 0.5, total: 0.735 },{ model: "gpt-5.6-sol", input: 5, cacheRead: 0.5, cacheWrite: 6.25, output: 30, total: 41.75 },{ model: "gpt-5.6-terra", input: 2.5, cacheRead: 0.25, cacheWrite: 3.125, output: 15, total: 20.875 },{ model: "gpt-5.6-luna", input: 1, cacheRead: 0.1, cacheWrite: 1.25, output: 6, total: 8.35 },@@ -355,6 +359,13 @@ describe("estimateCost", () => {}});+ it("resolves current Codex routing prefixes and context tags", () => {+ for (const model of ["openai:gpt-6.1-sol", "openai/gpt-6.1-sol", "gpt-6.1-sol[1m]"]) {+ expect(isModelPriced(model, "codex")).toBe(true);+ expect(estimateCost({ ...zeroUsage, provider: "codex", model, cache_read_tokens: 1_000_000 })).toBeCloseTo(0.1, 5);+ }+ });+it("flags catalog SKUs without a published price (gpt-5.5-mini) as unmapped", () => {// `gpt-5.5-mini` is in the Codex catalog but OpenAI hasn't published a// public rate. We refuse to absorb it into `gpt-5.5` — the diagnostic@@ -383,6 +394,10 @@ describe("estimateCost", () => {expect(isModelPriced("gpt-5-6-sol")).toBe(false);expect(isModelPriced("gpt-6-astra")).toBe(true);expect(isModelPriced("gpt-6-astra-pro")).toBe(false);+ expect(isModelPriced("gpt-6.1-sol-pro")).toBe(false);+ expect(isModelPriced("gpt-6-1-sol")).toBe(false);+ expect(isModelPriced("gpt-6-sol-high")).toBe(false);+ expect(isModelPriced("gpt-6-luna-pro")).toBe(false);expect(estimateCost({...zeroUsage,diff --git a/packages/views/runtimes/utils.ts b/packages/views/runtimes/utils.tsindex bd6f590e6e..eb696bde5a 100644--- a/packages/views/runtimes/utils.ts+++ b/packages/views/runtimes/utils.ts@@ -189,9 +189,10 @@ export function formatUsd(n: number): string {// Moonshot, Zhipu and xAI do not bill cache writes separately (cached input// is just discounted on subsequent reads), so cacheWrite mirrors input there.// OpenAI historically did the same, but its GPT-5.6+ generation bills cache-// writes at 1.25× input (cache reads still get the 90% cached-input-// discount), so those rows carry a distinct cacheWrite. Codex usage doesn't-// yet stream cache-write tokens, so that rate isn't exercised today.+// writes at 1.25× input (cache reads generally get the 90% cached-input+// discount; GPT-6.1 Sol gets 95%), so those rows carry a distinct cacheWrite.+// Codex usage doesn't yet stream cache-write tokens, so that rate isn't+// exercised today.//// The resolver matches exact keys after stripping a trailing date snapshot// (see `resolvePricing` below). It deliberately does NOT do startsWith@@ -248,11 +249,16 @@ const MODEL_PRICING: Record<// `server/pkg/agent/models.go` (Codex provider list).// gpt-6-astra and gpt-5.6 (sol/terra/luna) use OpenAI's official rates.// 5.6+ is the first OpenAI generation to bill cache writes separately:- // cacheRead = 0.1x input (90% cached-input discount), cacheWrite = 1.25x+ // cacheRead generally = 0.1x input, cacheWrite = 1.25x// input (see the header note above). Codex usage doesn't yet report// cache-write tokens, so cacheWrite isn't exercised today, but the rate// is kept correct for when it is."gpt-6-astra": { input: 10, output: 50, cacheRead: 1.00, cacheWrite: 12.50 },+ // Standard short-context rates: developers.openai.com/api/docs/models/.+ // GPT-6.1 Sol's cached input is 0.05x input; GPT-6 Sol's is 0.1x.+ "gpt-6.1-sol": { input: 2, output: 10, cacheRead: 0.10, cacheWrite: 2.50 },+ "gpt-6-sol": { input: 2, output: 10, cacheRead: 0.20, cacheWrite: 2.50 },+ "gpt-6-luna": { input: 0.10, output: 0.50, cacheRead: 0.01, cacheWrite: 0.125 },"gpt-5.6-sol": { input: 5, output: 30, cacheRead: 0.50, cacheWrite: 6.25 },"gpt-5.6-terra": { input: 2.50, output: 15, cacheRead: 0.25, cacheWrite: 3.125 },"gpt-5.6-luna": { input: 1, output: 6, cacheRead: 0.10, cacheWrite: 1.25 },diff --git a/server/internal/metrics/pricing.go b/server/internal/metrics/pricing.goindex d57f5e94b8..c2e1f6d7fa 100644--- a/server/internal/metrics/pricing.go+++ b/server/internal/metrics/pricing.go@@ -24,12 +24,17 @@ var modelPrices = map[string]ModelPrice{// GPT-5.6 series and GPT-6 Astra (Codex `codex` provider). Official rates// from OpenAI's GPT-5.6 announcement (openai.com/index/previewing-gpt-5-6-sol)// and Astra's published $10 / $50. For 5.6+ (including Astra) cache read is- // the 90%-off cached-input rate (0.1x input) and cache write is billed at- // 1.25x the uncached input rate — unlike earlier OpenAI SKUs, which don't+ // generally the 90%-off cached-input rate (0.1x input). Cache write is billed+ // at 1.25x the uncached input rate — unlike earlier OpenAI SKUs, which don't// bill cache writes separately. Codex app-server v0.147 reports cache-write// input separately while including it in the raw input total; the collector// normalizes those into mutually exclusive billing buckets.- "openai:gpt-6-astra": {Provider: "openai", Model: "gpt-6-astra", InputPerM: 10.00, CacheReadPerM: 1.00, CacheWritePerM: 12.50, OutputPerM: 50.00},+ "openai:gpt-6-astra": {Provider: "openai", Model: "gpt-6-astra", InputPerM: 10.00, CacheReadPerM: 1.00, CacheWritePerM: 12.50, OutputPerM: 50.00},+ // Standard short-context rates from developers.openai.com/api/docs/models/.+ // GPT-6.1 Sol caches at 0.05x input, not GPT-6 Sol's 0.1x.+ "openai:gpt-6.1-sol": {Provider: "openai", Model: "gpt-6.1-sol", InputPerM: 2.00, CacheReadPerM: 0.10, CacheWritePerM: 2.50, OutputPerM: 10.00},+ "openai:gpt-6-sol": {Provider: "openai", Model: "gpt-6-sol", InputPerM: 2.00, CacheReadPerM: 0.20, CacheWritePerM: 2.50, OutputPerM: 10.00},+ "openai:gpt-6-luna": {Provider: "openai", Model: "gpt-6-luna", InputPerM: 0.10, CacheReadPerM: 0.01, CacheWritePerM: 0.125, OutputPerM: 0.50},"openai:gpt-5.6-sol": {Provider: "openai", Model: "gpt-5.6-sol", InputPerM: 5.00, CacheReadPerM: 0.50, CacheWritePerM: 6.25, OutputPerM: 30.00},"openai:gpt-5.6-terra": {Provider: "openai", Model: "gpt-5.6-terra", InputPerM: 2.50, CacheReadPerM: 0.25, CacheWritePerM: 3.125, OutputPerM: 15.00},"openai:gpt-5.6-luna": {Provider: "openai", Model: "gpt-5.6-luna", InputPerM: 1.00, CacheReadPerM: 0.10, CacheWritePerM: 1.25, OutputPerM: 6.00},@@ -144,6 +149,9 @@ var modelAliasRules = []struct {// utils.ts does NOT dash-normalize, so a dashed `gpt-5-6-luna` must surface// as unmapped on both sides rather than silently borrowing a tier here.{regexp.MustCompile(`(^|/|:)gpt-6-astra$`), "openai:gpt-6-astra"},+ {regexp.MustCompile(`(^|/|:)gpt-6\.1-sol$`), "openai:gpt-6.1-sol"},+ {regexp.MustCompile(`(^|/|:)gpt-6-sol$`), "openai:gpt-6-sol"},+ {regexp.MustCompile(`(^|/|:)gpt-6-luna$`), "openai:gpt-6-luna"},{regexp.MustCompile(`(^|/|:)gpt-5\.6-sol$`), "openai:gpt-5.6-sol"},{regexp.MustCompile(`(^|/|:)gpt-5\.6-terra$`), "openai:gpt-5.6-terra"},{regexp.MustCompile(`(^|/|:)gpt-5\.6-luna$`), "openai:gpt-5.6-luna"},diff --git a/server/internal/metrics/pricing_test.go b/server/internal/metrics/pricing_test.goindex dc20548e28..4e780cae09 100644--- a/server/internal/metrics/pricing_test.go+++ b/server/internal/metrics/pricing_test.go@@ -58,7 +58,7 @@ func TestPriceForModelAliasAnthropicCurrentGeneration(t *testing.T) {}}-func TestPriceForModelAliasCodexGPT56(t *testing.T) {+func TestPriceForModelAliasCodexCurrentGeneration(t *testing.T) {// Official rates from OpenAI's GPT-5.6 announcement: cache read = 0.1x// input (90% cached-input discount), cache write = 1.25x input.cases := []struct {@@ -73,6 +73,22 @@ func TestPriceForModelAliasCodexGPT56(t *testing.T) {model: "gpt-5.6-sol",want: ModelPrice{Provider: "openai", Model: "gpt-5.6-sol", InputPerM: 5, CacheReadPerM: 0.5, CacheWritePerM: 6.25, OutputPerM: 30},},+ {+ model: "gpt-6.1-sol",+ want: ModelPrice{Provider: "openai", Model: "gpt-6.1-sol", InputPerM: 2, CacheReadPerM: 0.1, CacheWritePerM: 2.5, OutputPerM: 10},+ },+ {+ model: "openai:gpt-6.1-sol[1m]",+ want: ModelPrice{Provider: "openai", Model: "gpt-6.1-sol", InputPerM: 2, CacheReadPerM: 0.1, CacheWritePerM: 2.5, OutputPerM: 10},+ },+ {+ model: "openai:gpt-6-sol",+ want: ModelPrice{Provider: "openai", Model: "gpt-6-sol", InputPerM: 2, CacheReadPerM: 0.2, CacheWritePerM: 2.5, OutputPerM: 10},+ },+ {+ model: "openai/gpt-6-luna",+ want: ModelPrice{Provider: "openai", Model: "gpt-6-luna", InputPerM: 0.1, CacheReadPerM: 0.01, CacheWritePerM: 0.125, OutputPerM: 0.5},+ },{model: "openai:gpt-5.6-terra",want: ModelPrice{Provider: "openai", Model: "gpt-5.6-terra", InputPerM: 2.5, CacheReadPerM: 0.25, CacheWritePerM: 3.125, OutputPerM: 15},@@ -100,6 +116,10 @@ func TestPriceForModelAliasCodexGPT56(t *testing.T) {// sides surface these as unmapped instead of silently pricing them.for _, model := range []string{"gpt-6-astra-pro",+ "gpt-6.1-sol-pro",+ "gpt-6-1-sol",+ "gpt-6-sol-high",+ "gpt-6-luna-pro","gpt-6-astra/unknown","gpt-6-astra-high","gpt-5.6-luna-pro",diff --git a/server/pkg/agent/models.go b/server/pkg/agent/models.goindex f0dedff6a6..e32dcbbd29 100644--- a/server/pkg/agent/models.go+++ b/server/pkg/agent/models.go@@ -602,8 +602,8 @@ func claudeStaticModels() []Model {// codexStaticModels is the fallback for Codex versions older than 0.122.0// and for failed/malformed live and bundled discovery calls. It lists the// visible entries of the newest locally verified live catalog — which can run-// ahead of the bundled one (gpt-6-sol and gpt-6-luna were live-only on-// codex-cli 0.155.1) — plus still-common models from older Codex releases.+// ahead of the bundled one (gpt-6.1-sol was live-only on codex-cli 0.159.0)+// — plus still-common models from older Codex releases.// Each entry carries its own reasoning catalog so old/offline CLIs retain the// same model + thinking picker contract as dynamic discovery. Service tiers are// intentionally NOT guessed here: they are runtime/version/account-sensitive,@@ -647,6 +647,7 @@ func codexStaticModels() []Model {}return []Model{{ID: "gpt-6-astra", Label: "GPT-6 Astra", Provider: "openai", Default: true, Thinking: standardThinking("low", true, true)},+ {ID: "gpt-6.1-sol", Label: "GPT-6.1 Sol", Provider: "openai", Thinking: standardThinking("low", true, true)},{ID: "gpt-6-sol", Label: "GPT-6 Sol", Provider: "openai", Thinking: standardThinking("medium", true, true)},{ID: "gpt-6-luna", Label: "GPT-6 Luna", Provider: "openai", Thinking: standardThinking("medium", true, false)},{ID: "gpt-5.6-sol", Label: "GPT-5.6 Sol", Provider: "openai", Thinking: standardThinking("low", true, true)},diff --git a/server/pkg/agent/thinking.go b/server/pkg/agent/thinking.goindex 30b024bef1..6135edb896 100644--- a/server/pkg/agent/thinking.go+++ b/server/pkg/agent/thinking.go@@ -430,6 +430,8 @@ func normalizeCodexModelLabel(id, label string) string {switch id {case "gpt-6-astra":return "GPT-6 Astra"+ case "gpt-6.1-sol":+ return "GPT-6.1 Sol"case "gpt-6-sol":return "GPT-6 Sol"case "gpt-6-luna":diff --git a/server/pkg/agent/thinking_test.go b/server/pkg/agent/thinking_test.goindex 9f2099c587..70a866e2f3 100644--- a/server/pkg/agent/thinking_test.go+++ b/server/pkg/agent/thinking_test.go@@ -294,6 +294,14 @@ func TestParseCodexModelCatalog(t *testing.T) {"display_name": "GPT-6-Astra","visibility": "list","supported_reasoning_levels": []+ },+ {+ "slug": "gpt-6.1-sol",+ "display_name": "GPT-6.1-Sol",+ "visibility": "list",+ "default_reasoning_level": "low",+ "supported_reasoning_levels": [{"effort": "low"}, {"effort": "max"}, {"effort": "ultra"}],+ "service_tiers": [{"id": "priority", "name": "Fast", "description": "2x speed, increased usage"}]}]}`)@@ -301,8 +309,8 @@ func TestParseCodexModelCatalog(t *testing.T) {if err != nil {t.Fatalf("parseCodexModelCatalog: %v", err)}- if len(got) != 5 {- t.Fatalf("expected five visible models, got %+v", got)+ if len(got) != 6 {+ t.Fatalf("expected six visible models, got %+v", got)}if got[0].ID != "gpt-5.6-sol" || got[0].Label != "GPT-5.6 Sol" || !got[0].Default {t.Errorf("unexpected first model: %+v", got[0])@@ -315,6 +323,7 @@ func TestParseCodexModelCatalog(t *testing.T) {{"gpt-5.6-terra", "GPT-5.6 Terra"},{"gpt-5.6-luna", "GPT-5.6 Luna"},{"gpt-6-astra", "GPT-6 Astra"},+ {"gpt-6.1-sol", "GPT-6.1 Sol"},} {var found *Modelfor i := range got {@@ -340,6 +349,9 @@ func TestParseCodexModelCatalog(t *testing.T) {if got[3].ID != "no-reasoning" || got[3].Thinking != nil {t.Errorf("model without reasoning should remain selectable without a thinking picker: %+v", got[3])}+ if got[5].Thinking == nil || got[5].Thinking.DefaultLevel != "low" || !hasThinkingLevel(got[5].Thinking, "ultra") || len(got[5].ServiceTiers) != 1 || got[5].ServiceTiers[0].ID != "priority" {+ t.Errorf("GPT-6.1 Sol must preserve runtime capabilities: %+v", got[5])+ }}// Codex reports the GPT-6 family as "GPT-6-Sol" and so on (codex-cli 0.155.1@@ -350,9 +362,18 @@ func TestNormalizeCodexModelLabelMatchesStaticGPT6Family(t *testing.T) {static := map[string]string{}for _, m := range codexStaticModels() {static[m.ID] = m.Label+ if m.ID == "gpt-6.1-sol" {+ if m.Thinking == nil || m.Thinking.DefaultLevel != "low" || len(m.Thinking.SupportedLevels) != 6 || !hasThinkingLevel(m.Thinking, "max") || !hasThinkingLevel(m.Thinking, "ultra") {+ t.Errorf("GPT-6.1 Sol fallback must match the observed live efforts: %+v", m.Thinking)+ }+ if m.Default || len(m.ServiceTiers) != 0 {+ t.Errorf("new fallback must not change the default or guess service tiers: %+v", m)+ }+ }}for id, reported := range map[string]string{"gpt-6-astra": "GPT-6-Astra",+ "gpt-6.1-sol": "GPT-6.1-Sol","gpt-6-sol": "GPT-6-Sol","gpt-6-luna": "GPT-6-Luna",} {