Files
magpie/docs
yetone dafe4af822 gateway: the ChatGPT backend's "auto"/"default" tier is recorded as unknown (jjt on Discord)
The ChatGPT Codex backend says service_tier "auto" in response.created
and "default" in response.completed whether priority ran or not. jjt's
measurements on gpt-6.1-sol with a Plus account: Fast decodes at about
200 tok/s, without it about 110, and the reply says "default" both times
(real-priority.sse, speed-plus.txt). magpie copied that into tier_served,
so the usage log, its CSV and /v1/magpie/route said served = default for
requests that ran Fast.

servedTierAt (tier_record.go) leaves those two words empty when the
reply came from CodexBase's host. It is applied once per routed try, in
attempt (gateway.go, a defer, so every return path and the route's tries
see it), and on the relay of Codex's own sign-in (codexUpstreamOn).
OpenAI's API, where service_tier means what it says, keeps it as given:
a provider at api.openai.com and Codex with an sk- key relayed to it.
"priority" or "ultrafast" said by the ChatGPT backend is still kept.

Display: tier_served is shown by the CSV (an empty cell), the JSON log
and /v1/magpie/route (omitempty). No GUI page or TUI shows a tier
(grep of internal/gui/assets and internal/tui for tier_served,
tier_asked, tierServed: none), so no strings changed. docs/reference.md
and docs/subsystems/gateway-routing.md say it.

Tests:
- TestChatGPTBackendTierUnknown (new): the backend says auto, then
  default (jjt's events, cut to the fields read); a routed try asked
  priority and one asked nothing, and Codex's own sign-in relayed, all
  record "" in usage and the route.
- TestOpenAIAPITierKept (new): api.openai.com's "priority" and
  "default" kept, routed and through the sk- relay.
- TestTierRecordedPerTry: its "none asked" case on the ChatGPT backend
  now expects "" where it expected "default".

Run on mote (mote-run; the wider run at base cc81ad4ea, the tier run
again after the rebase, at this commit on c37b8b659: ok, 22 pass):
- go test ./internal/gateway -run 'Tier|ChatGPTBackend|OpenAIAPI'
  -count=1 -v: ok, 22 tests pass.
- go test ./internal/usage: ok. go test ./internal/gateway -run
  'Codex|Usage|Route|Tier': two reds, TestAntigravityTurnsCodexs-
  GPT5ThreadAwayOnce and TestCodexSpentGrokFailingIsTold, red the same
  on a fresh origin/main c37b8b659 and filed as #4362; the rest ok.
- go vet ./internal/gateway, GOOS=linux and GOOS=windows: clean.
- gofmt -l internal/gateway: clean.
Broken by hand: servedTierAt returning t unchanged -> TestChatGPT-
BackendTierUnknown and TestTierRecordedPerTry red ("served default");
the host check removed -> TestOpenAIAPITierKept red (served "", want
"default"). Both green again with the fix.

Not tried: a real ChatGPT account through the built gateway; the full
Go suite (the coordinator asked for the targeted run under mote's load
of ~200); Windows and Linux test runs (vet only). No GUI file reads the
tier, so no GUI test was run.
2026-10-30 13:57:36 +08:00
..