Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(agent): advertise grok-4.6 thinking levels and published rates [MUL-6549] (#7406)
zyzyhbz179761a325be
diff --git a/packages/views/runtimes/utils.test.ts b/packages/views/runtimes/utils.test.tsindex 277cf7c1d6..69ad1560a7 100644--- a/packages/views/runtimes/utils.test.ts+++ b/packages/views/runtimes/utils.test.ts@@ -503,6 +503,21 @@ describe("estimateCost", () => {).toBeCloseTo(8.3, 5);});+ it("prices grok-4.6 at xAI's short-context $2.00 / $6.00 tier with $0.50 cached input", () => {+ // grok-4.6 cached input is $0.50/1M, not grok-4.5's $0.30.+ // 1M input × $2.00 + 1M output × $6.00 + 1M cached-read × $0.50.+ expect(+ estimateCost({+ ...zeroUsage,+ provider: "xai",+ model: "grok-4.6",+ input_tokens: 1_000_000,+ output_tokens: 1_000_000,+ cache_read_tokens: 1_000_000,+ }),+ ).toBeCloseTo(8.5, 5);+ });+it("prices the rest of the published Grok catalog", () => {// grok-4.3 and the 4.20 snapshots share one $1.25 / $2.50 tier;// grok-build-0.1 is its own $1.00 / $2.00 row.diff --git a/packages/views/runtimes/utils.ts b/packages/views/runtimes/utils.tsindex 5cb5a5a96e..3a5b9ab991 100644--- a/packages/views/runtimes/utils.ts+++ b/packages/views/runtimes/utils.ts@@ -302,6 +302,7 @@ const MODEL_PRICING: Record<// `grok-composer-*` ships in the Grok Build catalog// (server/pkg/agent/models.go) but is absent from the price sheet; it// deliberately stays unmapped rather than inheriting a guessed rate. --+ "grok-4.6": { input: 2, output: 6, cacheRead: 0.50, cacheWrite: 2 },"grok-4.5": { input: 2, output: 6, cacheRead: 0.30, cacheWrite: 2 },"grok-4.3": { input: 1.25, output: 2.50, cacheRead: 0.20, cacheWrite: 1.25 },"grok-build-0.1": { input: 1, output: 2, cacheRead: 0.20, cacheWrite: 1 },diff --git a/server/internal/metrics/pricing.go b/server/internal/metrics/pricing.goindex 5a45722601..3b74eca738 100644--- a/server/internal/metrics/pricing.go+++ b/server/internal/metrics/pricing.go@@ -68,6 +68,7 @@ var modelPrices = map[string]ModelPrice{// packages/views/runtimes/utils.ts; keep the two tables in sync.// `grok-composer-*` ships in the Grok Build catalog but is absent from the// price sheet, so it stays unmapped rather than inheriting a guessed rate.+ "xai:grok-4.6": {Provider: "xai", Model: "grok-4.6", InputPerM: 2.00, CacheReadPerM: 0.50, CacheWritePerM: 2.00, OutputPerM: 6.00},"xai:grok-4.5": {Provider: "xai", Model: "grok-4.5", InputPerM: 2.00, CacheReadPerM: 0.30, CacheWritePerM: 2.00, OutputPerM: 6.00},"xai:grok-4.3": {Provider: "xai", Model: "grok-4.3", InputPerM: 1.25, CacheReadPerM: 0.20, CacheWritePerM: 1.25, OutputPerM: 2.50},"xai:grok-build-0.1": {Provider: "xai", Model: "grok-build-0.1", InputPerM: 1.00, CacheReadPerM: 0.20, CacheWritePerM: 1.00, OutputPerM: 2.00},@@ -117,6 +118,7 @@ var modelAliasRules = []struct {// rows above. The frontend resolver does not dash-normalize non-Anthropic// ids, so a dashed `grok-4-5` must surface as unmapped on both sides// rather than silently borrowing a tier here.+ {regexp.MustCompile(`(^|/|:)grok-4\.6$`), "xai:grok-4.6"},{regexp.MustCompile(`(^|/|:)grok-4\.5$`), "xai:grok-4.5"},{regexp.MustCompile(`(^|/|:)grok-4\.3$`), "xai:grok-4.3"},{regexp.MustCompile(`(^|/|:)grok-build-0\.1$`), "xai:grok-build-0.1"},diff --git a/server/internal/metrics/pricing_test.go b/server/internal/metrics/pricing_test.goindex 00616c499a..f9a7d478ba 100644--- a/server/internal/metrics/pricing_test.go+++ b/server/internal/metrics/pricing_test.go@@ -118,6 +118,14 @@ func TestPriceForModelAliasGrok(t *testing.T) {model stringwant ModelPrice}{+ {+ model: "grok-4.6",+ want: ModelPrice{Provider: "xai", Model: "grok-4.6", InputPerM: 2, CacheReadPerM: 0.5, CacheWritePerM: 2, OutputPerM: 6},+ },+ {+ model: "xai:grok-4.6",+ want: ModelPrice{Provider: "xai", Model: "grok-4.6", InputPerM: 2, CacheReadPerM: 0.5, CacheWritePerM: 2, OutputPerM: 6},+ },{model: "grok-4.5",want: ModelPrice{Provider: "xai", Model: "grok-4.5", InputPerM: 2, CacheReadPerM: 0.3, CacheWritePerM: 2, OutputPerM: 6},@@ -170,6 +178,8 @@ func TestPriceForModelAliasGrok(t *testing.T) {for _, model := range []string{"grok-composer-2.5-fast","grok-composer-2.5",+ "grok-4.6-fast",+ "grok-4-6","grok-4.5-fast","grok-4-5","grok-4.20-0309",diff --git a/server/pkg/agent/grok_test.go b/server/pkg/agent/grok_test.goindex 93bff8d7a8..e8f73b8686 100644--- a/server/pkg/agent/grok_test.go+++ b/server/pkg/agent/grok_test.go@@ -77,7 +77,7 @@ while IFS= read -r line; doprintf '{"jsonrpc":"2.0","id":%s,"error":{"code":-32000,"message":"authenticate must complete first"}}\n' "$id"exit 0fi- printf '{"jsonrpc":"2.0","id":%s,"result":{"sessionId":"ses_new","models":{"availableModels":[{"modelId":"grok-4.5","name":"Grok 4.5","description":""},{"modelId":"grok-composer-2.5-fast","name":"Grok Composer 2.5 Fast","description":""}],"currentModelId":"grok-4.5"}}}\n' "$id"+ printf '{"jsonrpc":"2.0","id":%s,"result":{"sessionId":"ses_new","models":{"availableModels":[{"modelId":"grok-4.6","name":"Grok 4.6","description":""},{"modelId":"grok-4.5","name":"Grok 4.5","description":""},{"modelId":"grok-composer-2.5-fast","name":"Grok Composer 2.5 Fast","description":""}],"currentModelId":"grok-4.6"}}}\n' "$id";;*'"method":"session/load"'*)if [ -z "$authenticated" ]; then@@ -109,7 +109,7 @@ while IFS= read -r line; doif [ -n "$GROK_USAGE" ]; then# Match live Grok Build ACP (0.2.x): metering lives under result._meta,# not a top-level usage field or sessionUpdate=usage_update.- printf '{"jsonrpc":"2.0","id":%s,"result":{"stopReason":"end_turn","_meta":{"sessionId":"ses_new","modelId":"grok-4.5","inputTokens":120,"outputTokens":30,"cachedReadTokens":20,"cachedWriteTokens":5,"usage":{"inputTokens":120,"outputTokens":30,"totalTokens":150,"cachedReadTokens":20,"cachedWriteTokens":5,"modelCalls":1,"costUsdTicks":98765}}}}\n' "$id"+ printf '{"jsonrpc":"2.0","id":%s,"result":{"stopReason":"end_turn","_meta":{"sessionId":"ses_new","modelId":"grok-4.6","inputTokens":120,"outputTokens":30,"cachedReadTokens":20,"cachedWriteTokens":5,"usage":{"inputTokens":120,"outputTokens":30,"totalTokens":150,"cachedReadTokens":20,"cachedWriteTokens":5,"modelCalls":1,"costUsdTicks":98765}}}}\n' "$id"elseprintf '{"jsonrpc":"2.0","id":%s,"result":{"stopReason":"end_turn"}}\n' "$id"fi@@ -606,9 +606,9 @@ func TestGrokPropagatesMCPAndUsage(t *testing.T) {if !strings.Contains(requests, `"name":"fetch"`) || !strings.Contains(requests, `"command":"uvx"`) {t.Fatalf("session/new did not receive MCP server:\n%s", raw)}- usage, ok := result.Usage["grok-4.5"]+ usage, ok := result.Usage["grok-4.6"]if !ok {- t.Fatalf("usage missing grok-4.5 key: %+v", result.Usage)+ t.Fatalf("usage missing grok-4.6 key: %+v", result.Usage)}// The fixture's totalTokens (150) equals input + output, so its 20 cached// reads sit inside inputTokens and are billed once: input is stored as the@@ -663,9 +663,9 @@ func TestGrokAttributesUsageOnResumeWithoutConfiguredModel(t *testing.T) {if _, unknown := result.Usage["unknown"]; unknown {t.Fatalf("resumed usage fell back to the unpriced \"unknown\" bucket: %+v", result.Usage)}- usage, ok := result.Usage["grok-4.5"]+ usage, ok := result.Usage["grok-4.6"]if !ok {- t.Fatalf("usage missing grok-4.5 key: %+v", result.Usage)+ t.Fatalf("usage missing grok-4.6 key: %+v", result.Usage)}if usage.InputTokens != 100 || usage.OutputTokens != 30 || usage.CacheReadTokens != 20 || usage.CacheWriteTokens != 5 {t.Fatalf("unexpected usage: %+v", usage)@@ -750,9 +750,19 @@ func TestDiscoverGrokModelsWaitsForAdvertisedAuth(t *testing.T) {if err != nil {t.Fatalf("discover grok models: %v", err)}- if len(catalog.Models) != 2 || catalog.Models[0].ID != "grok-4.5" {+ if len(catalog.Models) != 3 || catalog.Models[0].ID != "grok-4.6" {t.Fatalf("unexpected models: %+v", catalog.Models)}+ if catalog.Models[0].Thinking == nil {+ t.Fatal("discovered grok-4.6 must advertise documented effort levels")+ }+ got := make([]string, 0, len(catalog.Models[0].Thinking.SupportedLevels))+ for _, level := range catalog.Models[0].Thinking.SupportedLevels {+ got = append(got, level.Value)+ }+ if strings.Join(got, ",") != "low,medium,high,xhigh" {+ t.Fatalf("discovered grok-4.6 levels = %v, want low/medium/high/xhigh", got)+ }if catalog.Fallback {t.Error("a successful ACP discovery must not be marked Fallback")}@@ -796,7 +806,7 @@ func TestDiscoverGrokModelsStopsOnAuthFailures(t *testing.T) {if err != nil {t.Fatalf("discover grok models: %v", err)}- if len(catalog.Models) != 2 || catalog.Models[0].ID != "grok-4.5" {+ if len(catalog.Models) != 3 || catalog.Models[0].ID != "grok-4.6" {t.Fatalf("expected static fallback, got %+v", catalog.Models)}if !catalog.Fallback {@@ -819,18 +829,29 @@ func TestDiscoverGrokModelsStopsOnAuthFailures(t *testing.T) {func TestGrokThinkingCatalogIsPerModel(t *testing.T) {models := grokStaticModels()- if models[0].Thinking == nil {- t.Fatal("grok-4.5 should advertise documented effort levels")+ if len(models) != 3 || models[0].ID != "grok-4.6" || !models[0].Default {+ t.Fatalf("static fallback must default to grok-4.6: %+v", models)}- got := make([]string, 0, len(models[0].Thinking.SupportedLevels))- for _, level := range models[0].Thinking.SupportedLevels {- got = append(got, level.Value)+ want := map[string]string{+ "grok-4.6": "low,medium,high,xhigh",+ "grok-4.5": "low,medium,high",}- if strings.Join(got, ",") != "low,medium,high" {- t.Fatalf("grok-4.5 levels = %v, want low/medium/high", got)+ for id, levels := range want {+ model := grokMustFindModel(t, models, id)+ if model.Thinking == nil {+ t.Fatalf("%s should advertise documented effort levels", id)+ }+ got := make([]string, 0, len(model.Thinking.SupportedLevels))+ for _, level := range model.Thinking.SupportedLevels {+ got = append(got, level.Value)+ }+ if strings.Join(got, ",") != levels {+ t.Fatalf("%s levels = %v, want %s", id, got, levels)+ }}- if models[1].Thinking != nil {- t.Fatalf("unverified composer model must hide thinking controls: %+v", models[1].Thinking)+ composer := grokMustFindModel(t, models, "grok-composer-2.5-fast")+ if composer.Thinking != nil {+ t.Fatalf("unverified composer model must hide thinking controls: %+v", composer.Thinking)}unknown := []Model{{ID: "future-grok", Label: "Future"}}annotateGrokThinking(unknown)@@ -845,6 +866,9 @@ func TestGrokValidateThinkingLevelUsesPerModelCatalog(t *testing.T) {level stringwant bool}{+ {model: "grok-4.6", level: "high", want: true},+ {model: "grok-4.6", level: "low", want: true},+ {model: "grok-4.6", level: "xhigh", want: true},{model: "grok-4.5", level: "low", want: true},{model: "grok-4.5", level: "none", want: false},{model: "grok-4.5", level: "xhigh", want: false},@@ -889,14 +913,25 @@ func TestGrokSelectAuthMethod(t *testing.T) {func TestGrokIsKnownThinkingValue(t *testing.T) {t.Parallel()- for _, level := range []string{"", "low", "medium", "high"} {+ for _, level := range []string{"", "low", "medium", "high", "xhigh"} {if !IsKnownThinkingValue("grok", level) {t.Errorf("IsKnownThinkingValue(grok, %q) = false", level)}}- for _, level := range []string{"none", "minimal", "xhigh", "bogus", "max"} {+ for _, level := range []string{"none", "minimal", "bogus", "max"} {if IsKnownThinkingValue("grok", level) {t.Errorf("IsKnownThinkingValue(grok, %q) = true, want rejected", level)}}}++func grokMustFindModel(t *testing.T, models []Model, id string) Model {+ t.Helper()+ for _, model := range models {+ if model.ID == id {+ return model+ }+ }+ t.Fatalf("model %q not in catalog: %+v", id, models)+ return Model{}+}diff --git a/server/pkg/agent/models.go b/server/pkg/agent/models.goindex fbd0ec2893..91f8ab0528 100644--- a/server/pkg/agent/models.go+++ b/server/pkg/agent/models.go@@ -2257,9 +2257,11 @@ func discoverGrokModels(ctx context.Context, runtimeCmd Command) (Catalog, error// grokStaticModels is the offline fallback catalog for the Grok Build CLI.// IDs match a typical signed-in `session/new` / `grok models` listing.+// Grok 4.6 is the current Grok Build default (xAI, 2026-08-12).func grokStaticModels() []Model {models := []Model{- {ID: "grok-4.5", Label: "Grok 4.5", Provider: "xai", Default: true},+ {ID: "grok-4.6", Label: "Grok 4.6", Provider: "xai", Default: true},+ {ID: "grok-4.5", Label: "Grok 4.5", Provider: "xai"},{ID: "grok-composer-2.5-fast", Label: "Grok Composer 2.5 Fast", Provider: "xai"},}annotateGrokThinking(models)@@ -2267,22 +2269,37 @@ func grokStaticModels() []Model {}// annotateGrokThinking attaches only capabilities confirmed by xAI's-// per-model reasoning documentation. session/new does not advertise effort-// catalogs, so unknown and composer models deliberately keep Thinking nil-// instead of exposing values that may fail at runtime.+// per-model reasoning documentation and Grok Build's `--effort` flag.+// session/new does not advertise effort catalogs on the versions this+// table covers, so unknown and composer models deliberately keep Thinking+// nil instead of exposing values that may fail at runtime.+//+// grok-4.6 documents and accepts `xhigh` (docs.x.ai/developers/grok-4-6,+// grok 1.0.5 `--effort`). grok-4.5 does not; the server enum lets the+// token through and ValidateThinkingLevel still fails it closed for 4.5.func annotateGrokThinking(models []Model) {for i := range models {- if models[i].ID != "grok-4.5" {- continue+ switch models[i].ID {+ case "grok-4.6":+ models[i].Thinking = grokThinkingCatalog(true)+ case "grok-4.5":+ models[i].Thinking = grokThinkingCatalog(false)}- models[i].Thinking = &ModelThinking{SupportedLevels: []ThinkingLevel{- {Value: "low", Label: "Low"},- {Value: "medium", Label: "Medium"},- {Value: "high", Label: "High"},- }}}}+func grokThinkingCatalog(includeXHigh bool) *ModelThinking {+ levels := []ThinkingLevel{+ {Value: "low", Label: "Low"},+ {Value: "medium", Label: "Medium"},+ {Value: "high", Label: "High"},+ }+ if includeXHigh {+ levels = append(levels, ThinkingLevel{Value: "xhigh", Label: "Extra high"})+ }+ return &ModelThinking{SupportedLevels: levels}+}+// discoverCursorModels runs `cursor-agent --list-models` and parses// the `id - Label` rows. Cursor's catalog changes often and ships// many variants of the same base model (thinking / fast / maxdiff --git a/server/pkg/agent/thinking.go b/server/pkg/agent/thinking.goindex b097c0f008..8418ab7f5e 100644--- a/server/pkg/agent/thinking.go+++ b/server/pkg/agent/thinking.go@@ -773,12 +773,15 @@ var providerThinkingEnums = map[string]map[string]bool{"xhigh": true,"max": true,},- // Grok 4.5's documented --effort levels. It cannot disable reasoning and- // does not accept none, minimal, or xhigh.+ // Grok CLI --effort vocabulary (grok 1.0.5: low, medium, high, xhigh).+ // Grok cannot disable reasoning and does not accept none, minimal, or+ // max. xhigh is grok-4.6-only; the daemon's per-model catalog rejects+ // it for grok-4.5 after this server-side literal gate."grok": {"low": true,"medium": true,"high": true,+ "xhigh": true,},// Pi owns a fixed CLI vocabulary; RPC discovery narrows this universe to// the exact subset supported by each model before execution.diff --git a/server/pkg/agent/thinking_test.go b/server/pkg/agent/thinking_test.goindex 8bb3399217..5114fec2cd 100644--- a/server/pkg/agent/thinking_test.go+++ b/server/pkg/agent/thinking_test.go@@ -523,9 +523,9 @@ func TestIsKnownThinkingValue(t *testing.T) {{"grok", "low", true},{"grok", "medium", true},{"grok", "high", true},+ {"grok", "xhigh", true},{"grok", "none", false},{"grok", "minimal", false},- {"grok", "xhigh", false},{"grok", "max", false},{"grok", "bogus", false},}