Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
codex: subagents and memories follow the session's magpie model; auto-review can too (cybercaius on Discord)
yetonea1174674da9d
diff --git a/docs/subsystems/gateway-routing.md b/docs/subsystems/gateway-routing.mdindex d8b60c3fd..796cbeccc 100644--- a/docs/subsystems/gateway-routing.md+++ b/docs/subsystems/gateway-routing.md@@ -100,6 +100,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). 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).- 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.diff --git a/docs/subsystems/gui-shell.md b/docs/subsystems/gui-shell.mdindex a0a6e1ec9..22a3fd1d8 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) 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), `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, leavingdiff --git a/internal/agent/codex.go b/internal/agent/codex.goindex a7c396b7b..201d04453 100644--- a/internal/agent/codex.go+++ b/internal/agent/codex.go@@ -2024,6 +2024,28 @@ func CodexSideModel() string {return codex(home).SideModel()}+// CodexSideSet says whether this machine's Codex config names the model+// for a side call itself: "subagent" for [agents] default_subagent_model,+// "memories" for [memories] extract_model or consolidation_model. A config+// that can't be read counts as set, so the gateway leaves the call as Codex+// sent it (gateway.CodexSideSet).+func CodexSideSet(which string) bool {+ home, err := os.UserHomeDir()+ if err != nil {+ return true+ }+ path := filepath.Join(here(home).codexHome(), "config.toml")+ switch which {+ case "subagent":+ t, err := edit.GetTOMLTable(path, "agents")+ return err != nil || t["default_subagent_model"] != ""+ case "memories":+ t, err := edit.GetTOMLTable(path, "memories")+ return err != nil || t["extract_model"] != "" || t["consolidation_model"] != ""+ }+ return true+}+// codexChatGPT reports whether Codex is signed in to a ChatGPT account:// its built-in provider then runs and asks for the model list at// openai_base_url. Signed in with an API key alone, it asks for none.diff --git a/internal/agent/codex_side_test.go b/internal/agent/codex_side_test.goindex 01af457ca..71bc44fd2 100644--- a/internal/agent/codex_side_test.go+++ b/internal/agent/codex_side_test.go@@ -38,3 +38,26 @@ func TestCodexSideModel(t *testing.T) {t.Fatalf("magpie Codex's provider: %q", got)}}++// CodexSideSet says whether Codex's config names the model for its+// subagents or its memories itself, the gateway then leaving those calls+// as Codex sent them; a config it can't read counts as naming one.+func TestCodexSideSet(t *testing.T) {+ home, _ := codexHome(t, `{}`, "model = \"gpt-a\"\n")+ if CodexSideSet("subagent") || CodexSideSet("memories") {+ t.Fatal("nothing set")+ }+ config := filepath.Join(home, ".codex", "config.toml")+ os.WriteFile(config, []byte("[agents]\ndefault_subagent_model = \"gpt-b\"\n[memories]\nextract_model = \"gpt-c\"\n"), 0o644)+ if !CodexSideSet("subagent") || !CodexSideSet("memories") {+ t.Fatal("both set")+ }+ os.WriteFile(config, []byte("[agents]\ndefault_subagent_model = \"gpt-b\"\n"), 0o644)+ if !CodexSideSet("subagent") || CodexSideSet("memories") {+ t.Fatal("the subagents' alone")+ }+ os.WriteFile(config, []byte("[agents\n"), 0o644)+ if !CodexSideSet("memories") {+ t.Fatal("an unreadable config counts as set")+ }+}diff --git a/internal/cli/main.go b/internal/cli/main.goindex bc8dc1dc3..7750da29c 100644--- a/internal/cli/main.go+++ b/internal/cli/main.go@@ -319,6 +319,7 @@ func run(args []string) error {// for on a model of its own, on the model of magpie's picked beside// its ChatGPT sign-in rather than on that account (atom_Ray on X)gateway.CodexSideModel = agent.CodexSideModel+ gateway.CodexSideSet = agent.CodexSideSet// the setup kept the same on every computer, by whichever servesgateway.WhileServing = append(gateway.WhileServing, davsync.Run)// and dsh's patch lists, which dsh reads live: a route left behind bydiff --git a/internal/codexcat/autoreview_test.go b/internal/codexcat/autoreview_test.goindex c6c8d6c2a..322a6eab4 100644--- a/internal/codexcat/autoreview_test.go+++ b/internal/codexcat/autoreview_test.go@@ -80,3 +80,32 @@ func TestCodexAutoReviewChecked(t *testing.T) {t.Fatalf("saved %q", got)}}++// Set to "session" (cybercaius on Discord: left to Codex, a conversation+// on magpie's model had its auto-review on codex-auto-review through the+// ChatGPT sign-in), each of magpie's entries names itself, so the review+// runs on the session's model; Codex's own entries are left as OpenAI+// gave them, and one magpie put there before is taken out.+func TestCodexAutoReviewFollowsTheSession(t *testing.T) {+ v1Home(t, `{"etag":"W/\"a\"","models":[{"slug":"gpt-6","base_instructions":"x"},{"slug":"gpt-7","base_instructions":"x","auto_review_model_override":"deepseek/old"},{"slug":"gpt-8","base_instructions":"x","auto_review_model_override":"codex-auto-review"}]}`)+ s := settings.Load()+ s.CodexAutoReview = settings.CodexAutoReviewSession+ if err := settings.Save(s); err != nil {+ t.Fatal(err)+ }+ ms := []catalog.Model{+ {ID: "codex/gpt-6", Name: "GPT-6 · Codex"},+ {ID: "codex/gpt-7", Name: "GPT-7 · Codex"},+ {ID: "codex/gpt-8", Name: "GPT-8 · Codex"},+ {ID: "group/smart", Name: "smart"},+ {ID: "token/gpt-6.1-sol", Name: "GPT-6.1 Sol"},+ }+ got := overrides(t, ms)+ want := map[string]any{"codex/gpt-6": "none", "codex/gpt-7": "none", "codex/gpt-8": "codex-auto-review",+ "group/smart": "group/smart", "token/gpt-6.1-sol": "token/gpt-6.1-sol"}+ for k, v := range want {+ if got[k] != v {+ t.Fatalf("%s = %v, want %v (%v)", k, got[k], v, got)+ }+ }+}diff --git a/internal/codexcat/codexcat.go b/internal/codexcat/codexcat.goindex c6ee81253..9f1d33c9c 100644--- a/internal/codexcat/codexcat.go+++ b/internal/codexcat/codexcat.go@@ -218,6 +218,9 @@ func entriesAt(ms []catalog.Model, after int, effort string) []any {Tiers: []tier{}, SearchTool: true, Parallel: true,AutoReview: work.CodexAutoReview,}+ if e.AutoReview == settings.CodexAutoReviewSession {+ e.AutoReview = m.ID+ }// Fast mode: a ChatGPT account's GPT model Codex has no entry for,// or a group one is in, gets the tier Codex's own catalog gives its// GPT models@@ -608,14 +611,17 @@ func unstamp(e map[string]any, was string) {// place) runs on the auto_review_model_override of the conversation's// model's entry, else on codex-auto-review when the list has it, else on the// conversation's model at low effort (#938). With settings.CodexAutoReview-// every entry magpie hands Codex names that model.+// every entry magpie hands Codex names that model; set to+// settings.CodexAutoReviewSession, each of magpie's names itself and Codex's+// 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,// 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 != "" {+ if v := settings.Load().CodexAutoReview; 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/codex_backend.go b/internal/gateway/codex_backend.goindex 57b3629c2..d638837a6 100644--- a/internal/gateway/codex_backend.go+++ b/internal/gateway/codex_backend.go@@ -100,6 +100,10 @@ func (s *Server) codexBackend(w http.ResponseWriter, r *http.Request) {writeError(w, provider.Responses, 400, err.Error())return}+ // a turn of the conversation's own: the model its side calls may+ // follow (codexFollowTo)+ kind := requestCallKind(r.Header, requestSessionMetadata(r.Header, body))+ s.codexLeads.saw(r, kind, model)// a thread's title, where Settings sends it (#705) — the request// still on Codex's own model, through its sign-in, when it says// nothing of them@@ -123,9 +127,19 @@ func (s *Server) codexBackend(w http.ResponseWriter, r *http.Request) {// a subagent on one of Codex's own models, put on the model// set for Codex's subagents, a ChatGPT account's in magpie;// the request on the model asked for when it can't be, the- // trace saying why (codexUpstreamOn, serve)+ // trace saying why (codexUpstreamOn, serve). One with nothing+ // set for it, a subagent's or a memory call,+ // on the model its conversation is on when that is one of+ // magpie's, not on the ChatGPT sign-in (codexFollowTo)if !strings.Contains(model, "/") {- pick := codexSubagentPick(r, agentOf(r), requestCallKind(r.Header, requestSessionMetadata(r.Header, body)), model, body)+ pick := codexSubagentPick(r, agentOf(r), kind, model, body)+ if to := s.codexFollowTo(r, agentOf(r), kind, model, body); to != "" && pick == nil {+ if usage.PurposeOf(kind) == "kind:collab_spawn" {+ pick = &SubagentPick{Asked: model, To: to}+ } else {+ body, model = withModel(body, to), to+ }+ }r = withSubagentPick(r, pick)if pick.Moved() {body, model = withModel(body, pick.To), pick.Todiff --git a/internal/gateway/codex_follow.go b/internal/gateway/codex_follow.gonew file mode 100644index 000000000..8043f6568--- /dev/null+++ b/internal/gateway/codex_follow.go@@ -0,0 +1,141 @@+package gateway++import (+ "net/http"+ "strings"+ "sync"+ "time"++ "github.com/yetone/magpie/internal/access"+ "github.com/yetone/magpie/internal/provider"+ "github.com/yetone/magpie/internal/usage"+)++// Codex's side calls ask for one of Codex's own models by its bare name,+// whatever the conversation is on: a subagent goes on the model its lead+// names in spawn_agent (Codex lists its own first), its memories are+// written on gpt-5.6-luna and gpt-5.6-terra, its auto-review runs on+// codex-auto-review. With the conversation on one of magpie's models+// beside Codex's ChatGPT sign-in, each of those went to that ChatGPT+// account rather than where the user had routed Codex (cybercaius on+// Discord). With nothing set for them, a subagent and the memories follow+// the session: they go on the model the conversation's own turns go on,+// when that is one of magpie's. The auto-review follows it when set to+// (settings.CodexAutoReviewSession, which codexcat writes into each of+// magpie's entries); left to Codex it stays on codex-auto-review, which a+// ChatGPT sign-in runs free (#1593).++// CodexSideSet says whether Codex's own config names the model for a side+// call ("subagent": [agents] default_subagent_model; "memories": [memories]+// extract_model or consolidation_model), true when the config can't be+// read; nil leaves every such call as Codex sent it (agent.CodexSideSet).+var CodexSideSet func(which string) bool++// codexLeadsCap bounds how many conversations codexLeads keeps.+const codexLeadsCap = 512++// codexLeads is the model each Codex conversation's own turns last went+// on, by its thread id, and the one any of them last went on, by the+// gateway key it came with.+type codexLeads struct {+ mu sync.Mutex+ thread map[string]codexLead+ last map[string]string+}++type codexLead struct {+ model string+ at time.Time+}++// saw notes a turn of a Codex conversation's own (no call kind) on model.+func (l *codexLeads) saw(r *http.Request, kind, model string) {+ if kind != "" || model == "" {+ return+ }+ key := access.Caller(r.Context()).KeyID+ thread := sessionOf(r.Header)+ l.mu.Lock()+ defer l.mu.Unlock()+ if l.thread == nil {+ l.thread, l.last = map[string]codexLead{}, map[string]string{}+ }+ l.last[key] = model+ if thread == "" {+ return+ }+ if _, ok := l.thread[thread]; !ok && len(l.thread) >= codexLeadsCap {+ oldest, at := "", time.Time{}+ for id, v := range l.thread {+ if oldest == "" || v.at.Before(at) {+ oldest, at = id, v.at+ }+ }+ delete(l.thread, oldest)+ }+ l.thread[thread] = codexLead{model: model, at: time.Now()}+}++// of is the model the conversation a side call was made for is on: its+// parent thread's (a subagent's lead, a review's conversation), else its+// own thread's, else the one this key's Codex last had a turn on.+func (l *codexLeads) of(r *http.Request, body []byte) string {+ parent := requestSessionMetadata(r.Header, body).Parent+ if parent == "" {+ parent = strings.TrimSpace(r.Header.Get("x-codex-parent-thread-id"))+ }+ l.mu.Lock()+ defer l.mu.Unlock()+ for _, id := range []string{parent, sessionOf(r.Header)} {+ if v, ok := l.thread[id]; ok && id != "" {+ return v.model+ }+ }+ return l.last[access.Caller(r.Context()).KeyID]+}++// codexFollowTo is the model a Codex side call that asked for one of+// Codex's own models goes on instead: the session's, when it is one of+// magpie's and nothing is set for that call. "" leaves the call as it+// came: another call, a model of magpie's asked for, a model set for it, a+// conversation on one of Codex's own models, or a session model magpie+// can't serve it on now.+func (s *Server) codexFollowTo(r *http.Request, agent, kind, asked string, body []byte) string {+ if agent != "codex" && !fromCodex(r.Header) || asked == "" || strings.Contains(asked, "/") {+ return ""+ }+ which := ""+ switch {+ case usage.PurposeOf(kind) == "kind:collab_spawn":+ // a task the ChatGPT backend sealed opens only on a ChatGPT+ // account (codexSubagentPick)+ if provider.CodexSubagentModel() != "" || sealedTaskIn(body) {+ return ""+ }+ which = "subagent"+ case isMemoryKind(kind):+ which = "memories"+ default:+ return ""+ }+ to := s.codexLeads.of(r, body)+ if !strings.Contains(to, "/") || to == asked {+ return ""+ }+ if _, off := idOff(to); off {+ return ""+ }+ p, model, ok := provider.Resolve(to)+ if !ok {+ return ""+ }+ // the user's own pick in Codex's config is kept; read last, as it+ // reads the config+ if CodexSideSet == nil || CodexSideSet(which) {+ return ""+ }+ if who, held := keyHolds(r); held && !modelAllowed(who, p, model) {+ return ""+ }+ return to+}diff --git a/internal/gateway/codex_follow_test.go b/internal/gateway/codex_follow_test.gonew file mode 100644index 000000000..c74d658e1--- /dev/null+++ b/internal/gateway/codex_follow_test.go@@ -0,0 +1,101 @@+package gateway++import "testing"++// codexFollowSetup is Codex signed in to ChatGPT, its conversation put on+// a relay's model (third/gpt-6-astra) through magpie, and Codex's config+// naming no model for its subagents or memories unless set says so.+func codexFollowSetup(t *testing.T, set bool) (*chatgptSeen, *relayOfChatGPT, *Server) {+ t.Helper()+ up := codexSubagentSetup(t)+ relay := relayOn(t, "third")+ was := CodexSideSet+ CodexSideSet = func(string) bool { return set }+ t.Cleanup(func() { CodexSideSet = was })+ s := New()+ if rec := codexSubTurn(s, "third/gpt-6-astra", "lead-1", "", leadAsk); rec.Code != 200 {+ t.Fatalf("lead: %d %s", rec.Code, rec.Body.String())+ }+ return up, relay, s+}++// codexSide is one of Codex's side calls of kind on one of its own models.+func codexSide(t *testing.T, s *Server, kind, input string) {+ t.Helper()+ if rec := codexAsks(s, "gpt-5.5", kind, input); rec.Code != 200 {+ t.Fatalf("%s: %d %s", kind, rec.Code, rec.Body.String())+ }+}++// cybercaius on Discord: with Codex on a model routed through magpie, a+// subagent its lead put on one of Codex's own models, with no model set+// for subagents, went to the ChatGPT account. It follows the session now,+// and the trace says what it asked for.+func TestCodexSubagentFollowsTheSession(t *testing.T) {+ up, relay, s := codexFollowSetup(t, false)+ codexSide(t, s, "collab_spawn", plainTask)+ if got := up.asked(); len(got) != 0 {+ t.Fatalf("ChatGPT was asked for %v", got)+ }+ reqs := relay.requests()+ if len(reqs) != 2 || modelOf([]byte(reqs[1])) != "gpt-6-astra" {+ t.Fatalf("the relay got %d requests: %v", len(reqs), reqs)+ }+ r := lastRoute(s)+ if r.Subagent == nil || *r.Subagent != (SubagentPick{Asked: "gpt-5.5", To: "third/gpt-6-astra"}) {+ t.Fatalf("trace: model %q subagent %+v", r.Model, r.Subagent)+ }+}++// Codex's memories, written on gpt-5.6-luna and -terra whatever the+// conversation is on, follow it too.+func TestCodexMemoriesFollowTheSession(t *testing.T) {+ up, relay, s := codexFollowSetup(t, false)+ codexSide(t, s, "memgen", leadAsk)+ if got := up.asked(); len(got) != 0 {+ t.Fatalf("ChatGPT was asked for %v", got)+ }+ if reqs := relay.requests(); len(reqs) != 2 {+ t.Fatalf("the relay got %d requests", len(reqs))+ }+}++// A model Codex's config names for them is the user's own pick: the side+// calls go as Codex sent them.+func TestCodexSideCallsKeepTheConfigsModel(t *testing.T) {+ up, relay, s := codexFollowSetup(t, true)+ codexSide(t, s, "collab_spawn", plainTask)+ codexSide(t, s, "memgen", leadAsk)+ if got := up.asked(); len(got) != 2 || got[0] != "gpt-5.5" || got[1] != "gpt-5.5" {+ t.Fatalf("ChatGPT was asked for %v", got)+ }+ if reqs := relay.requests(); len(reqs) != 1 {+ t.Fatalf("the relay got %d requests", len(reqs))+ }+}++// A conversation on Codex's own model, and a task the ChatGPT backend+// sealed (which opens on a ChatGPT account alone), stay on ChatGPT.+func TestCodexSideCallsStayOnChatGPT(t *testing.T) {+ up := codexSubagentSetup(t)+ relay := relayOn(t, "third")+ was := CodexSideSet+ CodexSideSet = func(string) bool { return false }+ t.Cleanup(func() { CodexSideSet = was })+ s := New()+ codexSide(t, s, "", leadAsk)+ codexSide(t, s, "collab_spawn", plainTask)+ if got := up.asked(); len(got) != 2 {+ t.Fatalf("ChatGPT was asked for %v", got)+ }+ if rec := codexSubTurn(s, "third/gpt-6-astra", "lead-1", "", leadAsk); rec.Code != 200 {+ t.Fatalf("lead: %d", rec.Code)+ }+ codexSide(t, s, "collab_spawn", sealedTaskFernet)+ if got := up.asked(); len(got) != 3 || got[2] != "gpt-5.5" {+ t.Fatalf("ChatGPT was asked for %v", got)+ }+ if reqs := relay.requests(); len(reqs) != 1 {+ t.Fatalf("the relay got %d requests", len(reqs))+ }+}diff --git a/internal/gateway/gateway.go b/internal/gateway/gateway.goindex 78c2e1c54..324e79f22 100644--- a/internal/gateway/gateway.go+++ b/internal/gateway/gateway.go@@ -429,6 +429,9 @@ type Server struct {// codexTurns is the model each Codex last had a turn of its own// answered on, by caller (codexMemoryStandIn)codexTurns sync.Map+ // codexLeads is the model each Codex conversation's own turns last+ // went on, for its side calls to follow (codexFollowTo)+ codexLeads codexLeads// the listener, swapped when the gateway is shared on the network or// taken off it (see Relisten)lnMu sync.Mutexdiff --git a/internal/gui/api.go b/internal/gui/api.goindex 99c215b8f..20afc51cc 100644--- a/internal/gui/api.go+++ b/internal/gui/api.go@@ -1694,7 +1694,7 @@ func Handler(w Windows, gw *gateway.Server) http.Handler {return}v := strings.TrimSpace(in.Model)- if v != "" {+ if v != "" && v != settings.CodexAutoReviewSession {// Resolve intentionally accepts arbitrary names under a known// provider. An approval reviewer must be a model or group magpie// actually lists, including providers kept unlisted for routing.diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.jsindex d3122bddf..c7700034d 100644--- a/internal/gui/assets/app.js+++ b/internal/gui/assets/app.js@@ -3811,8 +3811,10 @@ const EXTRA_GLYPH = {[MEMORIES]: "M4.25 2.75h7.5v10.5h-7.5zM6.25 2.75v10.5M8.25 5.75h1.75M8.25 8h1.75",};// what Codex writes its memories with when none is set (codex-rs-// model-provider: memory_consolidation_preferred_model, _extraction_)-const MEMORIES_DEFAULT = "Codex's own: gpt-5.6-terra, threads summed up with gpt-5.6-luna";+// model-provider: memory_consolidation_preferred_model, _extraction_), or+// the session's when it is on magpie's (gateway codexFollowTo)+const MEMORIES_DEFAULT = "Codex's own: gpt-5.6-terra/luna, or the session's magpie model";+const SAME_SESSION = "Same as the session";function extraField(a, f) {if (f.key === "ultracode") return ultracodeToggle(a, f);const said = f.label === SUB_MODEL && codexSub(a) ? codexSubSaid(a, f) : null;@@ -19218,6 +19220,8 @@ async function loadSettings() {// went back to the old one when the read came in, the picker showing the// new).let prefsWrites = 0, prefsBusy = 0;+// prefWrite: a Settings write of its own, the page drawn again either way+function prefWrite(p) { return writingPrefs(p).then((ns) => { prefs = ns; renderSettings(); }).catch((e) => { status(t(e.message), "err"); renderSettings(); }); }async function writingPrefs(p) {prefsWrites++;prefsBusy++;@@ -19602,7 +19606,7 @@ function renderSettings() {]) $(row + " .who").title = t(en);// the system's record, set on its own, not with the other choices$("#loginSegs").replaceChildren(segs([["off", t("Off")], ["on", t("On")]], s.login ? "on" : "off", (v) =>- writingPrefs(api("settings/login", { on: v === "on" })).then((ns) => { prefs = ns; renderSettings(); }).catch((e) => { status(t(e.message), "err"); renderSettings(); })));+ prefWrite(api("settings/login", { on: v === "on" }))));renderLoginAllow(s);// Codex's and Claude Code's warm-ups and WorkBuddy's check-in, one tab// each over one card, the rows' names not saying the service again.@@ -21118,7 +21122,7 @@ function renderCodexDescriptions(s) {...models.map(opt)],onPick: (id) => {if (id === v) return;- writingPrefs(api("settings/codex-descriptions", { model: id })).then((ns) => { prefs = ns; renderSettings(); }).catch((e) => { status(t(e.message), "err"); renderSettings(); });+ prefWrite(api("settings/codex-descriptions", { model: id }));} }, b, ev);$("#codexDescriptionsPick").replaceChildren(b);}@@ -21146,7 +21150,7 @@ function renderCodexPredictions(s) {...models.map(opt)],onPick: (id) => {if (id === v) return;- writingPrefs(api("settings/codex-predictions", { model: id })).then((ns) => { prefs = ns; renderSettings(); }).catch((e) => { status(t(e.message), "err"); renderSettings(); });+ prefWrite(api("settings/codex-predictions", { model: id }));} }, b, ev);$("#codexPredictionsPick").replaceChildren(b);}@@ -21175,7 +21179,7 @@ function renderCodexTitles(s) {...models.map(opt)],onPick: (id) => {if (id === v) return;- writingPrefs(api("settings/codex-titles", { model: id })).then((ns) => { prefs = ns; renderSettings(); }).catch((e) => { status(t(e.message), "err"); renderSettings(); });+ prefWrite(api("settings/codex-titles", { model: id }));} }, b, ev);$("#codexTitlesPick").replaceChildren(b);}@@ -21183,7 +21187,8 @@ function renderCodexTitles(s) {// renderCodexAutoReview: the model Codex's auto-review — the reviewer that// decides an approval in the user's place — runs on (#938): Codex's own pick// (its codex-auto-review, else the conversation's model), or a model of-// magpie's named in every entry of the list magpie hands Codex.+// magpie's named in every entry of the list magpie hands Codex, or the+// session's own ("session": each of magpie's entries names itself).function renderCodexAutoReview(s) {const models = s.titleModels || [];const v = s.codexAutoReview || "";@@ -21191,15 +21196,16 @@ function renderCodexAutoReview(s) {const b = el("button", "rt-cond on");b.type = "button";b.setAttribute("aria-label", t("Codex auto-review model"));- if (v) b.append(icon(m?.icon || "generic"), el("span", "", m ? `${m.name || m.id} · ${m.providerName}` : v));+ if (v) b.append(icon(m?.icon || "generic"), el("span", "", m ? `${m.name || m.id} · ${m.providerName}` : v == "session" ? t(SAME_SESSION) : v));else b.append(icon("openai"), el("span", "", t("Codex’s own pick")));const opt = (x) => ({ value: x.id, label: x.name || x.id, note: x.providerName, icon: x.icon, group: x.provider ? x.providerName : ROUTING_GROUPS, ref: x.id });b.onclick = (ev) => openPicker({ id: "", name: "", fields: [] }, { key: "codexAutoReview", label: "model", value: v, options: [{ value: "", label: t("Codex’s own pick"), note: t("as Codex picks it"), icon: "openai", reset: true },+ { value: "session", label: t(SAME_SESSION), icon: "generic" },...models.map(opt)],onPick: (id) => {if (id === v) return;- writingPrefs(api("settings/codex-auto-review", { model: id })).then((ns) => { prefs = ns; renderSettings(); }).catch((e) => { status(t(e.message), "err"); renderSettings(); });+ prefWrite(api("settings/codex-auto-review", { model: id }));} }, b, ev);$("#codexAutoReviewPick").replaceChildren(b);}diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.jsindex 66db26b18..8607e2043 100644--- a/internal/gui/assets/i18n.js+++ b/internal/gui/assets/i18n.js@@ -722,7 +722,7 @@ const I18N = {"subagents": "子代理","subagent effort": "子代理推理强度","memories": "记忆整理模型",- "Codex's own: gpt-5.6-terra, threads summed up with gpt-5.6-luna": "Codex 自带的:整理用 gpt-5.6-terra,总结对话用 gpt-5.6-luna",+ "Codex's own: gpt-5.6-terra/luna, or the session's magpie model": "Codex 自带的 gpt-5.6-terra/luna,或会话正在用的 magpie 模型","opus effort": "opus 推理强度","sonnet effort": "sonnet 推理强度","haiku effort": "haiku 推理强度",@@ -1062,6 +1062,7 @@ const I18N = {"Codex auto-review model": "Codex 自动审批模型","Codex’s own pick": "由 Codex 决定","as Codex picks it": "按 Codex 默认选择",+ "Same as the session": "跟随当前会话","Codex memories model": "Codex 记忆整理模型","Same as the lead": "跟主代理一样","Each subagent runs on the lead's model ({model}), or on another the lead picks for it. Pick a model here to put every subagent on it.": "每个子代理都用主代理正在用的模型({model}),主代理也可能给某个子代理另选一个。在这里选定一个模型,所有子代理就都用它。",@@ -4698,7 +4699,7 @@ const I18N = {"subagents": "子代理","subagent effort": "子代理推理強度","memories": "記憶整理模型",- "Codex's own: gpt-5.6-terra, threads summed up with gpt-5.6-luna": "Codex 自帶的:整理用 gpt-5.6-terra,總結對話用 gpt-5.6-luna",+ "Codex's own: gpt-5.6-terra/luna, or the session's magpie model": "Codex 自帶的 gpt-5.6-terra/luna,或工作階段正在用的 magpie 模型","opus effort": "opus 推理強度","sonnet effort": "sonnet 推理強度","haiku effort": "haiku 推理強度",@@ -5031,6 +5032,7 @@ const I18N = {"Codex auto-review model": "Codex 自動審批模型","Codex’s own pick": "由 Codex 決定","as Codex picks it": "按 Codex 預設選擇",+ "Same as the session": "跟隨目前工作階段","Codex memories model": "Codex 記憶整理模型","Same as the lead": "跟主代理一樣","Each subagent runs on the lead's model ({model}), or on another the lead picks for it. Pick a model here to put every subagent on it.": "每個子代理都用主代理正在用的模型({model}),主代理也可能給某個子代理另選一個。在這裡選定一個模型,所有子代理就都用它。",@@ -8640,7 +8642,7 @@ const I18N = {"subagents": "サブエージェント","subagent effort": "サブエージェントの推論レベル","memories": "メモリ整理のモデル",- "Codex's own: gpt-5.6-terra, threads summed up with gpt-5.6-luna": "Codex の初期設定:整理は gpt-5.6-terra、スレッドの要約は gpt-5.6-luna",+ "Codex's own: gpt-5.6-terra/luna, or the session's magpie model": "Codex の初期設定(gpt-5.6-terra/luna)、またはセッションの magpie モデル","opus effort": "opus の推論レベル","sonnet effort": "sonnet の推論レベル","haiku effort": "haiku の推論レベル",@@ -8970,6 +8972,7 @@ const I18N = {"Codex auto-review model": "Codex 自動レビューのモデル","Codex’s own pick": "Codex に任せる","as Codex picks it": "Codex の既定どおり",+ "Same as the session": "セッションと同じ","Codex memories model": "Codex メモリ整理のモデル","Same as the lead": "リードと同じ","Each subagent runs on the lead's model ({model}), or on another the lead picks for it. Pick a model here to put every subagent on it.": "各サブエージェントはリードと同じモデル({model})で動きます。リードが別のモデルを選ぶこともあります。ここでモデルを選ぶと、すべてのサブエージェントがそのモデルになります。",@@ -12599,7 +12602,7 @@ const I18N = {"subagents": "Subagenten","subagent effort": "Reasoning-Effort der Subagenten","memories": "Modell für Erinnerungen",- "Codex's own: gpt-5.6-terra, threads summed up with gpt-5.6-luna": "Codex’ eigenes: gpt-5.6-terra, Threads zusammengefasst mit gpt-5.6-luna",+ "Codex's own: gpt-5.6-terra/luna, or the session's magpie model": "Codex’ eigenes: gpt-5.6-terra/luna, oder das magpie-Modell der Sitzung","opus effort": "Reasoning-Effort opus","sonnet effort": "Reasoning-Effort sonnet","haiku effort": "Reasoning-Effort haiku",@@ -12939,6 +12942,7 @@ const I18N = {"Codex auto-review model": "Modell für Codex’ Auto-Review","Codex’s own pick": "Wie Codex es wählt","as Codex picks it": "Codex’ Standard",+ "Same as the session": "Wie die Sitzung","Codex memories model": "Codex-Modell für Erinnerungen","Same as the lead": "Wie der Haupt-Agent","Each subagent runs on the lead's model ({model}), or on another the lead picks for it. Pick a model here to put every subagent on it.": "Jeder Subagent läuft auf dem Modell des Haupt-Agenten ({model}) oder auf einem anderen, das der Haupt-Agent für ihn wählt. Wähle hier ein Modell, damit alle Subagenten darauf laufen.",diff --git a/internal/gui/codex_auto_review_test.go b/internal/gui/codex_auto_review_test.goindex 3e34dbfc9..99d80dc84 100644--- a/internal/gui/codex_auto_review_test.go+++ b/internal/gui/codex_auto_review_test.go@@ -57,9 +57,10 @@ func TestCodexAutoReviewSetting(t *testing.T) {if code, _ := call("/api/settings", `{"theme":"dark"}`); code != 200 || settings.Load().CodexAutoReview != "fake/m1" {t.Errorf("another save (%d) lost the setting: %q", code, settings.Load().CodexAutoReview)}- // Groups and models of an unlisted provider are still valid targets.+ // Groups and models of an unlisted provider are still valid targets, and+ // "session", the session's own model.// Restore m1 before checking that rejected choices leave it in place.- for _, id := range []string{"group/checks", "hidden/reviewer", "fake/m1"} {+ for _, id := range []string{"group/checks", "hidden/reviewer", "session", "fake/m1"} {if code, _ := call("/api/settings/codex-auto-review", `{"model":"`+id+`"}`); code != 200 || settings.Load().CodexAutoReview != id {t.Fatalf("valid reviewer %s: %d, %q", id, code, settings.Load().CodexAutoReview)}diff --git a/internal/gui/tests/codex-auto-review.test.cjs b/internal/gui/tests/codex-auto-review.test.cjsindex 9955412f6..1ca36c948 100644--- a/internal/gui/tests/codex-auto-review.test.cjs+++ b/internal/gui/tests/codex-auto-review.test.cjs@@ -5,7 +5,8 @@// magpie's models and groups; a pick posts settings/codex-auto-review on its// own, its button shows the choice under a name alone (1ooogle on X), a refusal is said and the row keeps// what it had, and no click scrolls the Agents page, where Codex's row holds it.-// English and Chinese, Chromium and WebKit; no backend, the API is faked here.+// "Same as the session" runs it on the session's own model (cybercaius on+// Discord). Every language, Chromium and WebKit; no backend, the API is faked here.const assert = require("node:assert/strict");const fs = require("node:fs/promises");const path = require("node:path");@@ -70,13 +71,16 @@ function server(lang, posted) {}const want = {- en: { name: "Codex auto-review model", own: "Codex’s own pick" },- zh: { name: "Codex 自动审批模型", own: "由 Codex 决定" },+ en: { name: "Codex auto-review model", own: "Codex’s own pick", session: "Same as the session" },+ zh: { name: "Codex 自动审批模型", own: "由 Codex 决定", session: "跟随当前会话" },+ "zh-TW": { name: "Codex 自動審批模型", own: "由 Codex 決定", session: "跟隨目前工作階段" },+ ja: { name: "Codex 自動レビューのモデル", own: "Codex に任せる", session: "セッションと同じ" },+ de: { name: "Modell für Codex’ Auto-Review", own: "Wie Codex es wählt", session: "Wie die Sitzung" },};const view = (page) => page.locator("#view-agents").evaluate((v) => v.scrollTop);for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {- for (const lang of ["en", "zh"]) {+ for (const lang of Object.keys(want)) {test(`${engine} ${lang}: Codex's auto-review runs on the model Codex's settings pick`, async (t) => {const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));const context = await browser.newContext({ viewport: { width: 900, height: 480 }, reducedMotion: "reduce" });@@ -118,7 +122,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",await pick.click();await page.locator("#pop:not([hidden]) #list li").first().waitFor();const items = (await page.locator("#list li:not(.group)").allTextContents()).join("|");- for (const s of [want[lang].own, "DeepSeek V4 Flash", "cheap"]) assert(items.includes(s), `${s} in ${items}`);+ for (const s of [want[lang].own, want[lang].session, "DeepSeek V4 Flash", "cheap"]) assert(items.includes(s), `${s} in ${items}`);await page.locator("#list li:not(.group)").filter({ hasText: "DeepSeek V4 Flash" }).first().click();await page.locator("#codexAutoReviewPick button", { hasText: "DeepSeek V4 Flash" }).waitFor();assert.deepEqual(posted, [["codex-auto-review", { model: "deepseek/deepseek-v4-flash" }]]);@@ -132,6 +136,11 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",assert.deepEqual(posted.at(-1), ["codex-auto-review", { model: "group/cheap" }]);assert.match(await pick.textContent(), /DeepSeek V4 Flash/, "a refused pick changed the row");+ // the session's own model+ await choose(want[lang].session);+ await page.locator("#codexAutoReviewPick button", { hasText: want[lang].session }).waitFor();+ assert.deepEqual(posted.at(-1), ["codex-auto-review", { model: "session" }]);+// and back to Codex's own pickawait choose(want[lang].own);await page.locator("#codexAutoReviewPick button", { hasText: want[lang].own }).waitFor();diff --git a/internal/gui/tests/codex-memories.test.cjs b/internal/gui/tests/codex-memories.test.cjsindex 239d67f10..ca2db0980 100644--- a/internal/gui/tests/codex-memories.test.cjs+++ b/internal/gui/tests/codex-memories.test.cjs@@ -71,8 +71,8 @@ function server(lang, sets) {// the words as i18n.js has themconst W = {- en: { unset: "Codex memories model: Codex's own: gpt-5.6-terra, threads summed up with gpt-5.6-luna", def: "Default", set: "Codex memories model: GPT-5.4 mini" },- zh: { unset: "Codex 记忆整理模型:Codex 自带的:整理用 gpt-5.6-terra,总结对话用 gpt-5.6-luna", def: "默认", set: "Codex 记忆整理模型:GPT-5.4 mini" },+ en: { unset: "Codex memories model: Codex's own: gpt-5.6-terra/luna, or the session's magpie model", def: "Default", set: "Codex memories model: GPT-5.4 mini" },+ zh: { unset: "Codex 记忆整理模型:Codex 自带的 gpt-5.6-terra/luna,或会话正在用的 magpie 模型", def: "默认", set: "Codex 记忆整理模型:GPT-5.4 mini" },};const codex = '.row.agent[data-id="codex@wsl:Ubuntu-24.04"]';diff --git a/internal/settings/settings.go b/internal/settings/settings.goindex e42fd33ef..b31d3ccaf 100644--- a/internal/settings/settings.go+++ b/internal/settings/settings.go@@ -35,6 +35,10 @@ import ("github.com/yetone/magpie/internal/steady")+// CodexAutoReviewSession is the CodexAutoReview that runs Codex's+// auto-review on the session's own model.+const CodexAutoReviewSession = "session"+// Settings is what the user chose. "" and "system" both mean "follow the OS".type Settings struct {Theme string `json:"theme,omitempty"` // system | light | dark@@ -511,7 +515,10 @@ type Settings struct {// in every entry of the list magpie hands Codex as// auto_review_model_override, which Codex takes before its own// codex-auto-review or the conversation's model at low effort. ""- // leaves the list as it was.+ // leaves the list as it was. CodexAutoReviewSession has each of+ // magpie's entries name itself, so the review runs on the session's+ // model when that is one of magpie's, not on codex-auto-review through+ // the ChatGPT sign-in (cybercaius on Discord).CodexAutoReview string `json:"codexAutoReview,omitempty"`// CodexSubagentModel is the model the gateway puts every subagent// Codex spawns on (a request x-openai-subagent names collab_spawn),@@ -1521,7 +1528,7 @@ func save(s Settings, recording bool) error {return fmt.Errorf("the model for Codex's composer predictions must be a model's id such as openai/gpt-5-mini, or off, not %q", s.CodexPredictions)}s.CodexAutoReview = strings.TrimSpace(s.CodexAutoReview)- if s.CodexAutoReview != "" && !strings.Contains(s.CodexAutoReview, "/") {+ if s.CodexAutoReview != "" && s.CodexAutoReview != CodexAutoReviewSession && !strings.Contains(s.CodexAutoReview, "/") {return fmt.Errorf("the model for Codex's auto-review must be a model's id such as openai/gpt-5-mini, not %q", s.CodexAutoReview)}s.CodexSubagentModel = strings.TrimSpace(s.CodexSubagentModel)