WardLu's old threads say model_provider "custom": CC Switch's mirror of
the official OpenAI provider ([model_providers.custom], name "OpenAI",
requires_openai_auth, no base_url). magpie takes Codex onto a magpie
model by openai_base_url, which Codex applies to its built-in "openai"
provider only. A thread resumed on "custom" therefore went straight to
chatgpt.com with the magpie model picked in it, and ChatGPT answered
"The 'group/intent-auto' model is not supported when using Codex with a
ChatGPT account"; magpie's log never saw it.
While Codex goes to magpie by the base URL, takeMirrors now gives each
such mirror magpie's ChatGPT backend (codexURL) as its base_url, as
failover already does for a mirror that is Codex's current provider,
and records the ids in the stash (codex.mirrors). giveMirrors takes the
base URL off again when Codex steps off magpie (one of its own models,
reset, Disconnect), leaving one changed since as it is. A mirror a
profile names is the user's and is left alone. isCCSwitchMirror still
counts a taken mirror as a mirror, so its models stay grouped under
OpenAI and ccSwitchTables doesn't treat it as a relay.
No detection or guide was added: with the requests reaching magpie the
old threads keep their history and model. Moving them onto another
provider is already the Sessions page's Move (#887), which rewrites
every rollout of the thread (resumed _segment files too) and the state
DB row.
Run:
- go test -tags nogui ./internal/agent -run 'CCSwitch|Mirror|Codex':
ok. TestCodexTakesCCSwitchMirrorForItsThreads fails on the code
before this commit ("the mirror isn't through magpie").
- gofmt -l, go vet (darwin, linux, windows), full go test ./... before
the push.
Not tried: a real Codex resuming a "custom" thread against a real
ChatGPT account. The same base_url on a requires_openai_auth mirror is
what mirror failover (#504) has written since it shipped.
* fix(agent/codex): recognize CC Switch official OpenAI mirror for grouping and failover (#504)
CC Switch writes Codex's built-in OpenAI provider as model_provider = "custom"
with a [model_providers.custom] table having name = "OpenAI", requires_openai_auth = true,
and no base_url. Because model_provider was not empty or "openai", Codex's models
were filed under a group named "custom" instead of "OpenAI", and account failover was
skipped.
Recognize a model_provider table without a base_url and named OpenAI as the official
provider for model option grouping and account failover.
* fix(agent/codex): route CC Switch official mirror failover through table base_url (#504)
Codex ignores openai_base_url when model_provider = "custom" is set, so
setting openai_base_url during account failover caused requests to bypass
magpie and fall back directly to chatgpt.com.
Instead, point the mirror table itself at magpie (base_url = at.codexURL())
during failover, and remove base_url when failover turns off, returning the
config byte-identical to the original. Exclude the official mirror from
takeTables so relays remain distinct, and preserve the original picker
grouping logic for magpieID and openai.
* fix(agent/codex): clear mirror failover marker when switching table and preserve relay base_url