[bug] Pool token bucket returns a local 429 without Retry-After when only one account is selectable; Codex does not retry and long-running goals stall
Summary
With several accounts in the pool but only one of them currently selectable (the others are skipped as rate-limited / near weekly exhaustion), the runtime rotation proxy answers Codex with a locally synthesized 429 as soon as that one account's client-side token bucket runs dry. The response carries no Retry-After. Codex CLI does not retry such a 429, reports exceeded retry limit, last status: 429 Too Many Requests, and a long-running /goal session stalls — while the remaining account still has most of its weekly quota and is answering 200 upstream in the same minute.
Versions
- codex-multi-auth 2.26.1 (the relevant code is identical in 2.26.2:
dist/lib/rotation.js,dist/lib/accounts.js, and thebypassPoolTokenBucketline indist/lib/runtime-rotation-proxy.js) - codex-cli 0.170.0, macOS, launched through
codex-multi-auth-codex(session helper proxy,nativeOpenainot set)
What was observed
- Pool of 3 accounts. Two were being skipped (weekly window at 95% used), so one account carried a multi-agent session alone: about 8–10
responsesrequests per minute per model. - Usage ledger rows for the failures:
statusCode 429,errorCode rate-limit, no account,durationMs0–6. In the same 10-minute window the carrying account completed 134 requests with 200. - Replaying the ledger through
TokenBucketTracker(maxTokens: 50,tokensPerMinute: 6, keyed per account andfamily:model), starting from the lastpool-exhausted-no-accountruntime reset, gives a bucket level below 1 at every failure timestamp (0.87, 0.50, 0.75, 0.55, 0.87) and never below 0 anywhere else. An earlier pair of the same failures replays to 0.02.
So the rejecting gate is consumeTokenWithReason → token-exhausted, and with every other account already skipped the request ends in writePoolExhausted with reason rate-limit.
Why it hurts
bypassPoolTokenBucketis only true for a pin, transcription, ornativeOpenai. The comment above it already states the principle: a pin "has no alternative account, so exhausting that local heuristic can only reject a request that the pinned account could serve". The same is true when rotation has no other selectable account, but that case is not covered.- Client behaviour, measured against a stub server that always returns 429:
- no
Retry-After: codex-cli sends 1 request and fails at once (request_max_retries=8changes nothing); Retry-After: 2: codex-cli sends 6 requests, 2 s apart, before giving up.
- no
- The bucket refills one token every 10 s, so a short wait would have been enough.
Suggested fix (any one of these would do)
- Bypass the pool token bucket when no other account is selectable for the request (treat it like the pinned case).
- Or wait for the next token (bounded, e.g. up to 10–15 s) instead of failing when the only blocker is
token-exhausted. - At minimum, send
Retry-After= time until the next token on a pool exhaustion whose only live blocker istoken-exhausted, so Codex retries.
Making the bucket size / refill rate configurable would also help multi-agent workloads.