Commit Graph
2 Commits
Author SHA1 Message Date
yetone 72ca3d593b codex: magpie as Codex's provider keeps the Codex app's ChatGPT account while it has room, so its Work chats and projects stay
Qyburn3 on X: with magpie taking Codex over, the Codex app's "Work"
sessions don't load while the model still answers; turned off, they
come back.

Cause: [model_providers.magpie] had no requires_openai_auth, so Codex's
app-server answers account/read and getAuthStatus with no account and no
token whenever magpie is Codex's provider (magpie API, or the codex.out
takeover). ChatGPT.app 26.1021 then switches to an identity of no
account: onboarding again with no name, ChatGPT mode's projects and
chats ("Work") empty, no avatar, no Chrome control (#1824).

Now putProvider writes requires_openai_auth = true while Codex has a
ChatGPT sign-in with room (openaiAuth: codexChatGPTKnown and not
codexUsedUp), and takes it out otherwise:
- API key alone: left out. With it Codex drops image_gen (captured: 11
  tools without, 10 with), and there is no account to keep.
- No sign-in: left out (the app would ask for a sign-in).
- A sign-in the Codex app holds (codex.out, or magpie API while used
  up): left out, since the app's composer gate (authMethod chatgpt +
  allowed false, #540) would grey Send for magpie's models again. The
  takeover's note now names "its ChatGPT chats and projects" among what
  is off till the reset, beside Keep on ChatGPT.
- An unknown sign-in read leaves the table as it is.
Sync rewrites the key on any table that disagrees (authStale), an older
magpie's included, and the key joins codexAppRoute, so the Codex app's
app-server is restarted onto its account with nothing for the user to
do. The magpie API note no longer says Chrome control needs ChatGPT (en,
zh, zh-TW, ja, de); agent-wiring.md says why.

Real app (mote, ChatGPT.app 26.1021 with its codex 0.164.0-alpha.11,
sandbox CODEX_HOME, copied real ChatGPT auth, auth.json unchanged after):
- native config: the account's projects and recent chats listed.
- magpie table without the key: onboarding, "ChatGPT Work" with no
  projects, no chats. app-server: account null, authMethod null.
- magpie table with requires_openai_auth = true (the keys this commit
  writes): every project and chat back; account/read chatgpt pro,
  getAuthStatus authMethod chatgpt with a token.
- Model requests to a capturing server, with and without the key:
  Bearer is magpie's experimental_bearer_token, no ChatGPT-Account-ID,
  15 tools both ways with a ChatGPT sign-in (image_gen kept).

Tests: TestCodexMagpieProviderKeepsChatGPTAccount (ChatGPT + magpie API,
used up and back; taken over and the reset; an older magpie's table from
live config bytes; API key and no sign-in, fresh and after ChatGPT) and
TestCodexAppRouteFollowsOpenAIAuth. Broken by hand: on the old codex.go
5 of 7 subtests red; without the Sync re-derive 3 red; with the key kept
while used up 2 red; agents.go without the route key, the route test red.

Run (mote-run, at this tree on origin/main 157d575c3; the build and the
agent run again after the rebase onto e5e2aa58e, ok; 5a85a9836 after it touches redact only,
no agent
or GUI file, ok): gofmt -l clean;
go build ./...; go vet linux (-tags nogui) and windows ./..., darwin
./internal/agent; go test -tags nogui -run 'Codex|Agents|Sync|Disconnect|Route'
./internal/agent ok; GUI codex-signin-always, codex-app-out, i18n-keys
and the i18n files, Chromium and WebKit, 96/96.
Not run before the push: the full go test ./... (mote had three other
sessions' full suites at load ~100); it runs after, and any red gets an
issue. Not tried: the used-up case on the real app with the key (the
composer gate is from #540's reading of 26.1013), Windows and Linux
Codex apps.
2026-10-29 01:18:59 +08:00
maYandyetone 6fe8169502 gateway, agent: Codex draws with its native image tool through magpie (#870)
* fix(agent): give magpie's provider table the actor-authorization header

Codex offers its built-in image tool (image_gen.imagegen) — and the other
OpenAI-provider tools — only to a provider it reads as the OpenAI actor:
ModelProviderInfo::uses_openai_actor_authorization(), i.e. a provider that
does not require OpenAI auth but carries x-openai-actor-authorization.
magpie writes [model_providers.magpie] but carried neither signal, so a
Codex on magpie was never given the tool and could not draw through a
Codex backend such as sub2api's.

Write http_headers = { "x-openai-actor-authorization" = "magpie" } into
that table. magpie does not forward the header upstream: codexHeader
rejects anything naming "authorization".

Test: TestCodexMagpieProviderCarriesActorAuthorization.

* gateway/provider: let a Responses-only relay (Codex backend, sub2api) draw

A provider added as 'OpenAI Responses' only (what a Codex backend such as
sub2api speaks) has no chat base, so Drawers() returned nil before ever
looking at the vendor's list, draw() refused with 'can't draw', and
drawImages() posted to an empty base. The vendor's own /v1/models does list
its image models (sub2api serves gpt-image-2.5), and they are meant to be
picked in Settings → Images.

- Drawers: a Responses-only provider draws when it has any OpenAI-shaped
  base, not only a chat one.
- draw: refuse only when neither Chat nor Responses is set.
- drawImages: fall back to the Responses base when there is no chat base.
- List: the add form's 'Fetch models' keeps the vendor's image models so
  one can be picked while the provider is added.

Tests: TestResponsesOnlyProviderDraws, TestListOffersImageModels.

* fix: route Codex native images through its turn provider

---------

Co-authored-by: yetone <yetoneful@gmail.com>
2026-10-05 17:19:42 +08:00