Commit Graph
2 Commits
Author SHA1 Message Date
yetone 6c7cedece8 gateway: the first Codex title after magpie starts waits for the turn, not the config's model
Codex signed in to ChatGPT, its config's model one provider's (B/qwen3.7),
the conversation put on another provider's (A/dsf4.1) in the Codex app:
the first new conversation's title was written by B. The app asks for a
title on a temporary thread with no link to the conversation, sent as
the first message is, so it can reach magpie before that conversation's
first turn. codexLeads.sideOf waits for that turn when the key's last
turn is old, but when the key had no turn at all (nothing through magpie
since it started) it returned at once with nothing, and servedSession
fell back to CodexSideModel, the config's model. Now such a call waits
the same way (codexSideWait, 5s, or its cancellation) and takes the
turn's model; the config's model only when no turn comes. A memory call
before any turn (Codex consolidating as it starts, no turn on the way)
still takes the config's model at once. A model set for titles in
magpie's settings (settings.CodexTitles) still wins, as before.

TestCodexFirstTitleFollowsThePickNotTheConfig: fresh server, config on
third/, the title sent, then the conversation's turn on fourth/. Red on
the old codex_follow.go ("the config's model got 1 requests, the title
among them"), green on the new. TestCodexSideTurnsOnThePickedModel sends
side turns with no turn ever: it sets codexSideWait to 0 so it doesn't
wait 5s on each.

Run (mote, at this commit's tree):
go build ./..., go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./...: clean. gofmt -l: clean.
go test -count=1 -run Codex ./internal/gateway/: ok (172s).
Full suite (go test -tags nogui -timeout 45m ./..., through the suite
lock) was still queued/running at push; any red it shows gets an issue.
After a rebase onto 6b7ee4a98 (its routing commits touch gateway.go
and the routing doc too), go build, the three vets and
go test -run 'Codex|Routing|Group' ./internal/gateway/ ran again at
that tree. Then rebased onto 9451ad59f (two gateway commits touching
none of this change's files); go vet ./internal/gateway/ there only.

Not tried: the real Codex app was not run; its title model choice was
read from its app.asar. The Codex 0.165.0 TUI with magpie-style config
(model B, -m A, fake Responses server) sends its title on A, so the TUI
was never affected. No real provider accounts. Windows and Linux: vet
only. The same report on the /v1 route (magpie as Codex's provider) is
the next commit.

Reported-by: tenacious_eagle_96548 on Discord
2026-11-08 02:16:48 +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