Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
MUL-7613: fix(agent): refresh live model catalogs (#8722)
Yincan Huang7be175346e7c
diff --git a/server/internal/daemon/model_qualify_test.go b/server/internal/daemon/model_qualify_test.goindex 940a175971..8a97fcec8f 100644--- a/server/internal/daemon/model_qualify_test.go+++ b/server/internal/daemon/model_qualify_test.go@@ -4,6 +4,10 @@ import ("context""io""log/slog"+ "os"+ "path/filepath"+ "runtime"+ "strings""sync""testing"@@ -214,3 +218,62 @@ func TestResolveTaskModelSelectionFailsOpenOnDiscoveryError(t *testing.T) {t.Errorf("catalog reads = %d, want 1 — a failed read must not be retried within the task", calls)}}++// Exercise real discovery through the daemon's task-launch guard rather than+// injecting a prebuilt fallback: live discovery fails, bundled succeeds but+// lacks the saved model. Model-scoped overrides pass through; the CLI-version+// gate for explicit standard routing must still reject old Codex binaries.+func TestResolveTaskModelSelectionKeepsLiveOnlyCodexOverridesOnFallback(t *testing.T) {+ if runtime.GOOS == "windows" {+ t.Skip("shell-script fake binary requires a POSIX shell")+ }+ for _, tc := range []struct {+ name, version string+ in, want taskModelSelection+ }{+ {+ name: "new CLI retains model-scoped overrides", version: "0.155.1",+ in: taskModelSelection{Model: "gpt-6-sol", ThinkingLevel: "high", ServiceTier: "priority"},+ want: taskModelSelection{Model: "gpt-6-sol", ThinkingLevel: "high", ServiceTier: "priority"},+ },+ {+ name: "old CLI rejects explicit standard despite missing model", version: "0.130.0",+ in: taskModelSelection{Model: "gpt-6-sol", ThinkingLevel: "high", ServiceTier: "default"},+ want: taskModelSelection{Model: "gpt-6-sol", ThinkingLevel: "high"},+ },+ {+ name: "new CLI accepts explicit standard despite missing model", version: "0.155.1",+ in: taskModelSelection{Model: "gpt-6-sol", ThinkingLevel: "high", ServiceTier: "default"},+ want: taskModelSelection{Model: "gpt-6-sol", ThinkingLevel: "high", ServiceTier: "default"},+ },+ } {+ t.Run(tc.name, func(t *testing.T) {+ dir := t.TempDir()+ logFile := filepath.Join(dir, "calls")+ binary := filepath.Join(dir, "codex")+ script := "#!/bin/sh\n" ++ "printf '%s\\n' \"$*\" >> '" + logFile + "'\n" ++ "if [ \"$1\" = \"--version\" ]; then echo 'codex-cli " + tc.version + "'; exit 0; fi\n" ++ "if [ \"$3\" = \"--bundled\" ]; then echo '{\"models\":[{\"slug\":\"gpt-5.5\",\"display_name\":\"GPT-5.5\",\"visibility\":\"list\"}]}'; exit 0; fi\n" ++ "exit 1\n"+ if err := os.WriteFile(binary, []byte(script), 0o700); err != nil {+ t.Fatal(err)+ }++ got := resolveTaskModelSelection(context.Background(), "codex", agent.Command{Path: binary}, tc.in, quietTaskLog())+ if got != tc.want {+ t.Fatalf("launch selection = %+v, want %+v", got, tc.want)+ }+ calls, err := os.ReadFile(logFile)+ if err != nil {+ t.Fatal(err)+ }+ if !strings.Contains(string(calls), "debug models\n") || !strings.Contains(string(calls), "debug models --bundled\n") {+ t.Fatalf("expected failed live discovery and successful bundled fallback, got %q", calls)+ }+ if strings.Count(string(calls), "debug models --bundled\n") != 1 {+ t.Fatalf("task capability checks must share a single fallback discovery: %q", calls)+ }+ })+ }+}diff --git a/server/pkg/agent/models.go b/server/pkg/agent/models.goindex b601341763..750a2e51b8 100644--- a/server/pkg/agent/models.go+++ b/server/pkg/agent/models.go@@ -189,7 +189,7 @@ func ListModels(ctx context.Context, providerType string, runtimeCmd Command) (C})case "codex":return cachedDiscovery(discoveryCacheKey(providerType, runtimeCmd), func() (Catalog, error) {- return discovered(discoverCodexModels(ctx, runtimeCmd), nil)+ return discoverCodexCatalog(ctx, runtimeCmd), nil})case "antigravity":// agy 1.0.6 added a `--model` flag plus an `agy models` catalog@@ -426,11 +426,12 @@ func ModelSelectionSupported(providerType string) bool {}// ModelKnownIncompatibleWithProvider reports whether a saved model is a known-// mismatch for a target runtime provider. For first-party providers with-// maintained static catalogs, compatibility is exact: the model must be one of-// the IDs that runtime advertises. Unknown/custom model strings still return-// false because the UI and CLI allow manual entries and the server should not-// erase values it cannot confidently classify.+// mismatch for a target runtime provider. Static catalogs are sufficient to+// recognize known-good IDs, but they are not allow-lists: Claude and Codex can+// gain same-family model IDs through live discovery without a Multica release.+// Unknown/custom model strings still return false because the UI and CLI allow+// manual entries and the server should not erase values it cannot confidently+// classify.func ModelKnownIncompatibleWithProvider(providerType, model string) bool {model = strings.TrimSpace(model)if model == "" {@@ -444,6 +445,17 @@ func ModelKnownIncompatibleWithProvider(providerType, model string) bool {if accepted[modelIDForCapabilityLookup(providerType, model)] {return false}+ lookupID := modelIDForCapabilityLookup(providerType, model)+ switch providerType {+ case "claude":+ if strings.HasPrefix(lookupID, "claude-") && !strings.ContainsAny(lookupID, "[]") {+ return false+ }+ case "codex":+ if strings.HasPrefix(lookupID, "gpt-") || isOpenAIReasoningSeriesID(lookupID) {+ return false+ }+ }return isRuntimeSpecificModelID(model)}@@ -584,7 +596,7 @@ func claudeStaticModels() []Model {}// codexStaticModels is the fallback for Codex versions older than 0.122.0-// and for failed/malformed `codex debug models --bundled` calls. Keep it in+// and for failed/malformed live and bundled discovery calls. Keep it in// sync with the visible entries in the newest locally verified bundled// catalog, plus still-common models from older Codex releases. Each entry// carries its own reasoning catalog so old/offline CLIs retain the same modeldiff --git a/server/pkg/agent/models_test.go b/server/pkg/agent/models_test.goindex 7a7bf7e515..9dfc68753b 100644--- a/server/pkg/agent/models_test.go+++ b/server/pkg/agent/models_test.go@@ -530,10 +530,10 @@ func TestModelKnownIncompatibleWithProvider(t *testing.T) {want: true,},{- name: "unknown claude base stays incompatible after context normalization",+ name: "future claude model stays compatible after context normalization",provider: "claude",- model: "claude-fake-9[1m]",- want: true,+ model: "claude-opus-5-5[1m]",+ want: false,},{name: "provider-prefixed openai model is incompatible with codex",@@ -548,10 +548,10 @@ func TestModelKnownIncompatibleWithProvider(t *testing.T) {want: true,},{- name: "known openai-looking model outside codex catalog is incompatible",+ name: "future codex model is not rejected by the static fallback catalog",provider: "codex",- model: "gpt-99",- want: true,+ model: "gpt-6-sol",+ want: false,},{name: "unknown custom model is not classified",diff --git a/server/pkg/agent/thinking.go b/server/pkg/agent/thinking.goindex 1375575477..e18d9428d0 100644--- a/server/pkg/agent/thinking.go+++ b/server/pkg/agent/thinking.go@@ -3,6 +3,7 @@ package agentimport ("context""encoding/json"+ "fmt""regexp""strings""sync"@@ -245,25 +246,24 @@ func projectClaudeLevels(superset []string, allow map[string]bool) []ThinkingLev// ── Codex ────────────────────────────────────────────────────────────//-// `codex debug models --bundled` is the structured discovery hook for the-// visible model catalog, each model's reasoning catalog, and service tiers. OpenAI added-// the command and `--bundled` flag together in Codex 0.122.0 (openai/codex-// #18625). Older versions, failed invocations, and malformed/empty payloads-// use codexStaticModels so the picker remains usable.+// `codex debug models` is the structured discovery hook for the live visible+// model catalog, each model's reasoning catalog, and service tiers. OpenAI+// added the command in Codex 0.122.0 (openai/codex #18625). Older versions,+// failed invocations, and malformed/empty payloads use the bundled catalog and+// then codexStaticModels so the picker remains usable offline.//// We prefer this over the older config-error probe trick because:// 1. It gives us per-model subsets without hand-maintained tables.// 2. The schema is structured and has been stable since its 0.122.0 debut.// 3. It doesn't pollute stderr with an intentional misconfiguration.//-// The subcommand emits JSON on stdout by default — there is no-// `--output json` flag (a prior version of this code passed one and-// silently failed on 0.131.0). We add `--bundled` to skip the network-// refresh: discovery runs on every daemon poll and a network hop here-// would block the picker behind whatever the user's connection allows.-// The bundled catalog is what determines which `model_reasoning_effort`-// tokens the local binary actually accepts, which is the only thing we-// need for validation.+// The subcommand emits JSON on stdout by default — there is no `--output json`+// flag (a prior version of this code passed one and silently failed on+// 0.131.0). The live form matters because Codex can receive new account-visible+// models without a CLI release; `--bundled` only reflects the binary's compiled+// snapshot. A failed live refresh falls back to `--bundled`, marked+// non-authoritative so neither daemon nor server caches pin it after the+// network recovers.//// The static fallback deliberately mirrors a recently verified bundled// model/thinking catalog. It does not guess service-tier availability.@@ -290,7 +290,7 @@ const ()// codexDebugModelsResponse mirrors the JSON shape emitted by-// `codex debug models --bundled` (Codex 0.122.0+). Only the fields we+// `codex debug models` (Codex 0.122.0+). Only the fields we// consume are typed; unknown keys are ignored.type codexDebugModelsResponse struct {Models []codexDebugModel `json:"models"`@@ -316,32 +316,50 @@ type codexDebugServiceTier struct {Description string `json:"description"`}-// discoverCodexModels returns the installed Codex binary's bundled visible+// discoverCodexCatalog returns the installed Codex binary's live visible// catalog, including reasoning metadata. Version detection happens before the// debug command so old binaries do not log a predictable "unknown command"// failure on every cache refresh.-func discoverCodexModels(ctx context.Context, cmd Command) []Model {+func discoverCodexCatalog(ctx context.Context, cmd Command) Catalog {if cmd.Path == "" {cmd.Path = "codex"}version, err := DetectVersion(ctx, cmd)if err != nil {- return codexStaticModels()+ return Catalog{Models: codexStaticModels(), Fallback: true}}supportsExplicitStandard := codexSupportsExplicitStandardServiceTier(version)if !codexSupportsDebugModels(version) {- return annotateCodexExplicitStandardServiceTier(codexStaticModels(), supportsExplicitStandard)+ return Catalog{+ Models: annotateCodexExplicitStandardServiceTier(codexStaticModels(), supportsExplicitStandard),+ Fallback: true,+ }}- raw, err := runCodexDebugModels(ctx, cmd)- if err != nil {- return annotateCodexExplicitStandardServiceTier(codexStaticModels(), supportsExplicitStandard)+ liveCtx, cancel := context.WithTimeout(ctx, codexLiveCatalogTimeout)+ raw, err := runCodexDebugModels(liveCtx, cmd, codexDebugModelsArgs...)+ cancel()+ if err == nil {+ models, parseErr := parseCodexModelCatalog(raw)+ if parseErr == nil && len(models) > 0 {+ return Catalog{Models: annotateCodexExplicitStandardServiceTier(models, supportsExplicitStandard)}+ }}- models, err := parseCodexModelCatalog(raw)- if err != nil || len(models) == 0 {- return annotateCodexExplicitStandardServiceTier(codexStaticModels(), supportsExplicitStandard)++ raw, err = runCodexDebugModels(ctx, cmd, codexBundledDebugModelsArgs...)+ if err == nil {+ models, parseErr := parseCodexModelCatalog(raw)+ if parseErr == nil && len(models) > 0 {+ return Catalog{+ Models: annotateCodexExplicitStandardServiceTier(models, supportsExplicitStandard),+ Fallback: true,+ }+ }+ }+ return Catalog{+ Models: annotateCodexExplicitStandardServiceTier(codexStaticModels(), supportsExplicitStandard),+ Fallback: true,}- return annotateCodexExplicitStandardServiceTier(models, supportsExplicitStandard)}func codexSupportsDebugModels(version string) bool {@@ -374,23 +392,25 @@ func annotateCodexExplicitStandardServiceTier(models []Model, supported bool) []return models}-// codexDebugModelsArgs is the argv we pass to discover the local Codex-// catalog. Kept as a package-level var (not a literal at the call site)-// so tests can assert the exact form a real `codex` invocation receives,-// not just the parser behavior on a fixture string. The argv shape is-// the contract that broke under PR1 review; the test that pins it sits-// in thinking_test.go.-var codexDebugModelsArgs = []string{"debug", "models", "--bundled"}+const codexLiveCatalogTimeout = 15 * time.Second-func runCodexDebugModels(ctx context.Context, runtimeCmd Command) ([]byte, error) {- cmd := runtimeCmd.exec(ctx, codexDebugModelsArgs...)+// codexDebugModelsArgs is the argv we pass for the authoritative live catalog.+// codexBundledDebugModelsArgs is the offline fallback. Kept as package-level+// vars so tests can assert the exact form a real `codex` invocation receives.+var (+ codexDebugModelsArgs = []string{"debug", "models"}+ codexBundledDebugModelsArgs = []string{"debug", "models", "--bundled"}+)++func runCodexDebugModels(ctx context.Context, runtimeCmd Command, args ...string) ([]byte, error) {+ cmd := runtimeCmd.exec(ctx, args...)hideAgentWindow(cmd)return outputOwned(cmd, runtimeCmd.logger)}// parseCodexModelCatalog projects the CLI's raw catalog into the daemon wire// model. Hidden entries are intentionally excluded to match Codex's own model-// picker; the first visible entry is the bundled catalog's preferred default.+// picker; the first visible entry is the catalog's preferred default.func parseCodexModelCatalog(raw []byte) ([]Model, error) {var resp codexDebugModelsResponseif err := json.Unmarshal(raw, &resp); err != nil {@@ -730,6 +750,9 @@ func ValidateThinkingLevelWith(loadCatalog func() (Catalog, error), providerType}return false, nil}+ if missingFromFallbackCatalog(catalog, providerType, model) {+ return false, fmt.Errorf("model %q absent from fallback %s catalog; cannot validate thinking level", model, providerType)+ }return false, nil}@@ -797,6 +820,10 @@ func ValidateServiceTierWith(loadCatalog func() (Catalog, error), providerType,if err != nil {return false, err}+ // Explicit standard routing is a CLI-version capability, not a per-model+ // capability. Resolve it before the fallback missing-model check: an old+ // CLI must never pass "default" through just because its fallback omits+ // the saved (live-only) model.if value == codexStandardServiceTier {for _, candidate := range catalog.Models {if candidate.SupportsExplicitStandardServiceTier {@@ -805,6 +832,9 @@ func ValidateServiceTierWith(loadCatalog func() (Catalog, error), providerType,}return false, nil}+ if missingFromFallbackCatalog(catalog, providerType, model) {+ return false, fmt.Errorf("model %q absent from fallback %s catalog; cannot validate service tier", model, providerType)+ }for _, m := range catalog.Models {if m.ID != model {continue@@ -819,6 +849,22 @@ func ValidateServiceTierWith(loadCatalog func() (Catalog, error), providerType,return false, nil}+// Codex fallback is useful for known models, but its omissions are not+// evidence that a live-only model lacks a capability. The daemon passes validation+// errors through to the CLI rather than discarding a saved user override.+func missingFromFallbackCatalog(catalog Catalog, providerType, model string) bool {+ if providerType != "codex" || !catalog.Fallback || model == "" {+ return false+ }+ target := modelIDForCapabilityLookup(providerType, model)+ for _, candidate := range catalog.Models {+ if modelIDForCapabilityLookup(providerType, candidate.ID) == target {+ return false+ }+ }+ return true+}+func anyModelSupportsThinkingValue(models []Model, value string) bool {for _, m := range models {if m.Thinking == nil {diff --git a/server/pkg/agent/thinking_test.go b/server/pkg/agent/thinking_test.goindex dd8d74c199..b2540771f5 100644--- a/server/pkg/agent/thinking_test.go+++ b/server/pkg/agent/thinking_test.go@@ -132,8 +132,7 @@ func TestProjectClaudeLevels_PerModelSubset(t *testing.T) {//// Elon's PR1 review found that `codex debug models --output json` is// rejected by codex-cli 0.131.0 — there is no `--output` flag on the-// subcommand. The fix was to drop the flag and add `--bundled` (which-// just skips network refresh). These two tests pin the contract:+// subcommand. The fix was to drop the flag. These two tests pin the contract://// - TestCodexDebugModelsArgs_Pinned asserts the literal argv we pass// so a future "let's add a flag" refactor breaks loudly instead of@@ -166,7 +165,7 @@ func TestRunCodexDebugModels_ArgvSeenByBinary(t *testing.T) {// Linux ETXTBSY when we exec the file (Go #22315).writeTestExecutable(t, fake, []byte(script))- raw, err := runCodexDebugModels(context.Background(), Command{Path: fake})+ raw, err := runCodexDebugModels(context.Background(), Command{Path: fake}, codexDebugModelsArgs...)if err != nil {t.Fatalf("runCodexDebugModels: %v (output=%q)", err, raw)}@@ -176,7 +175,7 @@ func TestRunCodexDebugModels_ArgvSeenByBinary(t *testing.T) {t.Fatalf("read argv file: %v", err)}got := splitNonEmptyLines(string(data))- want := []string{"debug", "models", "--bundled"}+ want := []string{"debug", "models"}if !reflect.DeepEqual(got, want) {t.Fatalf("fake codex received argv %v, want %v", got, want)}@@ -343,7 +342,7 @@ func TestDiscoverCodexModelsVersionGateAndFallback(t *testing.T) {t.Skip("shell-script fake binary requires a POSIX shell")}- t.Run("supported version uses bundled catalog", func(t *testing.T) {+ t.Run("supported version prefers live catalog", func(t *testing.T) {dir := t.TempDir()fake := filepath.Join(dir, "codex")script := `#!/bin/sh@@ -352,16 +351,51 @@ if [ "$1" = "--version" ]; thenexit 0fiprintf '%s\n' "$@" > "` + filepath.Join(dir, "argv.txt") + `"-echo '{"models":[{"slug":"runtime-model","display_name":"Runtime Model","visibility":"list","default_reasoning_level":"high","supported_reasoning_levels":[{"effort":"high","description":"Live"}]}]}'+if [ "$3" = "--bundled" ]; then+ echo '{"models":[{"slug":"bundled-model","display_name":"Bundled Model","visibility":"list"}]}'+else+ echo '{"models":[{"slug":"live-model","display_name":"Live Model","visibility":"list","default_reasoning_level":"high","supported_reasoning_levels":[{"effort":"high","description":"Live"}]}]}'+fi+`+ writeTestExecutable(t, fake, []byte(script))++ catalog := discoverCodexCatalog(context.Background(), Command{Path: fake})+ if len(catalog.Models) != 1 || catalog.Models[0].ID != "live-model" || catalog.Models[0].Thinking == nil || !hasThinkingLevel(catalog.Models[0].Thinking, "high") {+ t.Fatalf("expected live runtime catalog, got %+v", catalog.Models)+ }+ if catalog.Fallback {+ t.Fatal("live catalog must be authoritative")+ }+ if catalog.Models[0].SupportsExplicitStandardServiceTier {+ t.Fatalf("Codex 0.122.0 must not advertise explicit-standard support: %+v", catalog.Models[0])+ }+ })++ t.Run("live failure uses bundled catalog as non-authoritative fallback", func(t *testing.T) {+ dir := t.TempDir()+ fake := filepath.Join(dir, "codex")+ script := `#!/bin/sh+if [ "$1" = "--version" ]; then+ echo "codex-cli 0.144.1"+ exit 0+fi+if [ "$3" = "--bundled" ]; then+ echo '{"models":[{"slug":"bundled-model","display_name":"Bundled Model","visibility":"list"}]}'+ exit 0+fi+exit 1`writeTestExecutable(t, fake, []byte(script))- got := discoverCodexModels(context.Background(), Command{Path: fake})- if len(got) != 1 || got[0].ID != "runtime-model" || got[0].Thinking == nil || !hasThinkingLevel(got[0].Thinking, "high") {- t.Fatalf("expected runtime catalog, got %+v", got)+ catalog, err := ListModels(context.Background(), "codex", Command{Path: fake})+ if err != nil {+ t.Fatalf("ListModels: %v", err)+ }+ if len(catalog.Models) != 1 || catalog.Models[0].ID != "bundled-model" {+ t.Fatalf("expected bundled fallback, got %+v", catalog.Models)}- if got[0].SupportsExplicitStandardServiceTier {- t.Fatalf("Codex 0.122.0 must not advertise explicit-standard support: %+v", got[0])+ if !catalog.Fallback {+ t.Fatal("bundled catalog after live discovery failure must be non-authoritative")}})@@ -373,12 +407,18 @@ echo '{"models":[{"slug":"runtime-model","display_name":"Runtime Model","visibil"exit 99\n"writeTestExecutable(t, fake, []byte(script))- got := discoverCodexModels(context.Background(), Command{Path: fake})- if len(got) == 0 || got[0].ID != "gpt-6-astra" {- t.Fatalf("expected static fallback, got %+v", got)+ catalog, err := ListModels(context.Background(), "codex", Command{Path: fake})+ if err != nil {+ t.Fatalf("ListModels: %v", err)}- if got[0].SupportsExplicitStandardServiceTier {- t.Fatalf("old Codex must not advertise explicit-standard support: %+v", got[0])+ if len(catalog.Models) == 0 || catalog.Models[0].ID != "gpt-6-astra" {+ t.Fatalf("expected static fallback, got %+v", catalog.Models)+ }+ if !catalog.Fallback {+ t.Fatal("static catalog for an old Codex must be non-authoritative")+ }+ if catalog.Models[0].SupportsExplicitStandardServiceTier {+ t.Fatalf("old Codex must not advertise explicit-standard support: %+v", catalog.Models[0])}})@@ -390,12 +430,18 @@ echo '{"models":[{"slug":"runtime-model","display_name":"Runtime Model","visibil"exit 1\n"writeTestExecutable(t, fake, []byte(script))- got := discoverCodexModels(context.Background(), Command{Path: fake})- if len(got) == 0 || got[0].ID != "gpt-6-astra" || got[0].Thinking == nil {- t.Fatalf("expected model + thinking fallback, got %+v", got)+ catalog, err := ListModels(context.Background(), "codex", Command{Path: fake})+ if err != nil {+ t.Fatalf("ListModels: %v", err)}- if !got[0].SupportsExplicitStandardServiceTier {- t.Fatalf("supported Codex version must retain explicit-standard capability through catalog fallback: %+v", got[0])+ if len(catalog.Models) == 0 || catalog.Models[0].ID != "gpt-6-astra" || catalog.Models[0].Thinking == nil {+ t.Fatalf("expected model + thinking fallback, got %+v", catalog.Models)+ }+ if !catalog.Fallback {+ t.Fatal("static catalog after both discovery attempts fail must be non-authoritative")+ }+ if !catalog.Models[0].SupportsExplicitStandardServiceTier {+ t.Fatalf("supported Codex version must retain explicit-standard capability through catalog fallback: %+v", catalog.Models[0])}})}@@ -427,6 +473,65 @@ func TestValidateThinkingLevelCodexPerModelFallbackCatalog(t *testing.T) {}}+// A fallback is not an allow-list for live-only models. Unknown models on an+// authoritative catalog still fail closed, and known fallback models still+// have their capabilities checked instead of being passed through.+func TestValidateCodexCapabilitiesMissingFromFallback(t *testing.T) {+ fallback := Catalog{Models: []Model{{ID: "gpt-5.5"}}, Fallback: true}+ for _, tc := range []struct {+ name string+ validate func(func() (Catalog, error), string, string, string) (bool, error)+ value string+ }{+ {"thinking", ValidateThinkingLevelWith, "high"},+ {"service tier", ValidateServiceTierWith, "priority"},+ } {+ t.Run(tc.name, func(t *testing.T) {+ load := func() (Catalog, error) { return fallback, nil }+ if valid, err := tc.validate(load, "codex", "gpt-6-sol", tc.value); valid || err == nil {+ t.Fatalf("missing live-only model: got (%v, %v), want validation error", valid, err)+ }+ if valid, err := tc.validate(load, "codex", "gpt-5.5", tc.value); valid || err != nil {+ t.Fatalf("known fallback model with unsupported value: got (%v, %v), want (false, nil)", valid, err)+ }+ fallback.Fallback = false+ if valid, err := tc.validate(load, "codex", "gpt-6-sol", tc.value); valid || err != nil {+ t.Fatalf("authoritative catalog omits model: got (%v, %v), want (false, nil)", valid, err)+ }+ fallback.Fallback = true+ })+ }++ load := func() (Catalog, error) { t.Fatal("empty model must not read catalog"); return Catalog{}, nil }+ if valid, err := ValidateThinkingLevelWith(load, "codex", "", "high"); valid || err != nil {+ t.Fatalf("empty model thinking = (%v, %v), want (false, nil)", valid, err)+ }+ if valid, err := ValidateServiceTierWith(load, "codex", "", "priority"); valid || err != nil {+ t.Fatalf("empty model tier = (%v, %v), want (false, nil)", valid, err)+ }+}++func TestValidateServiceTierStandardUsesCLICapabilityOnFallback(t *testing.T) {+ for _, tc := range []struct {+ name string+ supported bool+ }{+ {"before 0.133", false},+ {"0.133 and later", true},+ } {+ t.Run(tc.name, func(t *testing.T) {+ catalog := Catalog{Models: []Model{{ID: "gpt-5.5", SupportsExplicitStandardServiceTier: tc.supported}}, Fallback: true}+ load := func() (Catalog, error) { return catalog, nil }+ for _, model := range []string{"gpt-5.5", "gpt-6-sol"} {+ got, err := ValidateServiceTierWith(load, "codex", model, "default")+ if err != nil || got != tc.supported {+ t.Errorf("model %q on fallback (supported=%v): got (%v, %v), want (%v, nil)", model, tc.supported, got, err, tc.supported)+ }+ }+ })+ }+}+// TestParseCodexModelCatalog_PreservesFutureEfforts pins the dynamic-catalog// contract: a future Codex effort should reach the picker without a Multica// code update, pass the server's safe-token gate, and remain scoped to the