Repository navigation
Description
Client or integration
Claude Code CLI 2.1.311 and Codex CLI 0.164.0, both through OpenCodex on 127.0.0.1:10100 (Anthropic OAuth account pool, Messages and Responses).
Area
Account pool / session affinity (Anthropic).
Summary
One Claude Code session should stay on one Anthropic account until that account is truly exhausted or unusable. On 2.92.0 a session moves to another account in three ordinary situations, so prompt caches go cold and one conversation is spread over several accounts.
Measured on our usage ledger over 24 hours (2026-10-26 16:41 to 2026-10-27 16:41 KST): 204 identifiable multi-call Claude conversations, 16 of them used more than one account, 39 transitions in total, and none of the transitions followed a positive quota-exhaustion marker. In the same window 195 GPT conversations through the Codex pool changed account 0 times.
Causes we found in the installed source (src/oauth/anthropic-routing.ts):
- The binding lives only in memory (
sessionAffinity, a RoutingMap). Every proxy restart, including a machine reboot, drops all bindings, and the next request of a running session is placed bystrategy(round-robin in our case) on a different account. - Any 429 clears every binding of that account (
clearAnthropicSessionAffinityForAccount(failedAccountId)after the cooldown write, around line 1270), also for a short request-rate 429 where the account still has quota in its 5-hour and weekly windows. - A cooled account fails
stillUsableand the binding is deleted (around line 1043), so a short cooldown permanently moves the session instead of pausing it.
Round-robin itself is fine for choosing the first account of a new session; the problem is only that existing bindings do not survive these events.
Reproduction
- Enable the Anthropic account pool with two or more accounts,
strategy: round-robin. - Start a Claude Code session and make a few requests; note the account label in the usage ledger.
- Restart OpenCodex (or trigger one 429 on that account) and send the next request of the same session.
- The request is served by another account; the binding is gone.
Version
opencodex 2.92.0 (latest on npm on 2026-10-27).
Operating system
macOS (Apple silicon).
Provider and model
anthropic OAuth pool, claude-opus-5-5 and claude-sonnet-5-5.
Logs or error output
No error; the effect is visible only as changing account labels inside one conversation in the usage ledger.
Proposed fix
- Persist the session-to-account map (for example next to the usage ledger, with the existing 24 h idle TTL and 2000-entry cap), and load it at start, so a restart keeps every binding.
- On a request-rate 429 where the account still has quota (the rejected window is not the 5-hour or weekly quota window), keep the binding: wait for Retry-After or the cooldown and retry the same account, or serve only that one request elsewhere without rebinding.
- Rebind only when the account is positively exhausted for the model, paused, needs re-auth, or removed; log each rebind with its reason so it can be audited.
- Optional: a config switch such as
anthropicAccountPool.affinityStrict: truefor users who need strict one-session-one-account behaviour.
Checks
- I searched existing issues and documentation.
Activity
fix(anthropic): preserve affinity only for detours, not for exhausted…
fix(anthropic): keep pool session affinity across restarts and transi…
lidge-jun commentedon Oct 28, 2026
Fixed in #7828, merged to
devas d9ae8e5.dev(fix(anthropic): classify 429s and admit by per-model weekly quota in the Claude account pool #6443): a request-rate 429 pauses the account briefly, a shared 5h/7d rejection cools it and clears its bindings. What remained was a race where a short pause expiring during a detour rebound the session; a detour now keeps the original binding (bounded by a five-minute grace), while measured exhaustion, shared-quota and entitlement refusals still rebind.Ships with the next release from
dev.