Skip to content

Account Pooler: exhausted-pool usage polling bursts trigger /api/oauth/usage 429s and hide current cached quotas #8555

Backlog

Description

@salemsayed

1. Summary

In a multi-account Claude pool (7 OAuth accounts), when accounts are exhausted or past switchThreshold, Account Pooler bursts /api/oauth/usage requests across every account in parallel on startup, every 5 minutes, and every 30 seconds during traffic, even for accounts whose blocking resetAt is hours or days in the future. Anthropic responds with HTTP 429 on /api/oauth/usage, and after #8455 those accounts then show only "Anthropic is rate-limiting usage checks for this account." in Provider usage with no quota bars, plan badge, or reset times even though bb pool status --json already has current limitWindows persisted in SQLite.

2. Versions and environment

  • bb version: 0.50.2-nightly.46711705056.1 (installed via bb updater; reproduced on main at 4d7a9af609)
  • Plugin: builtin:account-pool 0.1.0, builtin:provider-usage
  • OS / Node: Linux 7.0.0-43-generic, Node v24.22.3
  • Setup: 7 enabled Claude OAuth accounts (5 Team 5x, 1 Max 5x, 1 Max 20x) + 1 Codex OAuth account, switchThreshold: 0.95, 3 enrolled hosts routed through one Account Pooler hub.

3. Steps to reproduce

Live observation on a 7-account Claude pool:

  1. Run Claude traffic until accounts cross switchThreshold (0.95) or hit their 5h/7d limit (with known future resetAt values, 1h to 4d ahead).
  2. Let normal Claude requests continue arriving (or restart the bb server while accounts are exhausted) and open the Provider usage sidebar popover.
  3. Compare the Provider usage popover against bb pool status --json.

Minimal deterministic repro in plugins/account-pool/src/server.test.ts (against 4d7a9af609):

  1. Configure an OAuth account whose /usage returns five_hour: { utilization: 100, resets_at: now + 3600s }.
  2. Send POST /v1/messages at now, now + 30_000, and now + 60_000. Observe /usage is called again every 30s despite the future resets_at.
  3. Return HTTP 429 (without Retry-After) from /usage, then call provider-usage.v1.getResource with { resourceId, refresh: false } on a cold provider-usage cache while the cached window's resetAt is still in the future. Observe { status: "error", message: "Anthropic is rate-limiting usage checks for this account." } instead of the valid cached windows.

4. Expected vs actual

Actual (observed live on 0.50.2-nightly.46711705056.1):

{
  "email": "[email protected]",
  "error": null,
  "status": "exhausted",
  "observedAt": 1796210898158,
  "limitWindows": [
    { "slot": "primary", "windowMinutes": 300, "utilization": 1, "resetAt": 1796212800059, "status": "rejected", "source": "usage" },
    { "slot": "secondary", "windowMinutes": 10080, "utilization": 0.52, "resetAt": 1796227200059, "status": "allowed", "source": "usage" }
  ]
}
{
  "email": "[email protected]",
  "error": null,
  "status": "exhausted",
  "observedAt": 1796210898134,
  "limitWindows": [
    { "slot": "secondary", "windowMinutes": 10080, "utilization": 1, "resetAt": 1796558400037, "status": "rejected", "source": "usage" }
  ]
}

Expected:

  • Exhausted/past-threshold accounts with a known future resetAt should not be polled every 30s on every incoming request; isRefusedWindow/isWindowPastThreshold already auto-clear them at resetAt, and the 5-minute background loop plus manual refresh cover mid-window changes.
  • Multi-account refreshes for the same provider should not fire all accounts concurrently in one Promise.all burst, and 429 responses without Retry-After should back off exponentially (not 1s) without being locked out for 5 minutes after retryAt expires.
  • When provider-usage has a cold cache (for example after a server restart) and calls getResource({ refresh: false }), account-pool should return its current persisted/header limitWindows (status: "ok") while at least one window is still un-reset, and still report status: "error" on explicit refresh: true or once all cached windows have reset (preserving Show stale and rate-limited usage honestly in the usage panel #8455).

5. Evidence

Root cause in main at 4d7a9af609:

  1. 30-second recheck ignores known future resetAt: forward() calls refreshExhaustedUsage() whenever selected === null or isPastThreshold(selected.quota, ...) (hub.ts#L528-L544). refreshExhaustedUsage() runs Promise.all over every OAuth account matching isPastThreshold at EXHAUSTED_USAGE_REFRESH_INTERVAL_MS (30s) (hub.ts#L342-L367), even when resetAt is hours or days ahead, despite isRefusedWindow/isWindowPastThreshold auto-clearing once resetAt <= now.
  2. Cold-cache refresh: false hides valid persisted windows: registerUsageSource() returns { status: "error" } whenever hub.usageCheckFailure(account.id) is non-null, regardless of refresh or whether account.limitWindows has un-reset windows (usage-source.ts#L143-L167). provider-usage only keeps cached bars alongside refreshError ("Showing last update.") if its own in-memory measurements map previously received a status: "ok" (provider-usage/server.ts#L191-L203, provider-usage/server.ts#L364-L369). When account-pool's startup burst 429s before provider-usage caches a reading, all bars disappear.
  3. Unstaggered Promise.all bursts and 429 backoff conflated with lastUsageRefreshAt: refreshUsage() fans out Promise.all across all OAuth accounts at once on hub start and every 5 minutes (hub.ts#L184-L187, hub.ts#L324-L340). On 429 without Retry-After, failedUsageRefresh() uses retryAfterMilliseconds() which defaults to 1_000 ms with no exponential backoff (provider-adapter.ts#L76-L88, quota.ts#L295-L304). Meanwhile refreshAccountUsage() stamps lastUsageRefreshAt before the fetch (hub.ts#L379-L382), so after a 429, passive checks (minIntervalMs = 5m) skip retrying even after retryAt has passed, leaving usageFailures stuck for 5 minutes.

6. What you ruled out

7. Suggested priority and effort

Affects any user with multiple OAuth accounts in Account Pooler once accounts near switchThreshold or exhaust; no data loss, workaround is inspecting bb pool status --json. Small, plugin-local fix in plugins/account-pool.

AGENT GENERATED

Activity

  1. added theissue type on Dec 2, 2026
  2. added
    providers
    confirmed-repro
    on Dec 2, 2026
  3. bb-slop-cop commented on Dec 2, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    Triage: Bug · Medium priority · Medium effort · providers

    REPRODUCED · High confidence · confirmed-repro · Reproduction and root-cause report. Five assertions exposed the same failures in two clean main checkouts with a simulated provider. The hub rechecks accounts before known quota resets, sends same-provider checks concurrently, and mixes retry timing with the normal refresh interval. After a 429, the usage source returns an error on a passive read even when an unexpired quota window is saved.

    No new PR: open PR #8556 already links this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-reproproviders

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions