Commit Graph
3 Commits
Author SHA1 Message Date
yetone 206efc90c8 gateway: a Codex side call with no setting still goes on Codex's sign-in (#4590 review)
e99e75dab took every side call on one of Codex's own models (title,
description, summary, prediction) off Codex's ChatGPT sign-in. With no
setting naming a model, codexTitlesTo and its siblings hand back the
bare model Codex asked for, which magpie serves nothing for: a user
signed in to ChatGPT whose titles worked through the sign-in got
"magpie knows no model \"gpt-6.1-sol\"" 404 for every title,
description, summary and prediction. A thread's summary has no setting
at all, so it always went that way.

Now only a side call whose setting names where it goes (CodexTitles,
CodexDescriptions, CodexPredictions: a model or "off") stays off the
sign-in (codexSideSet); without one it goes on the sign-in as before.

Run (mote, at this tree, -tags nogui):
- TestCodexSideCallOnOwnModelUnsetGoesOnSignIn (new: signed in, no
  setting, each of the four kinds): red on e99e75dab, the 404 above for
  all four; green now.
- go test -run 'TestCodexSideCallOnOwnModel|TestCodexOwnModelOnMagpieThread|
  TestCodexTitlesSetting|TestCodexTitleOnMagpieProvider|
  TestCodexDescriptionsSetting|TestCodexDescriptionFallbackOnMagpie|
  TestCodexPrediction|TestCodexSummar' ./internal/gateway: ok
- broken by hand: codexSideSet always false turns gua's
  TestCodexSideCallOnOwnModelNotPutOnSignIn red (the reporter's 404);
  always true turns the new test red.
2026-11-01 22:44:23 +08:00
ggbdpq 50e8da4c34 gateway: Codex side calls on its own models stay with magpie, not its sign-in (#4590)
shruru: with magpie as Codex's model provider, picking any model in the
Codex titles setting never took: the thread's title stayed the first
message's truncation, and a request for gpt-5.6-luna, Codex's own title
model, to /v1/responses was answered 404 "is one of Codex's own models...
open ~/.codex/auth.json: no such file or directory".

A thread started while magpie was Codex's provider sends to magpie's /v1
(model_providers.magpie's base_url is magpie's /v1), and since
4586307de a request there on one of Codex's own models is put on Codex's
ChatGPT sign-in, or answered 404 when no sign-in can be had — before
handle ever asks codexTitlesTo where the settings send a title. Codex's
hidden side calls (a thread's title, description, summary, a composer
prediction) on its own models were swept up in that: magpie has its own
answer for each (codexTitlesTo and its siblings, further down handle),
so with no ChatGPT account anywhere the title request died at the sign-in
check and Codex fell back to naming the thread after its first message,
whatever the settings said.

Now codexOwnOffMagpie leaves side calls where they stand; a plain turn on
one of Codex's own models goes on the sign-in as 4586307de says.

Tests (internal/gateway/codex_own_v1_test.go): shruru's machine — Codex
never signed in (no auth.json), gpt-5.6-luna in its models cache, no
ChatGPT account in magpie, titles and descriptions set to a magpie model;
a thread_title and a thread_description request to /v1/responses on
gpt-5.6-luna: was 404 "one of Codex's own models...", now 200 with the
{"title"} / {"description"} the settings' model wrote.

Run (darwin arm64, -tags nogui):
- go test -tags nogui -run 'TestCodexSideCallOnOwnModelNotPutOnSignIn|TestCodexOwnModelOnMagpieThread|TestCodexTitlesSetting|TestCodexTitleOnMagpieProvider|TestCodexDescriptionsSetting|TestCodexDescriptionFallbackOnMagpie' ./internal/gateway: ok
  (the new test was red before the fix, with the reporter's 404 verbatim)

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 22:44:23 +08:00
yetone 4586307de5 gateway: Codex's own model on a thread started on magpie goes on Codex's sign-in, not a 404
iuengei on Discord: after turning Codex's routing off and restarting,
Codex's official models answered "unexpected status 404 Not Found: magpie
knows no model \"gpt-6.1-sol\"", in ChatGPT and Always ChatGPT modes too.

A Codex thread keeps the provider it was started on (the
[model_providers.magpie] table stays for that reason). A thread started
while magpie was Codex's provider (magpie API, or the takeover of a
used-up account) goes on sending to /v1 after Disconnect or a switch back
to ChatGPT. An official model picked in it reaches serve as a bare
"gpt-6.1-sol"; with no ChatGPT account in magpie serving it (the Codex
sign-in removed from Providers, or subscription accounts off) it was
answered 404. /backend-api/codex relays such a model on Codex's own
sign-in; /v1 never did.

Now handle (Responses) puts such a request on the ChatGPT backend's route
(codexBackend) signed with Codex's own ChatGPT sign-in as Codex keeps it
(provider.CodexSignInAsKept, never renewed by magpie), magpie's key and
x-openai-actor-authorization left behind (codexOwnOffMagpie). Only for: a
bare model no provider, group or stand-in serves, not disabled or
switched off; one of Codex's own (its models cache, magpie's entries left
out) or OpenAI's in the catalog; from Codex on this computer (local); no
gateway key held to models or accounts. When the sign-in can't be had
(subscription accounts off, signed out, expired) the 404 says the thread
was started on magpie, why the sign-in can't be used, and to start a new
thread. Codex's identity and prompts are untouched.

Tests (internal/gateway/codex_own_v1_test.go): the reporter's case, a
sandbox HOME with Codex signed in, gpt-6.1-sol in its models cache, the
sign-in removed from magpie's Providers, Codex's request to /v1/responses
with magpie's key: was 404 "magpie knows no model \"gpt-6.1-sol\"", now
200 from a stand-in ChatGPT backend that got Codex's token and account
id, not magpie's key or header. Not sent: from another computer, a key
held to fake/*, a model that isn't OpenAI's (still 404). With accounts
off, a 404 that says why.

Run (on mote, at this commit's tree rebased on 173fb6ab0):
- gofmt -l internal/gateway internal/provider: clean
- go vet darwin, GOOS=linux -tags nogui, GOOS=windows for
  ./internal/gateway ./internal/provider: ok
- go test -timeout 45m ./internal/gateway ./internal/provider: ok (gateway 482s, provider 91s)
Broken by hand: the hook in handle off, GoesOnSignIn and SaysWhy are red
(the old 404); local() off, StaysHere/another_computer is red. The held
key is also kept off the relay by codexAccounts in codexBackend, so the
guard here off alone leaves that subtest green.
Not tried: a real Codex app thread against a real ChatGPT account (no
live ~/.codex touched).
2026-10-29 23:15:19 +08:00