Commit Graph
3 Commits
Author SHA1 Message Date
yetone 7f03d320d0 agent: a Codex thread started on CC Switch's OpenAI mirror goes through magpie while a magpie model is on, so reopened it isn't refused by ChatGPT for the magpie model picked in it (#1796)
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.
2026-10-12 23:16:54 +08:00
Luis Araya 49ee7d82d9 fix(agent/codex): recognize CC Switch official OpenAI mirror for grouping and failover (#504) (#579)
* 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
2026-10-03 06:48:49 +08:00
yetone 6c5ed2acf5 agents: CC Switch's provider tables in Codex's config go through magpie too, and the Library brings in every skill found at once (JasonLeeForOnly on Discord: after moving from CC Switch, Codex threads still went to the relay, "model not found" for a magpie model) — CC Switch writes a [model_providers.custom] table (cc-switch, cc-switch-N in older versions) and moves every third-party Codex thread onto it, and a reopened thread takes the provider it was saved with, not model_provider; magpie left those tables pointing at the relay. While a magpie model is on, signed in or not, their base_url is magpie's /v1, the relay's kept in the stash and the table's other keys as they were; a table a profile names, and cc-switch-official, are left alone; Codex's own model or a reset puts the URL back, unless the table was changed since; one pointed away again is named on the agent row and taken back on sync. The Skills tab's "In your agents" gets Bring in all (2+ found), one library write, one that fails named and the others brought in. TestCodexTakesCCSwitchTables, TestImportSkills and import-all-skills.test.cjs (Chromium, WebKit, en/zh) fail without the change. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass; click-scroll, old-webkit, shared-skills pass. 2026-09-30 18:16:22 +08:00