Skip to content

Account Pooler: when every account is past switchThreshold, the pool returns 429 with a far reset although upstream still allows requests #6169

Closed

Description

@seklow

Summary

With the default switchThreshold of 0.98, Account Pooler does not just switch away from an account at 98 % utilization; it stops using that account completely. On 2026-10-21 the last Claude account below 98 % crossed the threshold. Four of the six enabled accounts were at 98–99 % with every window still allowed, but the pool answered every Claude request with its own 429. That 429 quoted the reset of one of the two accounts that upstream had actually rejected, so Provider Retry parked the thread for 2 h 47 min, while the same four accounts served traffic as soon as switchThreshold was set to 1. Expected: when no account is below the threshold, the pool routes to an account that upstream still allows instead of refusing.

Versions and environment

  • bb 0.46.1, installed through npm (bb-app), running as a systemd user service. desktop-v0.46.1 is the latest release. Debian 13 (trixie), Linux 6.12, x86_64, Node v24.22.1.
  • Built-in Account Pooler (account-pool) 0.1.0. switchThreshold was at its default 0.98 during the incident. Provider Retry 0.1.0 with maximumWait set to "6 hours".
  • Claude Code 2.1.308 during the incident (2.1.309 now), model claude-opus-5-5. The pool's Codex accounts (codex-cli 0.163.0) were not involved.
  • Pool: six enabled Claude OAuth accounts (Max and Pro), called A–F below in priority order. All had error: null and heldUntil: null, and extra usage was off (extraUsage.status: "rejected").
  • Unchanged on main at 1e80ca7b44bccd06c6da75ed9ca6ba497bd380f5:
    • git diff desktop-v0.46.1 1e80ca7b44 -- plugins/account-pool/src/quota.ts plugins/account-pool/src/hub.ts plugins/account-pool/src/contracts.ts is empty;
    • the installed server.js has the same activeWindow and select() filters.

Steps to reproduce

Live (this happened on 0.46.1; I did not drain the accounts a second time on purpose):

  1. bb plugin enable account-pool, add two or more Claude OAuth accounts, keep extra usage off and leave the default threshold (bb pool config shows switchThreshold: 0.98).
  2. Use the pool until every enabled Claude account has a 5h or 7d window at 0.98 or more, while at least one account has every window below 1 and "allowed" in bb pool account list --json.
    • Accounts are used one after another until each reaches the threshold (accounts-and-routing.md).
    • So after a heavy week this is the normal state, not a corner case.
  3. Send a turn in a pooled Claude thread, for example bb thread spawn --project <proj> --provider claude-code --prompt "Reply only with ok.".
  4. The turn fails with the 429 shown below. bb provider-retry explain <thread> --json shows blocked with the far retryAt.
  5. Run bb pool config set switchThreshold 1, then bb provider-retry retry <thread>. The turn now succeeds on one of the accounts the pool had excluded.

Source-level (deterministic, on main at 1e80ca7, Node ≥ 23.6 for type stripping, no install needed): save this as repro.mts in the repo root and run node repro.mts. It passes the pool state from the incident to the quota.ts predicates that select() and accountAvailability() use.

repro.mts
// repro.mts: run from the repo root at 1e80ca7 with Node >= 23.6: node repro.mts
import * as q from "./plugins/account-pool/src/quota.ts";

const now = Date.parse("2026-10-21T23:13:02.259Z"); // first pool 429
const family = q.modelFamily("claude-opus-5-5");
const at = (s: string | null) => (s === null ? null : Date.parse(s));
type W = [number, string, string | null]; // utilization, status, resetAt
const quota = (h5: W, d7: W) => ({
  usageRestriction: null, extraUsage: null, heldUntil: null, error: null, // extra usage off
  representativeClaim: null, limitWindows: [], observedAt: now,
  familyWeekly: { fable: null, sonnet: null, opus: null, haiku: null, other: null },
  fiveHourUtilization: h5[0], fiveHourStatus: h5[1], fiveHourResetAt: at(h5[2]),
  sevenDayUtilization: d7[0], sevenDayStatus: d7[1], sevenDayResetAt: at(d7[2]),
});
// Pool state at the incident (bb pool account list --json, usage poll 23:15Z)
const accounts = {
  A: quota([0.26, "allowed", "2026-10-22T02:50:00Z"], [0.98, "allowed", "2026-10-26T23:00:00Z"]),
  B: quota([0, "allowed", null], [0.99, "allowed", "2026-10-22T22:00:00Z"]),
  C: quota([0, "allowed", null], [0.98, "allowed", "2026-10-26T06:00:00Z"]),
  D: quota([0, "allowed", null], [1, "rejected", "2026-10-22T02:00:00.044Z"]),
  E: quota([0.99, "allowed", "2026-10-22T03:30:00Z"], [0.76, "allowed", "2026-10-26T01:00:00Z"]),
  F: quota([0, "allowed", null], [1, "rejected", "2026-10-24T05:00:00.434Z"]),
};
for (const threshold of [0.98, 1]) {
  // the predicate select() and accountAvailability() apply (hub.ts L862-L871, L1312-L1317)
  const rows = Object.entries(accounts).map(([name, a]) => {
    const exhausted = q.isQuotaExhausted(a, family, threshold, now) && !q.hasExtraUsage(a);
    const reset = q.blockingResetAt(a, family, threshold, now);
    return [name, exhausted ? `excluded until ${new Date(reset!).toISOString()}` : "eligible"];
  });
  console.log(threshold, Object.fromEntries(rows));
}

Output at 1e80ca7 (Node v24.22.1):

0.98 {
  A: 'excluded until 2026-10-26T23:00:00.000Z',
  B: 'excluded until 2026-10-22T22:00:00.000Z',
  C: 'excluded until 2026-10-26T06:00:00.000Z',
  D: 'excluded until 2026-10-22T02:00:00.044Z',
  E: 'excluded until 2026-10-22T03:30:00.000Z',
  F: 'excluded until 2026-10-24T05:00:00.434Z'
}
1 {
  A: 'eligible',
  B: 'eligible',
  C: 'eligible',
  D: 'excluded until 2026-10-22T02:00:00.044Z',
  E: 'eligible',
  F: 'excluded until 2026-10-24T05:00:00.434Z'
}

At 0.98 the earliest "excluded until" is exactly the time quoted in the 429. It belongs to D, one of the two accounts that upstream had actually rejected.

Did not reproduce:

Expected vs actual

Actual: the pool returned its own 429 in two threads, and no request reached Anthropic:

  • thr_t9xt22j7id at 23:13:02.948Z (shown below);
  • thr_biw5z6pxki at 23:13:41.585Z, quoting 02:00:00.165Z, which is the same window observed again.
API Error: Request rejected (429) · No Account Pooler account is currently eligible. Next account is expected to be available at 2026-10-22T02:00:00.044Z (in 10018 seconds).

Fields from bb pool account list --json at 23:19:19Z, with threshold 0.98. Labels are replaced; the other values are verbatim:

{"label": "A", "fiveHourUtilization": 0.26, "sevenDayUtilization": 0.98, "fiveHourStatus": "allowed", "sevenDayStatus": "allowed", "heldUntil": null, "error": null, "status": "exhausted"}
{"label": "B", "fiveHourUtilization": 0, "sevenDayUtilization": 0.99, "fiveHourStatus": "allowed", "sevenDayStatus": "allowed", "heldUntil": null, "error": null, "status": "exhausted"}
{"label": "C", "fiveHourUtilization": 0, "sevenDayUtilization": 0.98, "fiveHourStatus": "allowed", "sevenDayStatus": "allowed", "heldUntil": null, "error": null, "status": "exhausted"}
{"label": "D", "fiveHourUtilization": 0, "sevenDayUtilization": 1, "fiveHourStatus": "allowed", "sevenDayStatus": "rejected", "heldUntil": null, "error": null, "status": "exhausted"}
{"label": "E", "fiveHourUtilization": 0.99, "sevenDayUtilization": 0.76, "fiveHourStatus": "allowed", "sevenDayStatus": "allowed", "heldUntil": null, "error": null, "status": "exhausted"}
{"label": "F", "fiveHourUtilization": 0, "sevenDayUtilization": 1, "fiveHourStatus": "allowed", "sevenDayStatus": "rejected", "heldUntil": null, "error": null, "status": "exhausted"}

After switchThreshold was set to 1 at 23:20:28.9Z, bb pool status --json at 23:21:00Z showed A, B, C and E as "status": "ready" with the same utilization. D and F stayed exhausted.

Expected:

  1. The threshold works as a switch point. While any account is below it, that account wins, as it does today.
  2. When no enabled, non-errored, non-held account is below it for the request, accounts above the threshold that upstream still allows (no window rejected, utilization below 1) stay routable as a fallback tier.
    • Preferably the account with the lowest utilization on the window that crossed the threshold goes first, ties by priority. Plain ring order would also work.
    • select() already has this two-tier preference for extra usage (hub.ts L872-L884).
    • Conversations would move back to a below-threshold account when one recovers, as they already do for extra usage.
  3. In that case accountAvailability() returns ready.
    • That flows through to provider-retry.v1.availability, the 429 text and retry-after, so a reset is quoted only when no account is upstream-allowed.
    • bb pool account list and bb pool status show these accounts as usable (ready, or a separate fallback status), not exhausted.
  4. Hitting the real limit stays safe. On an upstream quota rejection, the pool already records the rejected status from the response headers and tries the next account within the same request (hub.ts L583-L599).
  5. If a hard reserve is wanted (Account Pooler: last-resort accounts, per-account switch thresholds, and an opt-in order by earliest weekly reset #4468 asks for per-account thresholds "to leave 30 % for another tool"), it should be an explicit per-account or opt-in setting, not what the pool-wide default does.

From the code, not observed: even at the maximum value 1, activeWindow excludes a window whose utilization is 1.0 and whose status is allowed. Where the pool has an upstream status, the fallback tier should go by that status.

Evidence

Timeline (UTC, 2026-10-21/22). Times come from createdAt in bb thread log <thr> --json and from the bb pool captures in thr_v6a8gpnpii:

  • 23:11:03–23:12:51: the last successful pooled turn (thr_8mbj8rkgtg) ran on E, the active account according to the pool's affinity table. After it, E's 5h window read 99 %, and no account was below 0.98.
  • 23:13:02.259: first pool 429. A running workflow in thr_t9xt22j7id failed, then that thread's main turn failed at 23:13:02.948. thr_biw5z6pxki and its workflow failed at 23:13:41.585.
  • 23:15:24: usage poll. At 23:17:40 and 23:19:19, bb pool account list --json showed all six accounts exhausted. A, B, C and E had every window allowed; D and F showed sevenDayStatus: "rejected" at 1.0.
  • 23:20:28.934: switchThreshold set to 1. At 23:21:00, A, B, C and E were ready.
  • 23:23:48.629: thr_biw5z6pxki was sent ahead of Provider Retry's schedule. From then until 01:59:56 it completed 14 turns with no provider error. In that window D was at 100 % until 02:00Z and F until 10-24, so every one of those turns ran on accounts that the 0.98 threshold had excluded.
  • 02:00:23.441: Provider Retry resumed thr_t9xt22j7id ("Please continue.", retryAttempt 2). That matches retryAt 02:00:00.044 plus 15–45 s of jitter. The thread stalled for 2 h 47 min 20 s.

The stored allowed status alone doesn't prove the accounts could serve. When the usage API omits a status, the pool derives allowed from utilization below 1 (usage.ts L82-L92). The 14 completed turns are the proof.

Code at 1e80ca7:

Investigation: thr_agudxusj98 (item R3 of its pool-research report). Diagnosis and config change: thr_v6a8gpnpii. Affected threads: thr_t9xt22j7id, thr_biw5z6pxki.

What you ruled out

Suggested priority and effort (optional)

Medium. Every pool on the default threshold hits this at the end of a heavy week. There's a workaround (bb pool config set switchThreshold 1), but it gives up switching early. No data is lost, but running workflow agents fail and threads stall for hours. Effort is probably low to medium: the fix extends the existing extra-usage fallback tier in select() and accountAvailability().

Checks

  • I reproduced this on the latest release or on main, or I say above that I could not.
  • I searched open and closed issues for the same problem.
  • If an agent wrote this, the body ends with > AGENT GENERATED and links the thread or report.

AGENT GENERATED

Activity

  1. added theissue type on Oct 23, 2026
  2. added
    providers
    provider-claude-code
    confirmed-repro
    on Oct 23, 2026
  3. bb-slop-cop commented on Oct 23, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority Medium · Effort Medium. Applied labels: providers, provider-claude-code, confirmed-repro.
    • Report: https://get-bb.github.io/reports/issues/6169.html
    • Verdict: REPRODUCED · root-cause confidence high. Repeated directly in two clean checkouts of trusted origin/main at 1e80ca7b4.
    • Root cause: Selection, account status, and retry availability treat the configured threshold as exhaustion even when upstream still allows the account; only extra usage bypasses it.
    • Evidence: The plugin-level regression returns 429 with zero upstream attempts and a rejected account's two-hour reset. Changing only the threshold to 1 restores 200 and ready availability. Both runs match; 14 relevant existing tests and the full build pass. The reproduction patch and output are embedded in the report; live account history was not accessed.
    • No PR: A soft fallback would change the documented hard-cutoff/reserve policy and requires a product decision, so it fails the simple-fix safety criteria.

    AGENT GENERATED

  4. hellno commented on Oct 30, 2026

    @hellno
    Contributor

    I'd like to fix this, but it changes documented behavior (docs/configuration.md) says accounts past switchThreshold stop receiving traffic), so checking first.

    my suggestion: when every account is past the threshold, keep routing to the ones upstream still allows (lowest utilization first, before extra usage) instead of returning the pool's own 429. Hard reserves would come from per-account thresholds (#4468).

    OK to go ahead?

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-reproprovider-claude-codeproviders

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions