Skip to content

Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.

codex: auto-review follows the session on a ChatGPT Free plan (cybercaius)

yetone6e969033465c
diff --git a/docs/subsystems/gateway-routing.md b/docs/subsystems/gateway-routing.md
index f51858d38..614c47c3d 100644
--- a/docs/subsystems/gateway-routing.md
+++ b/docs/subsystems/gateway-routing.md
@@ -107,7 +107,7 @@ recorded as a prediction failure (`noPrediction`).
- A model the user disabled (#1867) gets a 403 for every caller (`idOff`), before anything is sent; see [Disabled models](#disabled-models).
- Sealed tasks (#619) are checked here. A Codex subagent's task its lead's `spawn_agent` sealed goes only to a ChatGPT account, or back to the Responses provider that answered the lead (`leadProvider`, a relay of the ChatGPT backend such as Sub2API, #1109), relayed as it came even when web search is offered. A lead's turn carrying its subagent's sealed reply (`send_message`) goes back to the Responses provider that answered the lead's own conversation (`leadProvider` of the request's `conversationID`, #1237); otherwise it is refused before anyone is asked (`sealedReader`, `sealedTaskError`). A sealed message (`Message Type: MESSAGE`, not a task) that nobody asked can open is left out instead, an `input_text` note naming its sender in its place (`withoutSealedMessages`, #1613): a lead on a chat provider whose subagent is on one of Codex's own models goes on, as the subagent's final result still reaches it as text. Only a sealed task (`NEW_TASK`, or an item with neither header) is refused. Who answered is first what affinity remembers; when affinity has let it go (a day since, a restart past the 512 conversations `affinity.json` keeps, or the lead's last reply broken off, `unanswered`), the usage log's answers to the lead's thread and the request's own conversation in the last 30 days count too (`loggedAnswers`, #1367), and `leadFirst` reads the lead's key or account from them. A refused or failed call and a title answer nothing, and Codex's own sign-in is told of as the ChatGPT backend. The refusal names who sealed the task when it is known, and says how to go on with it. It also says what is sealed (`sealedTaskItself`, #1855): the task itself, `spawn_agent`'s `message`, which the backend returns sealed (`encrypted_function_args`) and Codex hands the subagent as it came, so `fork_turns="none"`, which only leaves the lead's turns out, doesn't help; nothing in it can be left out for the subagent to go on.
- A model set for Codex's subagents (`settings.CodexSubagentModel`, the Agents page's Codex "subagent model", willz on Discord) is put on a Codex subagent's request (`x-openai-subagent` read as `kind:collab_spawn`) before this check, whatever model its lead's `spawn_agent` asked for (`codexSubagentPick` in [`codex_subagent.go`](../../internal/gateway/codex_subagent.go)): in `codexBackend` for one of Codex's own bare models, which then goes through `serveAgent`, and in `serve` for any other. Any model magpie serves can be set (`provider.SetCodexSubagentModel`, #1633): a task handed as text (a lead magpie served on a chat provider, or multi-agent V1) is read by any model. A request carrying a task the ChatGPT backend sealed (`sealedTaskIn`: a sealed agent message that isn't a `MESSAGE`, which `withoutSealedMessages` leaves out) is put only on a ChatGPT account's model; set to another, the subagent stays on the model asked for, which the sealed gate below handles as with nothing set. When magpie doesn't serve the model set now, or a gateway key held to some models may not use it, the subagent goes on the model asked for too. The route trace keeps both models and the reason it stayed (`Route.Subagent`), and the Routing page's `kindWhy` says it. The lead's turns, titles and every other kind are never moved.
- - With no model set for them, in magpie or in Codex's config (`[agents] default_subagent_model`, `[memories] extract_model`/`consolidation_model`, read by `agent.CodexSideSet`; a config it can't read counts as set), a Codex subagent or memory call on one of Codex's own bare models, made in a conversation whose own turns go on one of magpie's models, follows that model instead of going to the ChatGPT sign-in (`codexFollowTo` in [`codex_follow.go`](../../internal/gateway/codex_follow.go), cybercaius on Discord). The model is the parent thread's last own turn (`x-codex-parent-thread-id` or the turn metadata's parent), else its own thread's, else the last one by the gateway key (`codexLeads`, at most 512 threads), else, before any turn has come through magpie (Codex consolidates its memories as it starts), Codex's config `model` when it is one of magpie's (`codexSessionOf`, `TestCodexMemoriesBeforeAnyTurnFollowTheConfig`). A sealed task, a model magpie can't resolve now or one a gateway key may not use leaves the call as it came; a subagent's trace keeps both models in `Route.Subagent`. Codex's auto-review follows the session only when `settings.CodexAutoReview` is `session` (`settings.CodexAutoReviewSession`): `codexcat` then has each of magpie's entries name itself as `auto_review_model_override`, and Codex's own entries keep OpenAI's, since codex-auto-review is free on a ChatGPT sign-in (#1593).
+ - With no model set for them, in magpie or in Codex's config (`[agents] default_subagent_model`, `[memories] extract_model`/`consolidation_model`, read by `agent.CodexSideSet`; a config it can't read counts as set), a Codex subagent or memory call on one of Codex's own bare models, made in a conversation whose own turns go on one of magpie's models, follows that model instead of going to the ChatGPT sign-in (`codexFollowTo` in [`codex_follow.go`](../../internal/gateway/codex_follow.go), cybercaius on Discord). The model is the parent thread's last own turn (`x-codex-parent-thread-id` or the turn metadata's parent), else its own thread's, else the last one by the gateway key (`codexLeads`, at most 512 threads), else, before any turn has come through magpie (Codex consolidates its memories as it starts), Codex's config `model` when it is one of magpie's (`codexSessionOf`, `TestCodexMemoriesBeforeAnyTurnFollowTheConfig`). A sealed task, a model magpie can't resolve now or one a gateway key may not use leaves the call as it came; a subagent's trace keeps both models in `Route.Subagent`. Codex's auto-review follows the session only when `settings.CodexAutoReview` is `session` (`settings.CodexAutoReviewSession`): `codexcat` then has each of magpie's entries name itself as `auto_review_model_override`, and Codex's own entries keep OpenAI's, since codex-auto-review is free on a paid ChatGPT sign-in (#1593). On a Free plan it isn't (cybercaius measured it on Discord), so with the setting unset and Codex's live sign-in on the `free` plan (`codexcat.AutoReviewModel`, the plan from `provider.CodexSignInPlan`), it counts as `session` (`TestCodexAutoReviewOnAFreePlan`).
- A model set for Claude Desktop's subagents (`settings.DesktopSubagentModel`, the Agents page's Claude Desktop "subagent model") is put on a subagent's turn in Desktop's Code tab or Cowork after `desktopTurn`, the tiers and the groups, whatever model its lead or its tier asked for (`desktopSubagentPick` in [`desktop_subagent.go`](../../internal/gateway/desktop_subagent.go)). Desktop runs its Claude Code with `CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST=1`, under which Claude Code ignores the `CLAUDE_CODE_SUBAGENT_MODEL` magpie writes into its settings (see [agent wiring](agent-wiring.md)). A subagent's request is one with `x-claude-code-agent-id` (`subagentOf`) from `claude-desktop`, and only one that offers tools is its turn: Claude Code's tool-less helper calls inside a subagent, on the haiku tier's model, stay where they are, and so do the lead's turns, terminal Claude Code's and every other agent's. The model set must be served by its exact id (`provider.DesktopSubagentUnserved`: `Resolve` takes any model name under a provider that is on), enabled, and allowed to a gateway key held to some models (`groupAllowed` for a group); otherwise the subagent goes on the model asked for and the route trace says why (`Route.Subagent`, said on the Routing page by `subagentWhy`, its `Kind` staying empty). `Route.Model` and the ledger's `Requested` keep the model the subagent asked for. `count_tokens` counts on the model set the same way (`countTokens`). The setting is read on each request, so a change needs no restart of Desktop, and a provider renamed since it was set is read by its new id (`RenamedRef`). A Desktop on another computer that reaches magpie with a named gateway key is read as Claude Code (`agentOf`), so none of Desktop's routing, this included, applies to it. A subagent's turn, moved or not, is never kept as the session's model in `claude-desktop.model` (`desktopTurn`'s `bySubagent`): a subagent on the opus tier's model took the session's place until the lead's next turn, and Desktop's titles asked for meanwhile went to it.
- Desktop's subagent effort (`settings.DesktopSubagentEffort`, `desktopSubagentEffort` in [`desktop_subagent.go`](../../internal/gateway/desktop_subagent.go)) applies to the same subagent tool turns, independently of model replacement. Empty leaves requests unchanged. Set, it takes the place of a request model's effort suffix before the existing attempt-level effort fitting: a member fixed at an effort wins, then this pick fitted within group/model levels, then the turn's or request's effort. `withFixedEffort` can enable reasoning when it was disabled, or disable it with `none` on a model that supports that level; a reasonless model is still sent no reasoning fields. `countTokens` applies the pick after restoring any unmasked body. `Route.Effort` keeps the incoming effort, `Route.SubagentEffort` the configured pick, and each try and usage record the level actually sent; the Routing story explains the configured pick even when no model was replaced. A nonempty model pick already classifies the turn, so the effort check reuses it; empty effort costs only a held-settings read. The next request takes a changed or cleared effort without a Desktop restart.
- Every Claude Code subagent's turn, Desktop's or a terminal's, moved or not, keeps its `x-claude-code-agent-id` in `Route.SubagentID` (`subagentTurnOf` in [`desktop_subagent.go`](../../internal/gateway/desktop_subagent.go)): a request with the id that offers tools and names no kind, the turn the two settings above take. Claude Code 2.1.295 sends the id from any agent context but the main one; its `x-claude-code-request-class` and `x-claude-code-agent-type` hints go only to a first-party base URL or with `CLAUDE_CODE_GATEWAY_HINT_HEADERS`, so magpie doesn't get them. A Desktop pick or effort that found the turn is trusted, so the body isn't decoded again, and a request without the id isn't decoded at all. The Routing page tags it as Codex's subagents are (`tagKind` in [`routing.js`](../../internal/gui/assets/routing.js)): in the request list, the story, the replay and the tray panel, with the reason `kindWhy` gives Codex's. `Kind` stays empty, so its purpose stays unmarked in the Purpose filter, as in the ledger and on the Usage page. The ledger's `Subagent` keeps the same id, and also marks a subagent's tool-less helper calls, which aren't tagged. A route recorded before this has no id and no tag.
@@ -125,7 +125,7 @@ recorded as a prediction failure (`noPrediction`).
- A rule by agent (`Rule.Agents`, `agents=codex,sillytavern`) matches the agent the gateway names the request's (`agentOf` in [`gateway.go`](../../internal/gateway/gateway.go): its `magpie-<name>` key, else its User-Agent), in lower case (`cleanRules`, `MatchesBesidesIntent`, `Pauses`). A client magpie doesn't know is named by its User-Agent's product name, before the first `/` or space (`usage.AgentOf`), so a rule can hold SillyTavern or one's own app (raikyou on Discord). The editor's agent picker lists the agents magpie knows, then those `/api/usage?period=30d` heard from that it doesn't (not `other`, nor `magpie`), and takes a name typed in its filter as the gateway reads a User-Agent (`uaName` in [`plugins/routing/client.js`](../../internal/gui/assets/plugins/routing/client.js), through the picker's `field.typed`): "MyApp/2.0 (Linux)" is `myapp`. `routing-rule-agent-typed.test.cjs`.
- A pause rule (`Rule.Pause`, `pause=<model>`; John on Discord: a model of the group paused in its vendor's peak hours) leaves the model it names out of the group while it holds (`provider.PausedOut`, on `ruleClock`): the group's own rules and each nested group's on the way down to a member, a group named taking all its models, and a model named taking it wherever a group in the group has it (#625). It runs before planning, on every request rather than once a turn, so the model is not first, not a failover, and not kept by affinity, and comes back as soon as the hours end. It holds by hours, days, agents and folders only (`cleanRules` refuses another condition), and is not a send-to rule: `Matches`, `MatchRule`, `ThenUses`, `Ruled` and the compaction rules leave it out. A send-to rule naming a paused model finds it unready and the group routes as without it. The trace keeps what was paused (`GroupRef.Paused`), and the Routing page says so. Every model paused answers 503 (`pausedError`) naming each rule. Embeddings go by the same pauses; manual groups have no rules (`Live`), so none pause there. A pause by folder (#1606, Ti800: a subscription's quota kept for the long task in one folder, `pause=<model> except-folders=~/big-task`) reads the folder only when such a pause is on the way (`provider.PausesByFolder`, then `workDir`): outside its except-folders, which includes a request that says no folder (a subagent's or a small model's that doesn't), the model is left out; with `folders=`, only requests known to be in them. Embeddings and System One's decision calls have no folder. `Paused.Folder`/`ByFolder` carry what was read, and the Routing page says the folder or that none was said. `rules_pause_test.go`, `TestPauseByFolder`, `TestPauseByFolderRule`, `TestParsePauseByFolder`, `routing-pause-folder.test.cjs`.
- A rule's hours and days (`Rule.Time`, `provider.TimeWindow`) are read on `ruleClock` in the zone they were set in (`TimeWindow.Zone`, an IANA name; gaubeebangeel on X: magpie on a cloud server in UTC, its user in Beijing, the hours 8 off). The GUI saves the browser's zone when the hours or days are changed in the editor and leaves a rule's zone alone otherwise; the CLI (`magpie group rule add … time=09:00-18:00@Asia/Shanghai` or `tz=`) and the TUI save the one typed, or this computer's (`provider.LocalZone`: `$TZ`, `time.Local`, the `/etc/localtime` link) when it has an IANA name. A window with no zone, every one saved before zones were kept, stays on magpie's own clock. A zone magpie doesn't know is refused on save (`TimeWindow.clean`), and one in a file edited by hand makes the window never hold (`zoneOf`): the rule is as if absent, never always on and never hours off. Zones come from Go's embedded tzdata, so Windows knows them too. `/api/groups` gives magpie's clock (`clock`: its zone and offset in seconds), and when it differs from the hours' zone the Routing page tells the zone beside them, on the group's rules and in the editor (`zoneNote` in [`plugins/routing/client.js`](../../internal/gui/assets/plugins/routing/client.js)): the zone's name, or the server's offset for hours with none. `TestRuleTimeWindowInItsZone`, `TestRuleTimeWindowInItsZoneAtTurnStart`, `TestRuleTimeWindowUnknownZone`, `TestParseRuleTimeZone`, `TestGroupRuleTimeZoneCmd`, `routing-time-zone.test.cjs`.
-3. Candidates come from `planGroup` for a group or `plan` for a provider. They are filtered by `sealedReaders` and `allowedCandidates`. An account past its share is held out of the candidates (`capHeld`): a usage cap's share, each window at its own where the account gives it one (`AccountWindowCaps`, willz on Discord: 50% of the five hours, 40% of the week) and at the account's cap otherwise, or 100% of a window for a Codex account set not to spend its credits (`provider.HoldCaps`, `WindowCaps.Of`, `CodexNoCredits`). A ChatGPT account's call on `codex-auto-review`, which OpenAI counts in no window, is held by no usage cap, only by credits it may not spend (`freeOnChatGPT`, #1593, `TestAccountCapLetsAutoReviewThrough`). The account is held while any window is past its own share, and `cappedError` and the trace name the fullest such window's share and cap. When every candidate is held and one held for its credits spends its resets by itself, `autoReset` spends a reset on it and it is tried (`planned.held`); otherwise a capped or barred set returns `cappedError` or `barredError`. Then `affine` moves the conversation's last answerer first, unless it is resting or nearly used up. An `X-Magpie-Account` header (`AccountHeader`) pins the request to one account: only that account is tried, and when it can't answer the caller is told why.
+3. Candidates come from `planGroup` for a group or `plan` for a provider. They are filtered by `sealedReaders` and `allowedCandidates`. An account past its share is held out of the candidates (`capHeld`): a usage cap's share, each window at its own where the account gives it one (`AccountWindowCaps`, willz on Discord: 50% of the five hours, 40% of the week) and at the account's cap otherwise, or 100% of a window for a Codex account set not to spend its credits (`provider.HoldCaps`, `WindowCaps.Of`, `CodexNoCredits`). A ChatGPT account's call on `codex-auto-review`, which OpenAI counts in no window, is held by no usage cap, only by credits it may not spend (`freeOnChatGPT`, #1593, `TestAccountCapLetsAutoReviewThrough`); a Free plan's call is capped as any other (`TestAccountCapHoldsAutoReviewOnAFreePlan`). The account is held while any window is past its own share, and `cappedError` and the trace name the fullest such window's share and cap. When every candidate is held and one held for its credits spends its resets by itself, `autoReset` spends a reset on it and it is tried (`planned.held`); otherwise a capped or barred set returns `cappedError` or `barredError`. Then `affine` moves the conversation's last answerer first, unless it is resting or nearly used up. An `X-Magpie-Account` header (`AccountHeader`) pins the request to one account: only that account is tried, and when it can't answer the caller is told why.
4. The candidate loop calls `attempt` on each candidate in turn, through a `holdWriter`. The writer holds the reply until it is clearly passing. A candidate that fails before anything is sent rests (`failure`): out of credit for 30 minutes, out of quota until reset, rate limited until retry-after, otherwise a minute and longer on repeats: doubled each time, up to `longestRetry` (10 minutes) for a failure and `longestRateRest` (30 minutes) for a rate limit back as soon as its rest is over, or up to the provider's own `restCap` in minutes (`Provider.RestCapOr`, at most `MaxQuotaRest`; `magpie provider rest-cap <id> 4h`, #2008: a free key down for hours was asked every 10 minutes). A time the vendor names stands over it as before (`TestOwnRestCap`). The failure count is kept per key or account (`restKey`), and any of its models' answers clears it (`served`). Each model's own count (`restID`) is kept beside it and cleared only by that model's answer (`servedCandidate`): once it is past the account's, a sibling model answered since it last did, so the failure is the model's and it climbs its own ladder and rests alone, its siblings still served (#2241, weizsw: an Antigravity seat's gemini-3.5-flash-lite rested a minute 41 times of 43 while gemini-3.8-flash kept answering; `TestModelLadderClimbsPastSiblingAnswers`). Every model failing with no answer between still climbs the account's ladder and rests the account, and a candidate naming no model has the account's count alone. `rest-cap <id> off` (`provider.RestCapOff`, `restCap: -1`) is for a relay or account pool whose unknown errors come now and then and pass by the next request (Kismet Alan on Discord): a failure that says nothing of why (`failOther`: a 5xx, a dropped connection) then rests nobody and isn't counted, its trace rest `by: "off"` with no time left. A 401 or 403, a model not served, an account's window full, a rate limit (magpie's own 30-minute cap), quota, credit and a restriction still rest it as before (`TestRestCapOff`). A provider the user added can be set never to rest for a limit instead (`provider.LimitRestOff`, `limitRestOff` in providers.json; the editor's Advanced fold, "Set it aside when out of quota or rate limited", ticked by default): a refusal `restAfterMarked` reads as out of quota, out of credit or rate limited, and any 429, then rests nothing, isn't counted or sunk, and is `by: "off"`; `restDrawer` rests no image model of it. The next request is sent to it as usual. It is for a relay whose limits pass in a moment (zoecats on Discord: a local aggregator said "quota exhausted" while it switched upstreams, and magpie answered itself for 30 minutes; `TestLimitRestOffKeepsAsking`, `TestLimitRestOffRestsNothingForALimit`). A 401, a model not served and a plain failure still rest it. The shortest cap otherwise is a minute, the first rest; `rest-cap <id> 30s` is turned away and names `off`. A 400, 403, 404 or 422 that says the model isn't served (`unservedWords`) and says nothing of quota, credit or a rate limit rests only that key's or account's model (`modelRefused`, keyed by `restID`, its backoff counted apart): its other models are still served first in order (#1235, SenseNova's 403 "model is not available in the current token plan"). A Google account's Code Assist (the Antigravity and Gemini CLI built-ins) answering 404 `NOT_FOUND` ("Requested entity was not found.") rests its model the same way, as its endpoint is the same for every model (`codeAssistModelMissing`; Packing1 on Discord: Argon, listed for a Google AI Pro account, answered 404 and rested the whole account; `TestCodeAssistMissingModelRestsTheModel`). A refusal for want of quota, credit or rate, for an account its vendor restricted, or for a verify it asks of its account there, from another computer's magpie (a Remote magpie provider, LAN share) rests only the model it was about (`remoteModelRest`, keyed by `restID`, in `restAfterMarked` and `rateRest`): that magpie serves each of its models from its own providers and rests them itself, so one out of quota there says nothing of the others (bigsteven on Discord: a 429 for one model rested every model on the remote for the 3 hours it named, so a group never moved on to the remote's other models; `TestRemoteMagpieQuotaRestsTheModel`, `TestRemoteMagpieRestrictedRestsTheModel`). Another magpie added by hand, as an OpenAI-compatible provider of the user's own name rather than the preset, is read as one by its reply: a magpie names the provider that answered or held it (`X-Magpie-Provider`, `providerHeader`; `noteMember`, also on a `quotaHeld` or `verifyHeld` answer), as no vendor does, and `keepRetry` notes it as `answeredThereHeader`, since this magpie writes its own provider into the same header of its reply and the note is kept from the client (lagrangepoint1813 on Discord: "Remote Magpie: Claude Code: You've hit your session limit" answered every model of it, from `quotaHeld`, for the five hours it named; `TestAnotherMagpieAddedByHandRestsTheModel`, asked there and held there). Its key refused, the computer unreachable, or the key's own limit there (`keyLimited`'s 429, which carries `X-Magpie-Limit-Reset`, `remoteKeyLimitHeader`), still rests it whole: #2077's reporter had a Claude Code session limit on the other magpie refuse its Qoder models here (`TestRemoteMagpieRestsTheModel`, two gateways over HTTP; `TestRemoteMagpieKeyLimitRestsTheKey`). A 400, 404, 410 or 422 that says the model is retired (`retiredWords`: OpenCode Zen's 410 `ModelDeprecated` "Model exo-free has been deprecated.", whose own model list still names it; MOMO on Discord) rests only that model the same way, is retryable so a group's next member or another provider of it is asked, and is remembered (`provider.Retire`, `retired.json` beside `providers.json`): the model leaves that provider's entries in the catalog (`buildEntries`), so /v1/models, every agent's model list and the found groups go without it, until a request on it is answered again (`Unretire` in `servedCandidate`) or a week has passed. A refresh of the vendor's list doesn't bring it back early, since that list is where it still is. A `provider/model` request for it is still sent. A 400 or 422 that says this upstream's API can't take the request's shape (`shapeWords`: xAI's 422 "unknown item type" (#350), OpenAI's "Unknown parameter", and a limit of a model's own on tool schemas, OpenCode Go's 400 "JSON schema exceeds the maximum nesting depth of 10 levels" on muse-spark-1.3-contributor, #1870), or that it is served on another API than the one asked (`wrongEndpoint`, once the member has tried every API it has a URL for: #2670, a relay with a Chat URL alone refusing tools with reasoning and `none` too), rests nobody: the next candidate is asked once (`shapeRefused`, `failShape`), and the last one's error reaches the agent. A request missing what every API requires ("field required") isn't one, nor is a 200 that mentions it. Command Code's Provider API turning a request away with nothing but a trace id (`unsaidWords`: `{"message":"invalid request error trace_id: <hex>","type":"invalid_request_error"}`, a 400, or a 422 before) is handled the same way: it turns away a request whose history and asked-for output together are over a limit below the model's listed context (the reporter's A/B: one ~748K-token agent conversation answered 200 with `max_completion_tokens` 64000 and this 400 with 384000, the model's listed max output), which another member's model may take, and the key is fine (#2313, `TestGroupFailsOverCommandCodesBare400`). Its overflow, which names the model's context length before the trace id, and an error that names a `param`, aren't one. A relay's own cap on one request's input that says so (`tooLongRe`: B.ai's 400 "Input token exceed the limit", on a 380K request under the model's 1M window; #2445, worksyang) is taken as an overflow (`overflowed`), which no word list of `retryable` matched: a group's next member that may hold the request is asked (`withRoom`, `failOverflow`), nobody rests, another account of the same model isn't asked, and with no member left the agent is told the conversation is too long, so it compacts. A rate limit worded with input tokens (`paceWords`) isn't one, and a plain bad request is still asked of nobody else (`TestRelayInputCapGoesToTheNextMember`). A subscription account that fails any other way with a window full, by magpie's latest reading of its windows, rests until that window renews. A 401 or 403 is the exception: one that names a quota is out of quota already (`usedUpWords`), and one that doesn't is about the key or the request, so it rests on the backoff ladder whatever the reading says (plugins#243, zygs1083-dotcom: a Factory account read at 98% sat out its week over one plain 403; `TestPlain403DoesNotRestUntilTheWindow`). A plain 403 (`plainForbidden`: no quota, credit, rate, verification, restriction or model not served) from a second key or account of the same provider, model and reasoning in one request is the request refused, not each account: neither rests, the first one's rest and counted failure are taken back (`forbiddenAlike`, `unforbid`), and the provider's other mates are asked last (`matesLast`). Before, that one request walked every account of the provider into backoff (`TestPlain403OnTwoMatesRestsNeither`). One account's plain 403 alone still rests it. Both quota rests and window rests are held to `longestQuota` (8 days), so a reset time read wrong (a year off) doesn't bench the account for that long. The next candidate is then tried. A failed provider waits `fallbackCooldown` (1 minute) at the back. A WorkBuddy account the vendor restricted (#1849: 403 `{"code":11140,"msg":"request illegal","displayMsg":{"en":"Your account has been restricted due to unusual activity",…}}`) rests `restrictedRest` (2 hours) as `restricted` (`failRestricted`), not the minutes of an unknown failure: only WorkBuddy lifting the restriction, after the user's appeal, brings it back. Both shapes are known: the built-in's `wbExplain` and the plugin's `explained()` (0.1.17, the mover's `min`) end the error with `provider.WBRestrictedHint` (`restrictedSaid`), and the vendor's own body, its code 11140 or its words (`provider.WBRestricted`), counts only from a WorkBuddy candidate (`restrictedRefused`, `isWorkBuddy`), as another vendor's 11140 is its own. Bare "request illegal" isn't matched. WorkBuddy's 11128 channel refusal stays `promptRefused` and rests nobody. The Routing page names it "account restricted by the vendor", says the appeal is the way back, and gives the account's row a button that lifts the rest (`/api/gateway/unrest`) once the vendor has. Every other rest a key or account takes (quota, rate limit, retry-after, a failure's backoff) can be lifted by hand the same way (#1869): "Try now" on its row on the Routing page and beside its rest note in the provider's key list. It ends the rest, and with Sink on puts the key back from the back of the order; the backoff count stays, and a refusal after it rests the key again the usual way. Every lift before its time (Try now, `UnrestAll` for a replaced key, `renewed` for windows that renewed) is noted by its rest key (`restingUntil.lifted`) and handed to the Routing page in the trace (`TraceState.Lifted`, `lifted` in `/api/gateway/trace`), and a lift wakes a page waiting on the trace though no route changed (`trace.lifted`). The page stops showing a rest or a sink found before its lift, wherever the lift was asked for (zoecats on Discord: Try now in the provider's editor left Routing at 429 until a restart; `TestTryNowToldToTheRoutingPage`, `routing-lifted-elsewhere.test.cjs`). With another magpie serving the gateway, Try now lifts nothing (#3555). The vendor's safety filter refusing a reply rests nobody, whether it refuses the turn before any of the reply is said or once some of it has been said (`refused`, `refusedAfter`). So does one said in a stream a client is answered whole from (a Codex account is streamed upstream for a `stream:false` Responses, Chat or Messages request): each decoder gives the refusal's error event status 400 and its code (`filterRefused`), a whole reply it cut is answered the refusal rather than its words so far, and Anthropic's error shape, which has no code, carries it in `refusedHeader`; before, it was answered 502 `api_error`, asked again, and each account rested (#3274). `restAfterMarked` itself rests nobody, and counts no failure, for a 400 whose error object `policyRefusal` reads as a refusal, by its code, never by words a body may echo of the request. Its note on the try (and in the error the agent gets when nobody is left) is the vendor's reason, with Anthropic's `stop_details` category and explanation when it gave them (`refusedDetail`, #1768: "safety filter: refusal (category cyber)"); none is made up when it gave none. `stop_details` is carried through the IR (`Event.StopDetails`), so a Claude subscription run through the claude CLI and a translated Anthropic route keep it for an Anthropic client too. How many more candidates a refusal before any of the reply is asked of is Settings' `RefusalRetries` (`refusalAsksAgain`, counted per request in the candidate loop; a group's other members count too): unset, every one left (#248); 0, none (#1925, DD on Discord). When nobody is left, an agent on Anthropic's Messages API gets the held refusal itself, the vendor's 200 with `stop_reason` `refusal` and its `stop_details`, streamed or whole (`holdWriter.handBack`), since that is what Claude Code switches to its fallback model on; a 400 is only an API error to it. Codex and Chat clients still get `failTo`'s 400 (`refusedStatus`), which they don't ask again for. `TestRefusalRetries*` in [`refusal_retries_test.go`](../../internal/gateway/refusal_retries_test.go) cover keys, a group and the Claude subscription. The ChatGPT backend's 502 "response protection is unavailable" is about the request's content, not the account: the same history fails the same on each of its accounts and models. It rests nobody, isn't tried again after a moment, and isn't asked of the provider's other accounts or models; another provider left in a group is asked once (`protectionRefused`, `elsewhere`). One cause is known (#1270): a history that replays the backend's own `web_search_call` in a request that doesn't declare the `web_search` tool is refused so, whatever the account, model or turn (a plain turn, a thread's description, a compaction, Codex's own text compaction for a custom provider with `tools: []`). Every request to the ChatGPT backend with such a history therefore declares cached-only search (`{"type":"web_search","external_web_access":false}`, `provider.DeclareSearch`): an account's in `codexBody`, Codex's own sign-in relayed in `codexUpstreamOn`. It goes in the tools, or for Responses Lite (its header, `reasoning.context` `all_turns`, or an `additional_tools` item already there), which refuses a top-level `web_search`, in the `additional_tools` item. A request that offered no tools gets `tool_choice` `none` so the model can't search; one with a forced choice keeps it. A history without a search, or a request that declares search already, is relayed unchanged; Codex's own `web.run` (a function in the `web` namespace, which Codex offers in place of the hosted tool on a Responses Lite model or with its standalone web search on, and runs through `/alpha/search`) counts as declaring it, since the backend refuses a request carrying both `web.run` and the hosted `web_search` (Savin on Discord, Codex 0.163.0-alpha; `TestSearchedConversationUnderWebRun`). siwc, API-key requests to openai.com and the legacy `/responses/compact` are left as they were. Command Code turning a model away for its Zero Data Retention setting (its plugin's switch, 0.1.14, which sends `x-cmd-zdr: 1`; magpie-community/plugins#246) is a refusal of that request's setting, not of the model or the account: the Provider API's 422 with `"code":"cmd_zdr_no_providers"` and the 400 the plugin makes of Go's error line with `"type":"cmd_zdr_no_providers"` (`zdrCoded`, matched as the error's code or type, never by its words, whose "…a different model.","type":"invalid_request_error" read as a model unserved and rested the model on the account). `keepRetry` notes it beside the error (`zdrHeader`), since the error the agent gets may keep no code (Anthropic's shape, or the 400's numeric code). It rests nobody, anywhere (`restAfterMarked` returns `by: "off"`), so the model answers as soon as the switch is off; it isn't asked of the provider's other accounts at that model, which carry the same header (`notMates`), nor again after a moment; another member, the provider's other models among them, is asked once, and with none left the agent gets Command Code's words (`TestCommandCodeZDRRefusalRestsNothing`, `TestZDRRefusalNeverRests`). Another vendor's refusal in the same words, without the code, still rests the model (`TestZDRRefusalIsCommandCodesCodeOnly`).
5. The last candidate's error reaches the agent, with one exception for a group (#1418, `patience.go`). When every member has failed in a way that passes (`busy`: 408, 500, 502, 503, 504 or 529 that isn't a proxy, a quota, response protection, or an upstream that answered a stream request with a whole reply, which fails the same however often it is asked (`didNotStream`; the same-one retries of `passing` leave it alone too, `TestStreamlessMemberIsAskedOnce`), or a 429 that is a short rate limit, not a plan or credit), and nothing of the reply has been sent, the members that failed so are asked again in turn after a pause (`replan`). The pause is `retryPause` doubled each round up to `replanLongest()` (30 times `retryPause`, 30s), and never shorter than the soonest Retry-After; a member whose Retry-After ends past the pause is asked after the others. This goes on while the group's `Patience` lasts. A member of a group in the group uses the innermost that sets `Patience` (`innerPatience`, #2410), as FirstToken (#2246) and Sink (#2255) do; unset falls back to the group asked for, and an inner `PatienceOff` skips replan for that member (`TestNestedGroupPatienceThroughOuter`, `TestNestedGroupPatienceInnerOff`, `TestNestedGroupPatienceFallsBackToOuter`). `replanRounds` (12) is only a backstop that never comes first: the pauses alone add up to `PatienceLongest` in 11 rounds (with 6, a group set to 240s gave up after 90s of pauses, real-jacket on #1418; `TestPatienceIsUsedUp`). The budget is the group's `Patience`, counted from the first time every member had failed, when the agent would have had the error (`waitFrom`; `Group.Waits`: 0 is `PatienceDefault`, 60s; -1, `PatienceOff`, turns it off; at most `PatienceLongest`, 240s). A pause that would end past the budget isn't taken, and the agent gets the error. While another member is busy too, the last one isn't first tried again alone (`passing`): the members take turns, and once the budget has begun, the same-one retries aren't taken either. While the budget lasts, the last candidate's failure is held (`newHoldWriter`), and a streaming agent is kept alive through the pause with SSE comments (`pauseAlive`). The try is traced with `Again` (the pause), `Replan` (how many are asked again) and `Patience` (the budget in seconds). The group editor's "Every member busy" row sets it. A plain provider keeps only the same-one retries `passing` gives the last one left. An agent that goes away in either pause (the same-one retry's or a group's replan) ends the request there with 499: nobody is asked again, and the try whose pause it was is marked `Gone` (#1894, heng91: a relay down while its proxy was off, the agent's window closed). The Routing page says the agent canceled the request before the retry and lists it as canceled, rather than ending its story on "tried again in 2s", a retry that never came (`TestAgentGoneInTheRetryPause`, `routing-agent-gone.test.cjs`). A try that answered is recorded (`served`, `answered`) for routing, affinity and usage. A try is added to the route's `Tries` only as it is asked, so a later try is the record that the gateway went on from this one, and the Routing page tells what came of a try from that, never from where it stood in the order (#2281, xishuchkui-code: an Antigravity 502 empty reply that went on to the next account was told as "an error another account wouldn't fix, so Claude Code gets it"). The one case the record can't show is the last try left out of its allowance after an earlier failure that wasn't one, where the agent is told the earlier error: that try is marked `Earlier` (`routing-went-on.test.cjs`).
diff --git a/docs/subsystems/gui-shell.md b/docs/subsystems/gui-shell.md
index 22a3fd1d8..4efb23a89 100644
--- a/docs/subsystems/gui-shell.md
+++ b/docs/subsystems/gui-shell.md
@@ -401,7 +401,7 @@ covers it in both engines, every language and a narrow window.
- Wails calls the tray's click handler both for the icon's click (`Activate`) and when the tray host opens the icon's menu (dbusmenu's "opened" event). KDE opens the menu on a right-click, and the panel that click opened took the focus and shut the menu on Wayland. On Linux the handler ignores the call when it comes from the menu opening (`menuOpening` in [`trayclick.go`](../../internal/gui/trayclick.go), which looks for Wails' `(*linuxSystemTray).Event` among its callers; `TestTrayMenuOpenFrameIsWails` fails if Wails renames it or stops calling the handler there) (#1430).
- On GTK 3 builds, the app gives GDK a font DPI before the first webview when it has none (`fontDPI`, [`fontdpi_gtk3.h`](../../internal/gui/fontdpi_gtk3.h)). GDK's unset value is -1, and WebKitGTK 2.54's GTK 3 settings reader multiplies it by 1024 unchecked, so every page lays out at a negative width with a 9000000px font (#1371). An unset DPI takes `gtk-xft-dpi`, or 96, times a valid `GDK_DPI_SCALE`; a positive one is left alone. Wails initialises GTK (its GtkApplication) only inside `Run` and makes each window from a default-idle-priority callback on the main loop, so `fontDPI`, called just before `Run`, queues the check as a `G_PRIORITY_HIGH` idle: it runs on the main thread after GTK's own start, before the first window. `TestFontDPIUnset` opens a real WebKitGTK page through `magpie_font_dpi` and needs a display (Xvfb).
- Tests never touch a live agent config. The package's `TestMain` runs under `testenv`'s home of its own. A macOS test that shows windows runs them in a process of its own through `runAppKit` ([`appkit_darwin_test.go`](../../internal/gui/appkit_darwin_test.go)). AppKit and WebKit take their home from the account, not from HOME, so `runAppKit` gives them a temporary one with `CFFIXED_USER_HOME`; appearance, contrast and languages still come from the account. The test fails when that process leaves a folder in the real `~/Library/WebKit` or `~/Library/Caches`. Playwright tests serve `assets/` with isolated `/api` fixtures.
-- `POST /api/settings/codex-auto-review` accepts an empty value (Codex's own choice), `session` (the session's own model when it is one of magpie's; "Same as the session" in the picker), or an exact model/group ID in `provider.Served`, including unlisted providers. A known provider with an unknown or empty model name is rejected without changing the saved reviewer or catalog tag. Generic gateway request resolution remains permissive; it is not the validator for this setting. See `Handler` in [`api.go`](../../internal/gui/api.go) and `TestCodexAutoReviewSetting` in [`codex_auto_review_test.go`](../../internal/gui/codex_auto_review_test.go).
+- `POST /api/settings/codex-auto-review` accepts an empty value (Codex's own choice, or the session's model when Codex's sign-in is on a Free plan), `session` (the session's own model when it is one of magpie's; "Same as the session" in the picker), or an exact model/group ID in `provider.Served`, including unlisted providers. A known provider with an unknown or empty model name is rejected without changing the saved reviewer or catalog tag. Generic gateway request resolution remains permissive; it is not the validator for this setting. See `Handler` in [`api.go`](../../internal/gui/api.go) and `TestCodexAutoReviewSetting` in [`codex_auto_review_test.go`](../../internal/gui/codex_auto_review_test.go).
- `Settings -> Sync and backup` and `/api/davsync/{action}` configure and run encrypted WebDAV, S3 or GitHub setup sync. They share the CLI's operations and expose credential presence, never the secrets. State, merge, failure and compatibility behavior are described in [Sync and backup](sync-backup.md).
`openModal` makes the background inert when an editor opens fresh, leaving
diff --git a/internal/codexcat/autoreview_test.go b/internal/codexcat/autoreview_test.go
index 322a6eab4..9d71b861b 100644
--- a/internal/codexcat/autoreview_test.go
+++ b/internal/codexcat/autoreview_test.go
@@ -109,3 +109,44 @@ func TestCodexAutoReviewFollowsTheSession(t *testing.T) {
}
}
}
+
+// cybercaius on Discord: codex-auto-review, kept as the default for being
+// free on a ChatGPT sign-in (#1593), is not free on a Free plan. With
+// nothing picked and Codex signed in to one, the review follows the
+// session; on another plan, or one magpie can't read, it stays Codex's
+// pick, and a model the user picked is kept on any plan.
+func TestCodexAutoReviewOnAFreePlan(t *testing.T) {
+ v1Home(t, `{"etag":"W/\"a\"","models":[{"slug":"gpt-6","base_instructions":"x"},{"slug":"gpt-8","base_instructions":"x","auto_review_model_override":"codex-auto-review"}]}`)
+ plan := "free"
+ was := SignInPlan
+ SignInPlan = func() string { return plan }
+ t.Cleanup(func() { SignInPlan = was })
+ ms := []catalog.Model{
+ {ID: "codex/gpt-6", Name: "GPT-6 · Codex"},
+ {ID: "codex/gpt-8", Name: "GPT-8 · Codex"},
+ {ID: "token/gpt-6.1-sol", Name: "GPT-6.1 Sol"},
+ }
+ check := func(what string, want map[string]any) {
+ t.Helper()
+ got := overrides(t, ms)
+ for k, v := range want {
+ if got[k] != v {
+ t.Fatalf("%s: %s = %v, want %v (%v)", what, k, got[k], v, got)
+ }
+ }
+ }
+ check("free", map[string]any{"codex/gpt-6": "none", "codex/gpt-8": "codex-auto-review", "token/gpt-6.1-sol": "token/gpt-6.1-sol"})
+ if got := AutoReviewModel(); got != settings.CodexAutoReviewSession {
+ t.Fatalf("free: in effect %q", got)
+ }
+ for _, plan = range []string{"plus", ""} {
+ check("plan "+plan, map[string]any{"codex/gpt-6": "none", "codex/gpt-8": "codex-auto-review", "token/gpt-6.1-sol": "none"})
+ }
+ plan = "free"
+ s := settings.Load()
+ s.CodexAutoReview = "deepseek/deepseek-flash"
+ if err := settings.Save(s); err != nil {
+ t.Fatal(err)
+ }
+ check("picked", map[string]any{"codex/gpt-6": "deepseek/deepseek-flash", "codex/gpt-8": "deepseek/deepseek-flash", "token/gpt-6.1-sol": "deepseek/deepseek-flash"})
+}
diff --git a/internal/codexcat/codexcat.go b/internal/codexcat/codexcat.go
index 9f1d33c9c..a8f8c055e 100644
--- a/internal/codexcat/codexcat.go
+++ b/internal/codexcat/codexcat.go
@@ -195,6 +195,7 @@ func entriesAt(ms []catalog.Model, after int, effort string) []any {
own := CacheEntries()
v1 := V1()
work := settings.Load()
+ autoReview := AutoReviewModel()
var entries []any
for i, m := range ms {
if raw, ok := own[strings.TrimPrefix(m.ID, "codex/")]; ok && strings.HasPrefix(m.ID, "codex/") {
@@ -206,7 +207,7 @@ func entriesAt(ms []catalog.Model, after int, effort string) []any {
if v1 {
Stamp(e)
}
- AutoReview(e)
+ AutoReview(e, autoReview)
entries = append(entries, e)
continue
}
@@ -216,7 +217,7 @@ func entriesAt(ms []catalog.Model, after int, effort string) []any {
Shell: "unified_exec", Visibility: "list", InAPI: true, Priority: after + i + 1,
ApplyPatch: "freeform", Tools: []string{}, Modalities: []string{"text"},
Tiers: []tier{}, SearchTool: true, Parallel: true,
- AutoReview: work.CodexAutoReview,
+ AutoReview: autoReview,
}
if e.AutoReview == settings.CodexAutoReviewSession {
e.AutoReview = m.ID
@@ -616,12 +617,34 @@ func unstamp(e map[string]any, was string) {
// own are left as OpenAI gave them, so the review runs on the session's
// model.
-// AutoReview has one of Codex's own entries name the auto-review model the
-// user picked. With none picked, one magpie put there before — a magpie id,
+// SignInPlan is the plan of the ChatGPT account this machine's Codex is
+// signed in to, as its ID token names it ("free", "plus", "pro" …), ""
+// when it is unknown or Codex isn't signed in (provider.CodexSignInPlan).
+var SignInPlan func() string
+
+// AutoReviewModel is the auto-review setting in effect:
+// settings.CodexAutoReview, but with nothing picked and Codex signed in
+// to a Free ChatGPT plan, the session's (settings.CodexAutoReviewSession).
+// Left to Codex the review runs on codex-auto-review, kept as the default
+// for being free on a ChatGPT sign-in (#1593, from a paid account); on a
+// Free plan it is not (cybercaius on Discord measured it spending the
+// plan's allowance), so there it follows the session as Codex's other
+// side calls do. A plan magpie can't read keeps Codex's pick.
+func AutoReviewModel() string {
+ v := settings.Load().CodexAutoReview
+ if v == "" && SignInPlan != nil && strings.EqualFold(strings.TrimSpace(SignInPlan()), "free") {
+ return settings.CodexAutoReviewSession
+ }
+ return v
+}
+
+// AutoReview has one of Codex's own entries name the auto-review model in
+// effect, v (AutoReviewModel, read once for a whole list: it reads Codex's
+// sign-in). With none picked, one magpie put there before — a magpie id,
// which has a "/" where OpenAI's slugs have none, kept in Codex's cache — is
// taken out, and one OpenAI gave it is left.
-func AutoReview(e map[string]any) {
- if v := settings.Load().CodexAutoReview; v != "" && v != settings.CodexAutoReviewSession {
+func AutoReview(e map[string]any, v string) {
+ if v != "" && v != settings.CodexAutoReviewSession {
e["auto_review_model_override"] = v
} else if was, _ := e["auto_review_model_override"].(string); strings.Contains(was, "/") {
delete(e, "auto_review_model_override")
diff --git a/internal/gateway/account_cap_test.go b/internal/gateway/account_cap_test.go
index 380683de6..a6f0cfc44 100644
--- a/internal/gateway/account_cap_test.go
+++ b/internal/gateway/account_cap_test.go
@@ -1,8 +1,12 @@
package gateway
import (
+ "encoding/base64"
+ "encoding/json"
"fmt"
"net/http/httptest"
+ "os"
+ "path/filepath"
"strings"
"testing"
"time"
@@ -264,3 +268,33 @@ func TestAccountCapLetsAutoReviewThrough(t *testing.T) {
}
}
}
+
+// On a Free ChatGPT plan codex-auto-review is not free (cybercaius on
+// Discord), so the account's usage cap holds it as any call.
+func TestAccountCapHoldsAutoReviewOnAFreePlan(t *testing.T) {
+ codexSignedIn(t)
+ home, _ := os.UserHomeDir()
+ claims := func(m map[string]any) string {
+ b, _ := json.Marshal(m)
+ return "h." + base64.RawURLEncoding.EncodeToString(b) + ".s"
+ }
+ os.WriteFile(filepath.Join(home, ".codex", "auth.json"), mustJSON(map[string]any{"auth_mode": "chatgpt", "tokens": map[string]any{
+ "id_token": claims(map[string]any{"email": "[email protected]", "https://api.openai.com/auth": map[string]any{"chatgpt_plan_type": "free"}}),
+ "access_token": claims(map[string]any{"exp": time.Now().Add(time.Hour).Unix(), "who": "acct-1"}),
+ "refresh_token": "r-acct-1", "account_id": "acct-1"}}), 0o600)
+ provider.ForgetAccounts()
+ b := newResetBackend(t)
+ capUsage(t, map[string]float64{"[email protected]": 92})
+ if err := provider.SetAccountCap("codex", "[email protected]", 90); err != nil {
+ t.Fatal(err)
+ }
+ srv := New()
+ rec := httptest.NewRecorder()
+ req := httptest.NewRequest("POST", CodexPath+"/responses", strings.NewReader(`{"model":"codex-auto-review","stream":true,"input":"review this"}`))
+ req.Header.Set("Authorization", "Bearer chatgpt-token")
+ req.Header.Set("chatgpt-account-id", "acct-1")
+ srv.Handler().ServeHTTP(rec, req)
+ if tried, _ := b.seen(); rec.Code != 429 || !strings.Contains(rec.Body.String(), "usage cap reached") || tried != "" {
+ t.Errorf("free plan: %d %s tried %q", rec.Code, rec.Body.String(), tried)
+ }
+}
diff --git a/internal/gateway/codex_backend.go b/internal/gateway/codex_backend.go
index fd5806437..91b948f6e 100644
--- a/internal/gateway/codex_backend.go
+++ b/internal/gateway/codex_backend.go
@@ -1873,9 +1873,10 @@ func (s *Server) codexModels(w http.ResponseWriter, r *http.Request) {
}
}
// and the auto-review model the user picked (#938)
+ autoReview := codexcat.AutoReviewModel()
for _, m := range own {
if o, ok := m.(map[string]any); ok {
- codexcat.AutoReview(o)
+ codexcat.AutoReview(o, autoReview)
}
}
// a Codex here for account failover alone, not connected to magpie,
diff --git a/internal/gateway/codex_memory.go b/internal/gateway/codex_memory.go
index 5f2b7f769..6c788dfa1 100644
--- a/internal/gateway/codex_memory.go
+++ b/internal/gateway/codex_memory.go
@@ -39,13 +39,14 @@ func isReviewCall(kind, asked string) bool {
return kind == "guardian" || asked == "codex-auto-review"
}
-// freeOnChatGPT says whether a ChatGPT sign-in's call on model is free,
-// counted in none of its usage windows: Codex's reviewer model,
-// codex-auto-review, since OpenAI made Auto-review free for every ChatGPT
-// sign-in on 2026-10-06 (#1593, hywang1230). A review run on another
-// model, or through an API key, is counted as any call.
-func freeOnChatGPT(model string) bool {
- return strings.EqualFold(strings.TrimSpace(model), "codex-auto-review")
+// freeOnChatGPT says whether a call on model by a ChatGPT account on plan
+// is free, counted in none of its usage windows: Codex's reviewer model,
+// codex-auto-review, since OpenAI made Auto-review free for ChatGPT
+// sign-ins on 2026-10-06 (#1593, hywang1230), but not on a Free plan,
+// where cybercaius on Discord measured it spending the allowance. A review
+// run on another model, or through an API key, is counted as any call.
+func freeOnChatGPT(model, plan string) bool {
+ return strings.EqualFold(strings.TrimSpace(model), "codex-auto-review") && !strings.EqualFold(strings.TrimSpace(plan), "free")
}
// codexMemoryStandIn is the model a Codex memory call goes to when magpie
diff --git a/internal/gateway/fallback.go b/internal/gateway/fallback.go
index e3f6342d3..b39b5500f 100644
--- a/internal/gateway/fallback.go
+++ b/internal/gateway/fallback.go
@@ -645,7 +645,7 @@ func capHeld(p, acct provider.Provider, model string, now time.Time) *capHold {
}
a := acct.Account
caps := provider.HoldCaps(p, a.Agent, a.User)
- if a.Agent == "codex" && freeOnChatGPT(model) {
+ if a.Agent == "codex" && freeOnChatGPT(model, a.Plan) {
// a call ChatGPT counts in no window spends nothing a usage cap
// keeps (#1593); credits set not to be spent still hold it at
// 100%, as nothing says the backend answers it there
diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js
index 26b098215..3a466315b 100644
--- a/internal/gui/assets/app.js
+++ b/internal/gui/assets/app.js
@@ -19598,7 +19598,7 @@ function renderSettings() {
["#codexTitlesRow", "Names each thread in a hidden request of its own; same as the session, it goes on the session’s model, as Codex sends it when that is one of Codex’s own"],
["#codexDescriptionsRow", "Writes each thread’s short description in a hidden request of its own; same as the session, it goes on the session’s model, as Codex sends it when that is one of Codex’s own"],
["#codexPredictionsRow", "Guesses your next message for the composer, reading the whole conversation again each time; same as the session, it goes on the session’s model"],
- ["#codexAutoReviewRow", "Decides an approval in your place when Codex’s approvals are on auto-review; Codex’s own pick is codex-auto-review, else the conversation’s model at low effort"],
+ ["#codexAutoReviewRow", "Decides an approval in your place when Codex’s approvals are on auto-review; Codex’s own pick is codex-auto-review, else the conversation’s model at low effort; on a ChatGPT Free plan, where codex-auto-review isn’t free, unset follows the session"],
["#codexMemoriesRow", "Writes Codex’s memories of past threads, in the background; same as the session, on the session’s model, or on gpt-5.6-terra and gpt-5.6-luna when that is one of Codex’s own"],
["#loginRow", document.body.classList.contains("mac")
? "Opens in the menu bar with no window. System Settings › General › Login Items lists it under App Background Activity, not Open at Login"
diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js
index 3809bd9ce..6fe1cb86a 100644
--- a/internal/gui/assets/i18n.js
+++ b/internal/gui/assets/i18n.js
@@ -862,7 +862,7 @@ const I18N = {
"Names each thread in a hidden request of its own; same as the session, it goes on the session’s model, as Codex sends it when that is one of Codex’s own": "为每个会话起标题,是 Codex 单独发出的隐藏请求;跟随当前会话时用会话的模型,会话在 Codex 自带模型上时按 Codex 原样发送",
"Writes each thread’s short description in a hidden request of its own; same as the session, it goes on the session’s model, as Codex sends it when that is one of Codex’s own": "为每个会话写简短描述,是 Codex 单独发出的隐藏请求;跟随当前会话时用会话的模型,会话在 Codex 自带模型上时按 Codex 原样发送",
"Guesses your next message for the composer, reading the whole conversation again each time; same as the session, it goes on the session’s model": "为输入框猜测你的下一条消息,每次都把整段对话重读一遍;跟随当前会话时用会话的模型",
- "Decides an approval in your place when Codex’s approvals are on auto-review; Codex’s own pick is codex-auto-review, else the conversation’s model at low effort": "Codex 的审批设为自动审批时,代你决定是否批准;由 Codex 决定时用 codex-auto-review,没有则用当前对话的模型(低推理)",
+ "Decides an approval in your place when Codex’s approvals are on auto-review; Codex’s own pick is codex-auto-review, else the conversation’s model at low effort; on a ChatGPT Free plan, where codex-auto-review isn’t free, unset follows the session": "Codex 的审批设为自动审批时,代你决定是否批准;由 Codex 决定时用 codex-auto-review,没有则用当前对话的模型(低推理);ChatGPT 免费版上 codex-auto-review 不免费,未设置时跟随当前会话",
"Writes Codex’s memories of past threads, in the background; same as the session, on the session’s model, or on gpt-5.6-terra and gpt-5.6-luna when that is one of Codex’s own": "在后台把过去的会话整理成 Codex 的记忆;跟随当前会话时用会话的模型,会话在 Codex 自带模型上时用 gpt-5.6-terra 和 gpt-5.6-luna",
"Switched off in System Settings’ Login Items, so magpie won’t open at login": "已在系统设置的登录项里关闭,登录时不会打开 magpie",
"Open Login Items": "打开登录项",
@@ -4836,7 +4836,7 @@ const I18N = {
"Names each thread in a hidden request of its own; same as the session, it goes on the session’s model, as Codex sends it when that is one of Codex’s own": "為每個會話起標題,是 Codex 單獨發出的隱藏請求;跟隨目前工作階段時用工作階段的模型,工作階段在 Codex 自帶模型上時按 Codex 原樣傳送",
"Writes each thread’s short description in a hidden request of its own; same as the session, it goes on the session’s model, as Codex sends it when that is one of Codex’s own": "為每個會話寫簡短描述,是 Codex 單獨發出的隱藏請求;跟隨目前工作階段時用工作階段的模型,工作階段在 Codex 自帶模型上時按 Codex 原樣傳送",
"Guesses your next message for the composer, reading the whole conversation again each time; same as the session, it goes on the session’s model": "為輸入框猜測你的下一則訊息,每次都把整段對話重讀一遍;跟隨目前工作階段時用工作階段的模型",
- "Decides an approval in your place when Codex’s approvals are on auto-review; Codex’s own pick is codex-auto-review, else the conversation’s model at low effort": "Codex 的審批設為自動審批時,代你決定是否批准;由 Codex 決定時用 codex-auto-review,沒有則用目前對話的模型(低推理)",
+ "Decides an approval in your place when Codex’s approvals are on auto-review; Codex’s own pick is codex-auto-review, else the conversation’s model at low effort; on a ChatGPT Free plan, where codex-auto-review isn’t free, unset follows the session": "Codex 的審批設為自動審批時,代你決定是否批准;由 Codex 決定時用 codex-auto-review,沒有則用目前對話的模型(低推理);ChatGPT 免費版上 codex-auto-review 不免費,未設定時跟隨目前工作階段",
"Writes Codex’s memories of past threads, in the background; same as the session, on the session’s model, or on gpt-5.6-terra and gpt-5.6-luna when that is one of Codex’s own": "在背景把過去的會話整理成 Codex 的記憶;跟隨目前工作階段時用工作階段的模型,工作階段在 Codex 自帶模型上時用 gpt-5.6-terra 和 gpt-5.6-luna",
"Switched off in System Settings’ Login Items, so magpie won’t open at login": "已在系統設定的登入項目裡關閉,登入時不會開啟 magpie",
"Open Login Items": "打開登入項目",
@@ -8782,7 +8782,7 @@ const I18N = {
"Names each thread in a hidden request of its own; same as the session, it goes on the session’s model, as Codex sends it when that is one of Codex’s own": "各スレッドに題名を付ける、Codex 独自の隠れたリクエスト。セッションと同じなら、セッションのモデルで送られ、それが Codex 自身のモデルなら Codex が送るとおりに送られます",
"Writes each thread’s short description in a hidden request of its own; same as the session, it goes on the session’s model, as Codex sends it when that is one of Codex’s own": "各スレッドの短い説明を書く、Codex 独自の隠れたリクエスト。セッションと同じなら、セッションのモデルで送られ、それが Codex 自身のモデルなら Codex が送るとおりに送られます",
"Guesses your next message for the composer, reading the whole conversation again each time; same as the session, it goes on the session’s model": "入力欄に次のメッセージを予測し、そのたびに会話全体を読み直します。セッションと同じなら、セッションのモデルで送られます",
- "Decides an approval in your place when Codex’s approvals are on auto-review; Codex’s own pick is codex-auto-review, else the conversation’s model at low effort": "Codex の承認が自動レビューのとき、あなたの代わりに承認を判断します。Codex に任せると codex-auto-review、なければ会話のモデル(低い推論)",
+ "Decides an approval in your place when Codex’s approvals are on auto-review; Codex’s own pick is codex-auto-review, else the conversation’s model at low effort; on a ChatGPT Free plan, where codex-auto-review isn’t free, unset follows the session": "Codex の承認が自動レビューのとき、あなたの代わりに承認を判断します。Codex に任せると codex-auto-review、なければ会話のモデル(低い推論)。ChatGPT の Free プランでは codex-auto-review が無料ではないため、未設定ならセッションと同じモデルを使います",
"Writes Codex’s memories of past threads, in the background; same as the session, on the session’s model, or on gpt-5.6-terra and gpt-5.6-luna when that is one of Codex’s own": "過去のスレッドを Codex のメモリにバックグラウンドでまとめます。セッションと同じなら、セッションのモデルで、それが Codex 自身のモデルなら gpt-5.6-terra と gpt-5.6-luna で",
"Switched off in System Settings’ Login Items, so magpie won’t open at login": "システム設定のログイン項目でオフになっているため、ログイン時に magpie は開きません",
"Open Login Items": "ログイン項目を開く",
@@ -12742,7 +12742,7 @@ const I18N = {
"Names each thread in a hidden request of its own; same as the session, it goes on the session’s model, as Codex sends it when that is one of Codex’s own": "Benennt jeden Thread in einer eigenen versteckten Anfrage; bei „Wie die Sitzung“ geht sie auf das Modell der Sitzung, wie Codex sie sendet, wenn es ein eigenes von Codex ist",
"Writes each thread’s short description in a hidden request of its own; same as the session, it goes on the session’s model, as Codex sends it when that is one of Codex’s own": "Schreibt die Kurzbeschreibung jedes Threads in einer eigenen versteckten Anfrage; bei „Wie die Sitzung“ geht sie auf das Modell der Sitzung, wie Codex sie sendet, wenn es ein eigenes von Codex ist",
"Guesses your next message for the composer, reading the whole conversation again each time; same as the session, it goes on the session’s model": "Errät Ihre nächste Nachricht fürs Eingabefeld und liest dafür jedes Mal das ganze Gespräch neu; bei „Wie die Sitzung“ mit dem Modell der Sitzung",
- "Decides an approval in your place when Codex’s approvals are on auto-review; Codex’s own pick is codex-auto-review, else the conversation’s model at low effort": "Entscheidet eine Freigabe an Ihrer Stelle, wenn Codex’ Freigaben auf Auto-Review stehen; „Wie Codex es wählt“ ist codex-auto-review, sonst das Modell des Gesprächs mit wenig Reasoning",
+ "Decides an approval in your place when Codex’s approvals are on auto-review; Codex’s own pick is codex-auto-review, else the conversation’s model at low effort; on a ChatGPT Free plan, where codex-auto-review isn’t free, unset follows the session": "Entscheidet eine Freigabe an Ihrer Stelle, wenn Codex’ Freigaben auf Auto-Review stehen; „Wie Codex es wählt“ ist codex-auto-review, sonst das Modell des Gesprächs mit wenig Reasoning; im kostenlosen ChatGPT-Plan, in dem codex-auto-review nicht kostenlos ist, folgt es ohne Auswahl der Sitzung",
"Writes Codex’s memories of past threads, in the background; same as the session, on the session’s model, or on gpt-5.6-terra and gpt-5.6-luna when that is one of Codex’s own": "Schreibt im Hintergrund Codex’ Erinnerungen an frühere Threads; bei „Wie die Sitzung“ mit dem Modell der Sitzung, mit gpt-5.6-terra und gpt-5.6-luna, wenn es ein eigenes von Codex ist",
"Switched off in System Settings’ Login Items, so magpie won’t open at login": "In den Systemeinstellungen unter „Anmeldeobjekte“ ausgeschaltet, daher öffnet sich magpie bei der Anmeldung nicht",
"Open Login Items": "Anmeldeobjekte öffnen",
diff --git a/internal/provider/account_test.go b/internal/provider/account_test.go
index 885e27e59..89c513409 100644
--- a/internal/provider/account_test.go
+++ b/internal/provider/account_test.go
@@ -17,6 +17,7 @@ import (
"time"
"github.com/yetone/magpie/internal/catalog"
+ "github.com/yetone/magpie/internal/codexcat"
"github.com/yetone/magpie/internal/testenv"
)
@@ -630,3 +631,19 @@ func TestClaudeCredentialsMarshalLeavesTheBlob(t *testing.T) {
t.Fatalf("the blob was written into: %v", o)
}
}
+
+// CodexSignInPlan reads the plan from Codex's own sign-in, and codexcat
+// asks it there (the auto-review default on a Free plan, cybercaius).
+func TestCodexSignInPlan(t *testing.T) {
+ home := signIn(t)
+ if got := CodexSignInPlan(); got != "pro" {
+ t.Fatalf("plan %q", got)
+ }
+ if codexcat.SignInPlan == nil || codexcat.SignInPlan() != "pro" {
+ t.Fatal("codexcat doesn't read the sign-in's plan")
+ }
+ os.Remove(filepath.Join(home, ".codex", "auth.json"))
+ if got := CodexSignInPlan(); got != "" {
+ t.Fatalf("signed out: plan %q", got)
+ }
+}
diff --git a/internal/provider/codex_models.go b/internal/provider/codex_models.go
index 3ceea0bba..5079a74fd 100644
--- a/internal/provider/codex_models.go
+++ b/internal/provider/codex_models.go
@@ -524,7 +524,7 @@ func buildCodexListTag(kind string) string {
ms = append(ms, catalog.Model{ID: "~compact", Context: n})
}
// and the model Codex's auto-review runs on (#938)
- if v := settings.Load().CodexAutoReview; v != "" {
+ if v := codexcat.AutoReviewModel(); v != "" {
ms = append(ms, catalog.Model{ID: "~autoreview:" + v})
}
// and the effort new sessions start at, which magpie's models take as
diff --git a/internal/provider/logins.go b/internal/provider/logins.go
index da534af71..5d9847387 100644
--- a/internal/provider/logins.go
+++ b/internal/provider/logins.go
@@ -27,6 +27,7 @@ import (
"time"
"github.com/yetone/magpie/internal/appdir"
+ "github.com/yetone/magpie/internal/codexcat"
"github.com/yetone/magpie/internal/edit"
"github.com/yetone/magpie/internal/filelock"
"github.com/yetone/magpie/internal/filememo"
@@ -702,6 +703,18 @@ func liveLogin(agent string) (savedLogin, bool) {
return savedLogin{}, false
}
+// CodexSignInPlan is the plan of the ChatGPT account this machine's Codex
+// is signed in to, as its ID token's chatgpt_plan_type names it ("free",
+// "plus", "pro" …), "" when Codex isn't signed in or it can't be read.
+// Codex's auto-review follows the session on a Free plan by default
+// (codexcat.AutoReviewModel).
+func CodexSignInPlan() string {
+ l, _ := liveLogin("codex")
+ return l.Plan
+}
+
+func init() { codexcat.SignInPlan = CodexSignInPlan }
+
// codexLoginIn is the ChatGPT account Codex is signed in to in its folder
// home, as Codex keeps it there (auth.json, or the keychain item named by
// the folder).