csic21, HONGs23 and TimWongUp (#3172): a Codex subagent inherits
access_programs {"cyber":"standard"}, magpie relayed it to OpenCode Go,
and Go answered DeepSeek and GLM with 503 "Upstream request failed:
Endpoint is unavailable."; without the field, or with null, 200. Go's
Haiku took it.
Scope: Codex itself sends the field only with a ChatGPT sign-in, or an
API key on its provider named "openai" (codex-rs core/src/
cyber_access_program.rs, for_auth and for_provider; read at openai/codex
970111f6c). It comes to magpie because Codex thinks magpie is OpenAI,
the same reason forVendor takes OpenAI-only parts out (#292). So the
class is "only the upstreams Codex would send it to", not an OpenCode Go
rule: no other vendor has a Cyber program to read, and Go is the one
seen to refuse it. keepsAccessPrograms keeps it for a ChatGPT (Codex)
account, a host ending in openai.com, another magpie (IsRemoteMagpie,
whose own upstream decides) and a codexAsSent relay when Codex sent the
request. Every other Responses upstream, relayed or built (from Chat
too), plugins included, goes without it. A relay that fronts ChatGPT
loses it unless set codex=as-sent, as Codex with a custom provider
would send it none.
- forwardOnce takes it out before the user's extraBody is merged, so an
access_programs the user wrote there still goes (Edward4226's branch
did it after, which would override the user's own value).
- withoutTopMember (from Edward4226's branch, using longBody's spans on
a long body) removes the member, every one of that name, the rest byte
for byte; a body that isn't a valid object goes as it came. A
bytes.Contains check first, so a body without it costs nothing.
- Chat and Messages builds never carried it (now tested).
- Docs: gateway-routing.md, providers-accounts.md, ir.go comment.
Run:
- TestAccessProgramsGoToOpenAIAlone (new; fakes by the gateway client's
RoundTrip, no network): Go DeepSeek/GLM from Codex and from curl, null,
Chat built as Responses, Zen, a relay, codexAsSent with and without
Codex's headers, the user's extraBody, OpenAI (daybreak_blue, null,
from Chat), another magpie, a Chat and a Messages upstream.
TestWithoutTopMember (new). TestCodexAccessProgramsReachBackend,
TestAccessProgramsNullKept, TestCodexAccountTakesExtraBody pass.
- Broken by hand, each red: no strip (9 cases: Go, Zen, relay, extraBody);
IsRemoteMagpie out; openai.com out (3 OpenAI cases); codexAsSent out;
codexAsSent without fromCodex; Codex account out
(TestCodexAccessProgramsReachBackend red); strip moved after extraBody
(the user's value lost).
- gofmt -l clean; go vet -tags nogui ./... for darwin, linux, windows.
- HOME=<scratch> go test -tags nogui -timeout 45m ./internal/gateway/:
ok (414s), at 42976f9a0 plus this change.
Not tried: a real OpenCode Go account on this head (the reporters' and
Edward4226's real A/B runs show the field alone turns 503 into 200);
OpenCode Zen's DeepSeek with the field (now sent without it either way);
a real Codex collab_spawn end to end.
Co-authored-by: Edward4226 <Edward4226@users.noreply.github.com>