From d1a94f5792136c2a666ddf13cd5210168c69635e Mon Sep 17 00:00:00 2001 From: yetone Date: Sun, 1 Nov 2026 18:27:50 +0800 Subject: [PATCH] provider: a Codex pick the ChatGPT list dropped is not offered (#4772) Cause: the owner's codex provider keeps picks (providers.json "models") made while ChatGPT listed gpt-5.5. ChatGPT has since stopped listing it: the backend's /codex/models for the Pro account (client_version 0.165.0, asked 11-01) and the saved Plus account's list both have gpt-6.1-sol, gpt-6-astra, gpt-6.1-terra, gpt-6-sol, gpt-6-luna, gpt-5.6-sol/terra/luna and no gpt-5.5, and Codex CLI 0.165.0's models_cache.json has none either. ExposedOf offers a pick the vendor's list lacks as typed in by hand, and an account's refetch never drops gone picks (dropGonePicks is for key providers), so codex/gpt-5.5 stayed first in /v1/models. The backend refuses any model its list leaves out: a real request for gpt-5.5 on the Pro account answered 400 model_not_found "The 'gpt-5.5' model is not supported when using Codex with a ChatGPT account", while gpt-5.6-luna answered 200. Not plan-specific: Plus and Pro alike. Fix: a ChatGPT account (listedOnly) is treated as Copilot's already is: with its list fetched, a pick the list doesn't have is left out of what agents are offered. The pick itself stays saved and comes back when the list has it again. The list is the pool's (codexPoolModels), so a model only a saved account has is still offered and routed to it (Account.Lists). Run (mote, at this tree on origin/main 1fac66c06): - gofmt -l internal: clean; go vet ./internal/provider, GOOS=linux -tags nogui and GOOS=windows: ok - go test ./internal/provider (full): ok 131s - go test ./internal/tui ./internal/codexcat ./internal/usageapi ./internal/cli ./internal/catalog ./internal/agent: all ok - go test -run 'Codex|Pick|Expos|Listed|Models' ./internal/gateway ./internal/gui: ok - Real accounts, sandbox HOME (copy of ~/.codex/auth.json and the live providers.json and codex model lists): `magpie models` built from origin/main lists codex/gpt-5.5 first; built from this tree it lists only the six models the account serves. Broken by hand: with ExposedOf's condition put back to unusable != nil, TestCodexPickTheListDroppedNotOffered fails ("offered [gpt-5.5 gpt-6-astra gpt-6-sol]"). Not tried: the full ./... suite and the whole gateway package (mote was at load ~290 with another session's suite running); the GUI suite; the ChatGPT API provider (siwc), which keeps a fetched list too but was not checked for refusing unlisted models, so it is left as it was. --- internal/provider/account.go | 6 ++ internal/provider/codex_gone_pick_test.go | 94 +++++++++++++++++++++++ internal/provider/models.go | 7 +- 3 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 internal/provider/codex_gone_pick_test.go diff --git a/internal/provider/account.go b/internal/provider/account.go index 3677b28ea..406866660 100644 --- a/internal/provider/account.go +++ b/internal/provider/account.go @@ -105,6 +105,11 @@ type Account struct { // is one the account was refused (copilot_refused.go); and on a ZCode // account on the Start Plan: whether it is one only the Coding Plan has. unusable func(model string) bool + // listedOnly is set on a ChatGPT account: the backend serves none of + // the models its list leaves out ("The 'gpt-5.5' model is not + // supported when using Codex with a ChatGPT account", #4772), so a + // pick the fetched list doesn't have isn't offered. + listedOnly bool // explain adds what the user can do about a refusal the account's // backend answered, "" when there is nothing to add (factory.go). explain func(status int, body []byte) string @@ -1049,6 +1054,7 @@ func codexAccount(home string) (Provider, bool) { } acct.body = codexBody acct.models = catalog.Codex + acct.listedOnly = true acct.fetch = func(ctx context.Context) ([]catalog.Model, error) { ms, err := codexModels(ctx, acct.sign) if err != nil { diff --git a/internal/provider/codex_gone_pick_test.go b/internal/provider/codex_gone_pick_test.go new file mode 100644 index 000000000..f0e2dce34 --- /dev/null +++ b/internal/provider/codex_gone_pick_test.go @@ -0,0 +1,94 @@ +package provider + +import ( + "net/http" + "net/http/httptest" + "path/filepath" + "slices" + "sync/atomic" + "testing" + "time" +) + +// #4772: the owner picked Codex's models while ChatGPT listed gpt-5.5. +// ChatGPT then stopped listing it on Plus and Pro alike, and its backend +// answers every request for it 400 "The 'gpt-5.5' model is not supported +// when using Codex with a ChatGPT account". The pick stayed, and agents +// (Cindy) were offered codex/gpt-5.5 first. A pick the account's list +// doesn't have is not offered; it comes back when the list has it again. +func TestCodexPickTheListDroppedNotOffered(t *testing.T) { + isolate(t) + home := t.TempDir() + t.Setenv("HOME", home) + t.Setenv("USERPROFILE", home) + t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config")) + t.Setenv("XDG_CACHE_HOME", filepath.Join(home, ".cache")) + newFetches.Lock() + newFetches.m = map[string]time.Time{} + newFetches.Unlock() + + var dropped atomic.Bool + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.URL.Path != "/backend-api/codex/models" { + w.WriteHeader(404) + return + } + if dropped.Load() { + // the Pro account's list on 11-01 + w.Write(codexListOf("gpt-6.1-sol", "gpt-6-astra", "gpt-6-sol", "gpt-5.6-luna")) + return + } + w.Write(codexListOf("gpt-5.5", "gpt-6-astra", "gpt-6-sol", "gpt-5.6-luna")) + })) + defer srv.Close() + codexListedAt(t, srv.URL) + codexSignedIn(t, home) + + offered := func() []string { + t.Helper() + p, err := Find("codex") + if err != nil { + t.Fatal(err) + } + var out []string + for _, m := range p.ExposedOf(p.Available()) { + out = append(out, m.ID) + } + return out + } + refetch := func() { + t.Helper() + p, err := Find("codex") + if err != nil { + t.Fatal(err) + } + if _, err := p.fetch(t.Context()); err != nil { + t.Fatal(err) + } + forgetAccountCaches() + } + + refetch() + if err := SetModels("codex", []string{"gpt-5.5", "gpt-6-astra", "gpt-6-sol"}); err != nil { + t.Fatal(err) + } + if got := offered(); !slices.Equal(got, []string{"gpt-5.5", "gpt-6-astra", "gpt-6-sol"}) { + t.Fatalf("picks while listed: %v", got) + } + + dropped.Store(true) + refetch() + if got := offered(); slices.Contains(got, "gpt-5.5") || !slices.Equal(got, []string{"gpt-6-astra", "gpt-6-sol"}) { + t.Fatalf("after ChatGPT stopped listing gpt-5.5, offered %v; want gpt-6-astra and gpt-6-sol", got) + } + // the user's pick is kept, only not offered + if p, _ := Find("codex"); !slices.Contains(p.Models, "gpt-5.5") { + t.Fatalf("the pick itself was dropped: %v", p.Models) + } + + dropped.Store(false) + refetch() + if got := offered(); !slices.Contains(got, "gpt-5.5") { + t.Fatalf("listed again, gpt-5.5 not offered: %v", got) + } +} diff --git a/internal/provider/models.go b/internal/provider/models.go index 65013366c..3a3170f2b 100644 --- a/internal/provider/models.go +++ b/internal/provider/models.go @@ -1574,11 +1574,14 @@ func (p Provider) ExposedOf(avail []catalog.Model) []catalog.Model { return out } picks := p.Models - if _, _, ok := p.live(); ok && p.Account != nil && p.Account.unusable != nil { + if _, _, ok := p.live(); ok && p.Account != nil && (p.Account.unusable != nil || p.Account.listedOnly) { // A Copilot account is served what its list offers it, less what // it was refused: a pick its list doesn't have (#371: gpt-6-luna, // not in a Student plan's) or that it was refused is left out; - // with none left, as if none were picked. + // with none left, as if none were picked. A ChatGPT account's + // too: a pick made while its list had gpt-5.5 stayed offered after + // the list dropped it, and the backend refused every request for + // it (#4772). It comes back when the list has it again. picks = slices.DeleteFunc(slices.Clone(picks), func(id string) bool { _, ok := byID[id]; return !ok }) } else if p.Account != nil && p.Account.unusable != nil { // with no list fetched, a pick the account can't be served (a