JNDliuliuM: after picking new models for a provider, Codex CLI didn't
change, and after a restart it was still on the old model. magpie wrote
the new list, but Codex's `model` (config.toml, or magpie.config.toml for
`codex -p magpie`) stayed on the model the user had unchecked. Resolve
still takes any provider/model, so Codex kept starting on it and asking
the vendor for it.
Tried with the real codex-cli 0.165.0 in a sandbox CODEX_HOME, profile
wiring: the list was swapped from sub/old-a, sub/old-b to sub/new-x,
sub/new-y. After a restart, /model listed only the new ones, but the
status line still read sub/old-a, as the profile named it.
What changed:
- provider.Unpicked(id) reports a model the user has since unchecked:
the provider has picks, its served models lack the model, and it isn't
a decision model. This is the same rule ResolveRoute already applies
to routing groups (#3911).
- agent.pickedInstead moves such a model to the first model of that
provider that magpie lists for the agent now.
- Codex's Sync calls it before its other model branches, through set, as
picking the model does. The profile's Sync calls it through put. The
Codex app reads the same config.toml, so it follows too.
- Left alone:
- a provider with no picks, whose list is the vendor's and may lack
the model (#2642);
- a provider with none of its models listed any more.
Run on mote:
- TestCodexLeavesAModelUncheckedInItsProvider (as provider, beside a
ChatGPT sign-in, profile) and TestCodexKeepsAModelOfAProviderWithNoPicks;
- go test ./internal/agent/ ./internal/provider/;
- go vet for darwin, linux and windows on both packages;
- gofmt.
Result: internal/agent ok (470s). internal/provider is red only on
TestHostBuildsNoList (a Gemini provider's Host allocates 5 times), which
is #6479 and was already red on main.
Broken by hand: with the Codex Sync call disabled, the "as its provider"
and "beside the sign-in" subtests are red ("model = sub/old after sub/old
was unchecked"). With the profile call disabled, the "by its profile"
subtest is red.
Not tried:
- the fixed magpie with a real Codex;
- the Codex app.
Not changed, filed as #6504: other agents' model fields, and Codex's
subagent and compaction models.
Codex, never installed, was listed on the Agents page as "not connected"
once a ChatGPT account was added in Providers. With Codex signed in to
nothing, addLogin hands it that account and saveCodexLogin writes
~/.codex/auth.json, which makes ~/.codex; Detected took any non-empty
Dir for the agent. Claude Code is the sibling off the Mac: putClaudeLogin
writes ~/.claude/.credentials.json when Claude Code has none.
Agent.signIn names that file (auth.json for both Codex agents,
.credentials.json for Claude Code), and agentDir passes over it. A folder
with anything else of the agent's beside it (config.toml, sessions/,
settings.json, projects/, history.jsonl), its binary, or its app still
lists it.
Run:
- gofmt -l; go vet on darwin, linux (-tags nogui) and windows, on mote.
- go test -count=1 ./internal/agent ./internal/gui on mote: ok.
- win-run on xiaomi-gpu: TestSignInFileAloneIsNoAgent,
TestClaude*Windows*, TestDetected*: ok.
Broken by hand: agentDir not passing over the sign-in file:
TestSignInFileAloneIsNoAgent red for codex and claude
(../tray-jump-scratch/break.log).
Not tried: a real ChatGPT sign-in in a sandbox HOME with no Codex. A
Codex app installed but never opened, with only magpie's auth.json in
~/.codex, is not listed until it is opened (it then writes its own
files there).
Codex wired by its profile alone (codex -p magpie) kept offering the models
of a provider that was deleted. The profile's model was one of that
provider's, so it no longer resolved as a magpie model, wired() was false,
and the profile's Sync returned before it wrote magpie-models.json again.
The old list stayed, new providers' models never reached it. The Sync now
writes the list again whenever the profile names magpie as provider and its
list, even when the model it was set to is gone. All-of-Codex scope already
did this (asProvider and ownCatalog), as did the models_cache.json staling.
Found by syncing a sandbox HOME in both scopes after a provider edit and a
provider delete: only profile scope plus delete left the old list.
TestCodexProfileListDropsADeletedProvider is red on the old code (listed
added/m2 and added/m3 after the delete) and green now.
Run on mote: internal/agent package, go vet darwin, linux nogui, windows.
Not tried: a real Codex CLI reading the list; the viaBase models_cache.json
path (covered by existing tests, not changed).
The Codex agent gets an "applies to" field: All of Codex (as before) or
"codex -p magpie only". In the second mode magpie writes
<CODEX_HOME>/magpie.config.toml (model_provider, model, effort,
model_catalog_json, its own [model_providers.magpie]) and a catalog beside
it, and never touches config.toml: its top-level model_provider, model and
openai_base_url stay the user's. Disconnect deletes that file and magpie's
catalog (kept if the user added to it). Plain `codex` keeps its own provider.
Codex 0.165 reads `--profile NAME` from NAME.config.toml and refuses -p while
config.toml holds a legacy [profiles.NAME] or profile = "NAME", so this is
the file form, not a [profiles.magpie] table. Codex without profile files
(older than the May 2026 removal of legacy profiles) isn't served in this
mode. The choice changes only while Codex is disconnected, so the two wirings
never share a config. Only magpie's models are offered in this mode; no
joining, failover or subagent fields.
Run (mote, at the rebased head): go test ./internal/agent ./internal/gui ok;
gofmt clean; go vet darwin, linux nogui, windows ok; GUI i18n-keys,
i18n-en-no-cjk, gui-zh-tw, codex-signin-always, agent-connect,
agent-disconnect in Chromium and WebKit. Real codex 0.165.0 in a sandbox
CODEX_HOME against a fake server: `codex -p magpie` sent one request
(Bearer magpie, model fake/m1); plain `codex` sent none; config.toml was
byte-identical after connect, effort change, sync and disconnect.
Broken by hand: letting scope change while connected turns two
TestCodexProfileOnly tests red.
Not tried: a real account, the Codex app, the GUI row in a live window, an
older Codex without profile files. gui-de and gui-ja "has every zh string"
are red on main without this change (#6234).