neiko on Discord: Claude Code connected to magpie, and "Test as Claude
Code" stayed grey. The test asks with the headers Claude Code last sent
(client-shapes.json), and those were noted only where they were passed
on: a request forwarded on Anthropic Messages to a keyed provider. A
Claude Code on a subscription, a Chat provider's model or any translated
one never got there, so the test kept saying no Claude Code request had
come. They are now noted as the request arrives on /v1/messages, after
the caller guard, whatever serves it; the forward still passes them on
only to a keyed provider on Messages, as before.
Run:
- TestClaudeCodeSeenOnAnyRoute (new): Claude Code on a Chat-only
provider, then a relay's model tested as Claude Code with its headers.
Fails on main ("no Claude Code request has come through magpie yet").
- TestModelTestAsClient still green.
- gofmt; go vet darwin, GOOS=linux -tags nogui, GOOS=windows for
internal/gateway and internal/provider.
- go test -tags nogui ./internal/gateway ./internal/provider (-timeout
60m; the machine was at load ~300): gateway ok; provider red only on
TestCopilotSecretToolUsername's 10s bound under load (#1627), green
3 of 3 alone. The full ./... ran twice and timed out package by
package at load ~270-300 (10m default, then build failures in the
second), so it is not a pass.
Not tried: a real Claude Code against a real Claude Code-only relay.
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.