Commit Graph
1 Commits
Author SHA1 Message Date
yetone 9b52fb504a gateway: Codex's web search on magpie's models answers, no longer 404 (anton on Discord)
anton on Discord (Linux): asked to look something up, Codex called its
web.run tool, which posts to <base_url>/alpha/search, here
http://127.0.0.1:3425/v1/alpha/search. magpie had no such route and
answered 404, and Codex takes any failed web.run as fatal, so the turn
ended.

Why Codex sends it: since 0.143 (#29909) Codex offers web.run to a
provider that sends x-openai-actor-authorization, as magpie's provider
table does, on a model whose catalog entry says use_responses_lite, as a
ChatGPT account's models do in magpie (codexcat copies Codex's own
entry). The request is codex-api's SearchRequest (id, model, input,
commands.search_query/open/click/find..., settings, max_output_tokens)
and the reply is {encrypted_output, output, results}, output being what
the model is shown.

What changed:
- POST /v1/alpha/search and /alpha/search are served (codex_search.go).
- A ChatGPT account's model goes to the ChatGPT backend's
  /backend-api/codex/alpha/search, as the official client sends it: on
  the account's sign-in (codexSign, no SSE Accept), the model bare, the
  body otherwise as it came (through redaction), only Codex's own
  x-openai-*/x-codex-* headers kept (codexHeader: never magpie's token or
  the actor header). Its own paused sign-in is passed over, the key's
  account and model holds kept, and the next account is asked on a
  non-2xx; the backend's answer is relayed as it is.
- Any other model's search_query/image_query (domains as site:) is
  searched by webSearch, as magpie searches for a model that can't. When
  nothing answers, or only open/click/find were asked, the reason goes
  back as a 200 with output, which the model reads, instead of a failure
  that ends the turn. A ChatGPT search that fails on every account falls
  back to the same, saying why.
- On the Codex backend path a magpie model's /alpha/search is served
  the same, never relayed on Codex's own sign-in; one of Codex's own
  models goes through magpie's accounts when its turns would
  (codexAccounts), else is relayed as before.
- docs/subsystems/gateway-routing.md names the route.

What was run (worktree on origin/main, sandbox HOME, private GOCACHE):
- New tests from Codex's own wire fixture (codex-api endpoint/search.rs):
  TestCodexWebRunSearchesOnChatGPTAccount (both paths; acct-1 429 ->
  acct-2, bare model, body kept, no magpie token/actor header, turn
  metadata kept), TestCodexWebRunChatGPTFailsSearchedByMagpie,
  TestCodexWebRunOnOtherModelSearchedByMagpie (no searcher hint, search
  API asked "OpenAI news site:openai.com", open-only, bad JSON 400, and
  a stub ChatGPT backend that fails the test if reached).
- Broken by hand three ways, each red: without the /v1 route (404 as
  anton saw), without the codexBackend case (relayed to the backend on
  Codex's sign-in), without the ChatGPT forward (searched by magpie).
- go test ./internal/gateway/ -timeout 30m, gofmt -l, go vet darwin,
  GOOS=linux go vet -tags nogui, GOOS=windows go vet.

Not tried: the real codex binary against a sandbox magpie, nor a real
ChatGPT account's /alpha/search; the shape is from Codex's source and
its own test fixture.
2026-10-13 16:49:29 +08:00