e4e9eb0928becfa4e48484dde85ef5032671d582
4
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
9f4e1120f3 |
agent: a Codex not connected is never pointed at magpie for account failover
TylerBai_loveai on X (tweet 2121532671180632290): with several ChatGPT accounts added in magpie and Codex not connected, Codex's requests went through magpie anyway; only adding Codex in Agents, then Disconnect, put it back. Cause: Sync's `failover` in codex.go wrote `openai_base_url = "http://127.0.0.1:3425/backend-api/codex"` (stash codex.failover), or pointed a CC Switch OpenAI mirror's base_url at the gateway (codex.mirror_failover), for any Codex signed in to ChatGPT with another of its accounts on (#1385), on every start and Sync, unless the user had disconnected Codex or turned on "Only switch Codex's sign-in". The row said not connected while every request went through magpie. Fix: failover writes nothing any more. A Codex that isn't wired or using magpie as its provider gets what failover wrote before taken out by Sync: the marked base URL, or the mirror's base_url. A base URL the user wrote by hand has no mark and stays (#856). Failover between Codex accounts comes with connecting Codex. modelOptions no longer counts failover as through magpie, so a pick of Codex's own model on the Agents page doesn't go via magpie. codexProxyOK (the proxy probe only failover waited for) is gone. The CLI's and GUI's switch-only lines, reference.md and the subsystem pages say failover is for a connected Codex. Users already affected: the first Sync after updating (magpie's start) removes the marked openai_base_url or mirror base_url, and the route change restarts Codex's app-server; Codex then goes straight to OpenAI on its own sign-in. A thread opened while it was on magpie keeps its provider until reopened, as after Disconnect. Tests: - TestCodexNotConnectedStaysOffMagpie: two spare accounts on, Codex not connected; SyncCatalog, Sync twice and a model pick leave no base URL, no model_provider, not Wired/FailingOver/CodexOwnOnly. - TestCodexFailoverFromBeforeTakenOut: a marked base URL and a marked mirror base_url from before are taken out, bytes restored exactly. - TestCodexSwitchOnlyKeepsCodexOffTheGateway, the CC Switch mirror, disconnect-stays and proxy/EndFailover tests reworked to seed the old state by hand; TestCodexFailoverHeldWhileProxyDoesNotPassOn deleted with codexProxyOK. Red on the old code (old codex.go + codex_proxy.go, new tests, mote): TestCodexNotConnectedStaysOffMagpie, TestCodexFailoverFromBeforeTakenOut and TestCodexSwitchOnlyKeepsCodexOffTheGateway fail with the reporter's line `openai_base_url = "http://127.0.0.1:3425/backend-api/codex"`; TestCodexCCSwitchOfficialOpenAIMirror fails with the mirror pointed at magpie. Run (mote; mica's disk is full, 100% with other sessions' runs, and mote's load was ~17-25 of 18): - At base |
||
|
|
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. |
||
|
|
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 |
||
|
|
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. |