A relay that serves only Codex or Claude Code tells them by their headers
("This account only allows Codex official clients"). The gateway already
lets those headers go on to a provider reached with a key, so the agents'
own requests were served, but the provider/model test is magpie's own
tiny request (Go's User-Agent), so it was turned away and said the
provider didn't work.
provider.TestAs(ctx, "codex"|"claude-code") asks Test and TestModels as
that agent asks. It goes to that agent's API (Codex: Responses, else Chat;
Claude Code: Anthropic Messages), streamed, store:false on Responses, and
with the headers the gateway last let through for it. The gateway notes
them with provider.SawClient beside the existing pass-through, without the
session, thread, turn, request id, subagent kind, anthropic-beta or
anything that signs. They are kept in client-shapes.json so the CLI has
them too.
Claude Code's headers are never made up. Until a Claude Code request has
come through magpie, the test says so. They are sent only to a relay,
never to anthropic.com, googleapis.com, Bedrock or Azure. A signed-in
account, a decision-only provider, and OpenCode/Cline/Kilo (which already
ask as their own client) are not offered it. Codex's fall back to the
headers a ChatGPT account's requests use (codexSign) until Codex has come
through.
Surfaces:
- CLI: magpie provider test <id> [--as codex|claude-code] [model…]
- GUI: a model chip's right-click has "Test as Codex" and "Test as Claude
Code" where the provider offers them (providerJSON.testsAs). An item that
can't run yet is off, with the reason shown. zh, zh-TW, ja, de strings.
Run:
- TestModelTestAsClient (internal/gateway). A fake relay 403s anything but
codex_*/claude-cli/. The plain test gives 403. As Codex it is OK on
/v1/responses with stream+store:false and codex_cli_rs headers. As
Claude Code it is refused before Claude Code came, then OK after one
Claude Code request through the gateway, with its UA/x-app/x-stainless
but no session id or beta. Anthropic's API is refused. With the beta
filter removed by hand the test goes red.
- model-test-as.test.cjs, Chromium and WebKit, en/zh/zh-TW/ja/de at
420px: 10/10. On the old app.js it fails (no such items). Siblings
model-test-one, model-copy-id, model-test-why, provider-typed: 28/28.
- Sandbox CLI (fake chat relay on :3571, sandbox HOME):
- provider test relaya --as codex deepseek-chat sent
codex_cli_rs/0.162.0 … with originator and version, stream:true.
- --as claude-code said the relay has no Anthropic endpoint.
- go test -tags nogui ./internal/{provider,gateway,gui} and the root
package under a temp HOME with pinned caches: ok. gofmt -l clean.
go vet darwin/linux/windows on those packages: ok.