Files
magpie/internal
yetone 7353a4bc2a gateway: a row told an earlier try's 529 overload says its kind, not the last account's usage_limit_reached (蛋仔)
蛋仔 on Discord: a Codex turn over ChatGPT accounts showed in Usage →
Requests as "529 · usage_limit_reached · 4 次尝试", while Codex said
"Selected model is at capacity. Please try a different model." The
model at capacity is no used-up quota.

Cause: when the last account left is out of its allowance and one
asked before it failed otherwise, serve tells the agent that earlier
failure (waroy's rule): call.Status and call.Error were swapped for
the earlier try's, but call.Usage.ErrType kept the last account's
usage_limit_reached, so the row paired the 529 and its words with the
quota's kind. The same swap where middleware passes every account
over. Try now keeps the failure's kind (errType, unexported, not in
the trace JSON) wherever it is kept as `other`, and both swaps take it.

Accounts were not rested for the overload: failure(529, …) is not
failQuota, vendorOverloaded rests the overloaded account 30s at most a
minute with no failure counted, and only the account that answered
usage_limit_reached rests till its reset. The new test checks that too.
Anthropic's 529 overloaded_error handling (saidOverloaded,
vendorOverloaded, fallback/patience status lists) is unchanged; the
own-sign-in path (codex_backend.go) records its own failure's kind and
never swapped one in. What Codex is told is unchanged.

Test: TestCodexCapacityNotLabelledUsageLimit (two ChatGPT accounts,
acct-1 529 with the backend's overload and with the words Codex
showed, acct-2 429 usage_limit_reached): the row is 529 · server_error,
the overloaded account rests a minute at most, one account rests hours.

Run on mote (mote-run), at this tree on origin/main 7dd2434d3:
- broken by hand (the two swaps without ErrType): the new test FAILs,
  "row: 529 · \"usage_limit_reached\" · \"Codex: Selected model is at
  capacity. Please try a different model.\"", both subtests; restored,
  ok.
- gofmt -l internal/gateway: empty; go vet, GOOS=linux go vet -tags
  nogui, GOOS=windows go vet of ./internal/gateway: ok.
- go test -tags nogui -count=1 -timeout 45m ./internal/gateway: ok (791.8s)
- GUI files that render err_type (ledger-cache-tokens,
  usage-ledger-detail, usage-session-speed, usage-loops): Chromium 60
  pass 0 fail, WebKit 30 pass 0 fail (no GUI change).

Rebased on origin/main 844c35505 (no internal/gateway change since
7dd2434d3); the new test and the overload/spent tests: ok there.

Not tried: a real ChatGPT account at capacity (can't be made to
happen); the full ./... suite (runs after the push); Windows/Linux runs.
2026-11-04 19:25:42 +08:00
..
…
…
…
…
…
…
…
…