Skip to content

Return Account Pool accounts rejected during an outage once usage succeeds - #4383

Closed
ymichael wants to merge 1 commit into
mainfrom
fix/account-pool-outage-error-recovery
Closed

ymichael wants to merge 1 commit into
mainfrom
fix/account-pool-outage-error-recovery

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

During the 2026-09-25 Codex outage, upstream answered pooled requests with 401 invalid_api_key. The hub responded as it would to a stale token: it force-refreshed the OAuth credential, which succeeded, and retried. The retry also got a 401, so markAuthError recorded an error on the account. Nothing ever cleared that error. Selection skips errored accounts, and the only automatic clear is a successful OAuth refresh inside freshSecret, which throws before refreshing when the account is errored. The periodic five-minute usage refresh goes through freshSecret too, so it also threw. That left both Codex accounts out of routing after OpenAI marked the incident resolved. At the same time, wham/usage accepted both stored tokens, and requests succeeded once the errors were cleared by hand with bb pool account enable.

What changed

  • ProviderAdapter.refreshUsage now resolves true when the upstream usage endpoint accepted the account's credentials (Claude and Codex adapters).
  • hub.ts: the usage refresh requests its secret with a new usage secret use that is exempt from the error gate. When the usage endpoint accepts the credential, the hub clears the error and publishes an accounts-changed update. Request paths keep the gate, so in-flight requests still stop using an account another request just marked in error.
  • Accounts with credentials that are really invalid stay in error, because their usage call is rejected too. An errored account with an expired token and a dead refresh token now makes one refresh attempt per five-minute cycle.
  • bb pool account refresh <id> now also clears a recovered account's error immediately.
  • Docs: PLUGIN_OVERVIEW.md and the account-pool skill reference describe the recovery.

How you verified

  • New test returns an account rejected during an outage once usage accepts its credentials: a request 401s through a successful forced refresh, the account is in error, and requests get 429. After the outage ends, account.refreshUsage reports ready and the next request returns 200. Without the fix it fails with expected 'error' to be 'ready'.
  • pnpm exec turbo run typecheck lint test --filter='...[origin/main]': 9/9 tasks passed, 314/314 account-pool tests.
  • Live: confirmed both stuck accounts' stored tokens got 200 from wham/usage while the pool still reported them in error.

AGENT GENERATED

🤖 Generated with Claude Code

…ceeds

A 401 during a provider outage forces an OAuth refresh, and a second 401
on the fresh token marks the account in error. Nothing cleared that error:
selection skips errored accounts and freshSecret refused to hand the
periodic usage refresh a credential for one. Both Codex accounts stayed
out of routing after the 2026-09-25 Codex outage until re-enabled by hand.

The usage refresh now obtains its credential past the error gate, and an
accepted usage response clears the error. Request paths keep the gate.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant