From 50aaa572684dc575c631a85d2b4029aa3bf99566 Mon Sep 17 00:00:00 2001 From: yetone Date: Wed, 4 Nov 2026 21:54:33 +0800 Subject: [PATCH] agents: Codex's Lead's pick, already chosen, still takes away the config's subagent model luckymanjc (Discord) set Codex's subagent model to Default (Lead's pick) on the Agents page, but ~/.codex/config.toml kept [agents] default_subagent_model = "gpt-6.1-terra". Restarting magpie and Codex didn't clear it, so every subagent ran on Terra. The card said "Codex's config still starts subagents on gpt-6.1-terra when the lead names none; picking here replaces it". But magpie's own setting was already "", and commit() returns when a pick equals the current value, so nothing was sent. The backend's Set("") does take the key away (internal/agent/ codex.go, subagent_model). Now Lead's pick is sent while Codex's config still has a subagent model; it still sends nothing when there is none. magpie writes that key through Codex's own subagents square, which the card no longer draws once magpie's subagent model is offered. Nothing records whether magpie or the user wrote it. The owner's rule is that a pick in the subagent model takes it away, and the card says so. [agents] default_subagent_reasoning_effort ("low" here) is left alone: it is the subagent effort square on the card, which can be set to Default there. Run (mote): - codex-subagent-model.test.cjs: 20/20 in Chromium and WebKit, in en, zh, zh-TW, ja and de, at 1100 and 560px. The square now starts as the reporter's case: Lead's pick with a model in Codex's config. Picking Lead's pick posts "", and a second pick with nothing left posts nothing. - Broken by hand: with the old `if (value === field.value) return;`, 2/2 red (chromium en; waitForFunction timed out, nothing sent). - codex-subagents-lead 20/20, subagent-effort 4/4, i18n-keys 4/4, go test -run Budget ./internal/gui: ok. After a rebase it was 285 bytes over, so the inline comment went into codexSub's comment and the check got shorter. app.js is 189 bytes smaller than its base; the budget was not raised. Rerun at that tree: 20/20 and 20/20, and red on the old code. Not tried: the real app against a real ~/.codex (sandbox only; ~/.codex was not touched), and Windows and Linux. --- internal/gui/assets/app.js | 11 +++----- .../gui/tests/codex-subagent-model.test.cjs | 26 ++++++++++++++++++- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index 967309199..cc3a88b62 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -3974,9 +3974,6 @@ const MEMORIES = "memories"; // Desktop's subagent model is the same square: the gateway puts each of // its subagents' turns on it const SUB_MODEL = "subagent model"; -// Codex's subagents square is [agents] default_subagent_model: a subagent's -// model when its lead names none (codex-rs child_config.rs); the lead may -// name another (willz on Discord), so it points at the subagent model. // Claude Code's auto mode square: the model its client-side auto mode // classifier runs on (CLAUDE_CODE_AUTO_MODE_MODEL); unset, Claude Code's own // pick, not the model's @@ -3991,9 +3988,9 @@ const LEAD_PICKS = "The model a subagent starts on when Codex's lead names none; const CLAUDE_PICKS = "Claude Code's lead, or a subagent's own definition, may name a model or tier for it; a model set here is for the subagents that name none"; const claudePicks = (a, f) => leadPicks(a, f) && kindOf(a) === "claude"; // Codex's two subagent squares read alike (the owner, HoGee_xxl on X): the -// card shows the subagent model alone, saying what each does. A pick there takes away [agents] default_subagent_model too (the -// backend), and one left in the config is said on it until then. With no -// model of magpie's to pick there, Codex's own square stays. +// card shows the subagent model alone. A pick there, Lead's pick again too +// (luckymanjc), takes away Codex's [agents] default_subagent_model, said +// till then. With none of magpie's models to pick, Codex's square stays. const codexSub = (a) => kindOf(a) === "codex" && a.fields.some((f) => f.label === SUB_MODEL && (f.options.length || f.value)); const codexOwnSub = (a, f) => f.label === "subagents" && codexSub(a); // named rows in Codex's settings: no square too (the owner, 10-25) @@ -5624,7 +5621,7 @@ async function commit(value) { if (tier) openPicker(agent, tier, anchor, { stopPropagation() {} }); return; } - if (value === field.value) return; + if (value === field.value && (value || field.label !== SUB_MODEL || !codexSubSaid(agent, field).old)) return; if (agent.native) return setPick(agent, field, value, opt); // a pick that takes a connected agent off magpie (its Default, or a // model of its own asked of its vendor directly) is asked first, as the diff --git a/internal/gui/tests/codex-subagent-model.test.cjs b/internal/gui/tests/codex-subagent-model.test.cjs index 3f5b44131..c322954ae 100644 --- a/internal/gui/tests/codex-subagent-model.test.cjs +++ b/internal/gui/tests/codex-subagent-model.test.cjs @@ -221,9 +221,33 @@ for (const engine of engines) { }).length); assert.equal(left, 0, "a coloured left border"); + // Lead's pick, already the choice, still takes away the model + // Codex's config starts subagents on (luckymanjc on Discord: it sent + // nothing, and every subagent stayed on gpt-6.1-terra) + await page.locator("#pop #list li").first().click(); + await page.waitForFunction(() => !document.querySelector('.row.agent[data-id="codex@wsl:Ubuntu-24.04"] .field.extra.set[data-key="subagent_model"]')); + assert.deepEqual(sets, [{ agent: wsl, field: "subagent_model", value: "" }]); + assert.equal(await square.getAttribute("aria-label"), w.unset + "\n" + w.line); + assert.equal(await page.evaluate(() => scrollY), y, "the pick scrolled the page"); + await square.click(); + await page.locator("#pop:not([hidden]) #list li").first().waitFor(); + await page.locator("#pop #list li", { hasText: "GPT-6 Astra" }).first().click(); + await page.waitForFunction(() => document.querySelector('.row.agent[data-id="codex@wsl:Ubuntu-24.04"] .field.extra.set[data-key="subagent_model"]')); + assert.deepEqual(sets.at(-1), { agent: wsl, field: "subagent_model", value: "codex/gpt-6-astra" }); + // with nothing left in Codex's config, Lead's pick again sends nothing + await square.click(); + await page.locator("#pop:not([hidden]) #list li").first().waitFor(); + await page.locator("#pop #list li").first().click(); + await page.waitForFunction(() => !document.querySelector('.row.agent[data-id="codex@wsl:Ubuntu-24.04"] .field.extra.set[data-key="subagent_model"]')); + await square.click(); + await page.locator("#pop:not([hidden]) #list li").first().waitFor(); + await page.locator("#pop #list li").first().click(); + await page.waitForTimeout(200); + assert.equal(sets.length, 3, JSON.stringify(sets)); + await square.click(); + await page.locator("#pop:not([hidden]) #list li").first().waitFor(); await page.locator("#pop #list li", { hasText: "GPT-6 Astra" }).first().click(); await page.waitForFunction(() => document.querySelector('.row.agent[data-id="codex@wsl:Ubuntu-24.04"] .field.extra.set[data-key="subagent_model"]')); - assert.deepEqual(sets, [{ agent: wsl, field: "subagent_model", value: "codex/gpt-6-astra" }]); assert.equal(await square.getAttribute("aria-label"), w.set + "\n" + w.setLine); // Same as the lead: every subagent on the model asked for again, and