Commit Graph
3 Commits
Author SHA1 Message Date
yetone 67c8f562cd codex: a subagent named a model goes on it with "Same as the lead" (mengxiao on Discord)
mengxiao left Codex's subagent model at "Same as the lead" in magpie,
asked the lead for a subagent on GPT-6.1 Terra, and magpie put the
subagent on the lead's model anyway. The cause was codexFollowTo
(internal/gateway/codex_follow.go): on the ChatGPT-sign-in path, a
collab_spawn request asking for one of Codex's bare models, with nothing
set in magpie or [agents] default_subagent_model, was moved onto the
model the conversation's own turns go on (a1174674d, cybercaius).

Codex starts a spawn that names no model on its lead's model (codex-rs
core/src/agent/child_config.rs: build_agent_spawn_config sets the
child's model to the step's slug; apply_requested_spawn_agent_model_
overrides takes spawn_agent's model, else default_subagent_model; a
role's config can set one too). So under a lead on a magpie model, a
bare model in a subagent's request was always named by the lead, the
config or a role: the user's or the lead's pick. The GUI already says
"Same as the lead" means "the lead's model, or another the lead picks".

- codexFollowTo now handles memory calls only; a subagent is moved only
  by the model set for Codex's subagents in magpie (codexSubagentPick,
  unchanged). codex_backend.go no longer builds a pick from it.
- Dead code out: codexSessionOf, codexLeads.of, and CodexSideSet's
  "subagent" case (its doc moved onto servedSession).
- docs/subsystems/gateway-routing.md says a subagent never follows.
- Sibling checked: Claude Code writes no CLAUDE_CODE_SUBAGENT_MODEL
  while following the main model, and Claude Code takes the Agent call's
  model first; Claude Desktop's pick acts only when a model is set.
  Neither overrides a named model under "same as lead".
- Who relied on a1174674d (a lead's own pick of a Codex model following
  the session): pick the session's model as Codex's subagent model in
  magpie, which puts every subagent on it.

Ran (mote, -tags nogui -count=1, this change on 7fd77a944; rebased after onto a57c95513, which adds only docs, LESSONS and GUI test files):
- TestCodexSubagentKeepsTheModelItWasNamed on the old code (b01193ef9
  with only the new test): FAIL, "ChatGPT was asked for []".
- go test -run 'TestCodex(Subagent|Side|Memor|AppSide|Title|Prediction)'
  ./internal/gateway ./internal/agent: ok.
- go vet (darwin nogui, GOOS=linux, GOOS=windows) on internal/gateway
  and internal/agent: ok. gofmt -l: clean.
Not run: the full go test ./... suite (started on mote, not waited on);
staticcheck (not installed on mote); a real Codex spawn_agent with a
ChatGPT sign-in and a lead on a magpie model.
2026-10-28 16:16:02 +08:00
yetone a1174674da codex: subagents and memories follow the session's magpie model; auto-review can too (cybercaius on Discord)
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 the lead
names in spawn_agent, memories on gpt-5.6-luna/terra, auto-review on
codex-auto-review. With Codex signed in to ChatGPT and the conversation
routed onto one of magpie's models, each of those went to the ChatGPT
account instead (cybercaius: "can't pick follow the main model").

- gateway (codexFollowTo, codexLeads): a collab_spawn or memory call
  that asks for a bare model, with nothing set for it (no magpie
  subagent model, no [agents] default_subagent_model, no [memories]
  extract/consolidation_model in Codex's config), goes on the model its
  conversation's own turns go on (parent thread, own thread, else the
  key's last turn), when that is a magpie model the key may use. A task
  the ChatGPT backend sealed stays on ChatGPT. The trace shows a
  subagent's pick as {asked -> to}.
- agent.CodexSideSet reads Codex's config.toml for those keys; an
  unreadable config counts as set (leave as sent).
- Auto-review gets "Same as the session" (settings value "session"):
  codexcat writes each magpie entry's own id as its
  auto_review_model_override. Not the default: codex-auto-review runs
  free on a ChatGPT sign-in (#1593).
- GUI: the option in all languages; Memories' default text says it
  follows the session. app.js stays under its budget by folding five
  identical writingPrefs then/catch chains into prefWrite.

Ran (sandbox HOME, -tags nogui -count=1 -timeout 45m):
- go test ./internal/gateway ./internal/agent ./internal/codexcat
  ./internal/settings ./internal/cli ./internal/gui: ok.
  ./internal/provider: FAIL with "close of synctest channel from outside
  bubble" in filememo.Forget (TestUnreadLoginsWriteErrorsKeepCredentials),
  which is #3632 on main; this change touches nothing there.
- TestCodexSubagentFollowsTheSession and TestCodexMemoriesFollowTheSession
  go red with codexFollowTo returning "" (broken by hand).
  TestCodexSideCallsKeepTheConfigsModel, TestCodexSideCallsStayOnChatGPT,
  TestCodexSideSet, TestCodexAutoReviewFollowsTheSession pass.
- GUI (playwright 1.62.0, chromium + webkit): codex-auto-review (en, zh,
  zh-TW, ja, de), codex-memories, codex-memories-settings, codex-titles,
  codex-predictions, codex-descriptions, settings-general, agent-prefs,
  i18n-keys: 120/120 pass. TestCoreScriptBudget passes, budget unchanged.
- gofmt -l clean; go vet -tags nogui for linux, windows and darwin ok.

Again after rebasing on origin/main 49f15d124 (25341b4ca on top touches
only internal/redact; rebuilt): nogui builds (darwin, linux,
windows), TestCoreScriptBudget, the tests above, and the GUI files 120/120.

Not tried: a real Codex with a real ChatGPT account and a relay model.
2026-10-26 15:35:12 +08:00
yetone 0d2a101160 gateway: the Codex app's titles, descriptions and summaries go to the magpie model picked, not ChatGPT (atom_Ray on X)
atom_Ray on X: with a third-party model picked in the Codex app through
magpie, an hour of use still took 2% of the ChatGPT account's 5-hour
window, and at 0% left it could not be used at all.

The cause is the app's hidden side turns. ChatGPT.app 26.1013.40934 asks
for a thread's title, description and one-line summary
(ThreadMetadataGenerationService.generateTitle/generateDescription/
generateSummary in .vite/build/main-CLu1A25j.js; R0/z0/B0 via H0 and Jq
in src-DsLVGakC.js) on ephemeralGenerationModel, gpt-6-luna by default,
whatever model the conversation is on. A summary is asked after each
user and assistant message (bAu in app-initial). With magpie's model
beside the ChatGPT sign-in (openai_base_url), these reach
/backend-api/codex as gpt-6-luna. codexTitlesTo and codexDescriptionsTo
left an unset setting on the model Codex asked for, and thread_summary
had no route at all, so all three went to ChatGPT on the user's sign-in.

Now, with Codex's config model one of magpie's and magpie not Codex's
provider (agent.CodexSideModel, through gateway.CodexSideModel),
codexSideTo sends titles, descriptions and summaries on the Codex
backend path to that model. On Codex's own model nothing changes, and a
model the Titles or Descriptions setting names still wins. Summaries get
the same wrapper as descriptions (codexShaped): the plain answer is
handed back as the {"summary": ...} the schema asks for, with
compactSummary filled and cut to its maxLength (summaryJSON). This also
covers a summary on magpie's own API, where a Chat model's plain answer
was dropped by the app. No prompt, instructions or base_instructions are
changed: the request is sent to another model as Codex wrote it.

Run (this change on origin/main e57e78563 for the full suite; rebased
onto 3a47e377e, which touches internal/gateway, for the packages run
again; then onto 0e643b14e, internal/sessions only, built):
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows for
  internal/gateway, internal/agent and internal/cli: clean.
- New tests: TestCodexSideTurnsOnThePickedModel,
  TestCodexSummaryOnMagpieProvider, TestSummaryJSON (gateway) and
  TestCodexSideModel (agent). Also the existing title, description and
  #540 used-up tests: ok.
- Full suite (go test -tags nogui -timeout 45m ./..., one suite on the
  machine, log tee'd): 70 packages ok, 19 without tests, no FAIL, exit 0
  (gateway 594s, agent 449s, provider 220s, cli 151s).
- Rebased onto 3a47e377e: gofmt and vet (nogui) of gateway, agent and
  cli clean; go test -tags nogui -timeout 45m of internal/gateway,
  internal/agent, internal/cli and internal/usage: all ok.
- Rebased onto 0e643b14e (internal/sessions only): go build ./... ok;
  not run again.

Broken by hand:
- codexSideTo's side-model branch turned off: TestCodexSideTurnsOn-
  ThePickedModel red (the title went to ChatGPT, 0 magpie calls).
- Both codexSummariesTo call sites turned off: TestCodexSideTurnsOn-
  ThePickedModel red on thread_summary, and
  TestCodexSummaryOnMagpieProvider red (plain text came back).
- SideModel without the !asProvider() check: TestCodexSideModel red.

Not tried: the real Codex App with a real ChatGPT account (live ~/.codex
and the running magpie were left alone), Windows and Linux. The app's
ambient suggestions (ambientSuggestionsModel), safety recourse and
commit/PR message turns are not moved; they are asked rarely or only by
user action. Not changed: what ef37b6fb7 does at 0% (Send greyed in the
app until it is reopened). On macOS magpie reopens the app once when it
is idle. On Windows and Linux it only shows a notice
(internal/gui/codex_app_out.go:78). With account discovery off,
readLogins returns nil (internal/provider/logins.go:208), so a used-up
account is never known.
2026-10-25 01:41:23 +08:00