Skip to content

Account Pooler keeps a stale 5-hour window while an account is busy: responses without 5h headers keep it, and usage refresh skips accounts with requests in flight #7418

Description

@seklow

Summary

Account Pooler keeps showing a 5-hour window for a Claude account after Anthropic stopped reporting one, for as long as the account stays busy. Two things combine:

  1. Responses without anthropic-ratelimit-unified-5h-* headers carry the old window forward unchanged.
  2. The usage poll that would drop the window (fixed for this case in Store Account Pooler's Claude 5-hour and 7-day limits as limit windows #7191) doesn't run while the account is busy. refreshAccountUsage skips any account that has requests in flight, and forced refreshes are skipped too.

Provider usage then shows the old value as current: 5h 3% with a live reset countdown, on an account that no longer has a 5-hour limit. The first usage poll that ran for it, once the account went idle, dropped the window. I expected the pool to drop the 5-hour window, or at least to show that the value is old.

Versions and environment

  • bb 0.49.0 (npm bb-app, systemd user service), Debian 13, Node v24.22.1.
  • Built-in Account Pooler with 8 Claude OAuth accounts (7 Max 20x, 1 Max 5x). Several bb threads use them at once.
  • Checked against main at 365d7c5237ae270be0555b5b44ea61020252713e. None of quota.ts, usage.ts, usage-source.ts or hub.ts has changed since Store Account Pooler's Claude 5-hour and 7-day limits as limit windows #7191.
  • The installed account-pool/dist/server.js has the same logic: return o===null&&a===null&&c===null?l:{…,observedAt:r,source:"header"} and async refreshAccountUsage(e,A,r=!1){let n=this.adapter(e.provider);if((this.inFlightByAccount.get(e.id)??0)>0)return;.

Steps to reproduce

This was observed on a live account. Whether an account has a 5-hour limit is decided by Anthropic, so I can't trigger it on demand.

  1. Pool a Claude account that loses its 5-hour limit while it keeps serving a few concurrent sessions, so it rarely has 0 requests in flight.
  2. Run bb pool account list --json and open Provider usage.
  3. Press Reload, or run bb pool account refresh <id>. By the code, the forced refresh hits the same in-flight check and the window stays. I did not try this during the incident.

Unit-level repro of the header half (run against quota.ts at the SHA above):

  1. Call quotaFromHeaders with a previous quota whose primary window is {utilization: 0.03, resetAt: 10:00Z, observedAt: 05:01:56Z}.
  2. Pass headers that hold only 7d-utilization, 7d-reset, 7d-status and representative-claim: seven_day_overage_included.
  3. It returns the same primary object (old observedAt, source: "header") and sets the account-level observedAt to now.

I did not unit-test the hub guard. Its code is quoted under Evidence.

Expected vs actual

Provider usage at ~06:28Z (2026-11-11), account A: 5h 3%, reset countdown 3h 32m, 7d 39%, 7d Fable 79%, plan badge Ultra.

The 5h values are exactly the stored values below: 3% is round(0.03 × 100), and 3h 32m is the time to 10:00:00Z, rounded up.

bb pool account list --json (non-secret fields), account A:

06:37:17Z  primary   u=0.03 reset=11-11T10:00Z allowed observedAt=05:01:56Z source=header
           secondary u=0.41 reset=11-16T06:00Z         observedAt=06:37:17Z source=header
           account observedAt=06:37:17Z  representativeClaim=seven_day_overage_included  status=ready
06:52:37Z  primary   u=0.03 reset=11-11T10:00Z allowed observedAt=05:01:56Z source=header   (unchanged)
           secondary u=0.44 reset=11-16T06:00Z         observedAt=06:52:30Z source=header
           account observedAt=06:52:30Z  inFlight=3
07:08:59Z  usage poll (no header writes since 07:06:13Z, so the account was idle):
           primary gone, only secondary left; header writes resume at 07:09:03Z
  • Account A was busy in every sample. I sampled it 25 times, about 5 s apart, from 06:43:08Z to 06:45:15Z. Its in-flight count was 2–5 every time, and 3 at 06:52:37Z.
  • Usage polls skipped it. Polls at 06:39:52Z, 06:44:53Z and 06:49:53Z updated every Claude account that was idle when sampled: their windows are now source: "usage". None of them touched account A's primary window. A poll that read five_hour or seven_day would have replaced or dropped that window (usage.ts#L184-L190).
  • The pool DB agrees. Its WAL holds 126 versions of account A's row, written between 06:32:15Z and 06:44:26Z. All of them come from headers, and all keep the same 05:01:56Z primary window.
  • Accounts B and C are busy too:
    • B has a 5-hour limit (representative claim five_hour) and still gets fresh 5h values from headers: primary u=0.9 observedAt=06:52:34Z source=header.
    • C has no stored 5-hour window and gets only 7d values from headers.

Actual: the 5-hour window stays stored and is shown as current for as long as the account is busy. A forced refresh hits the same in-flight check. The account-level observedAt keeps moving forward, so the account looks freshly observed.

Expected: a busy account still gets a usage poll, or at least one forced from the panel or CLI, and five_hour: null then drops the window as #7191 intended. Failing that, Provider usage should show that the window was last observed at 05:01Z instead of presenting it as current.

Evidence

  • Header merge. When a response has none of the three 5h-* headers, windowFromHeaders returns the previous window unchanged. When any of them is present, it stamps observedAt: now (quota.ts#L93-L105).
  • Every response is merged. Every upstream response goes through quotaFromHeaders (hub.ts#L620-L628).
  • The account timestamp hides the window's age. The account-level observedAt moves forward on any new window or representative-claim header (quota.ts#L147-L159).
  • In-flight guard. refreshAccountUsage returns early while the account has requests in flight, before the throttle check (hub.ts#L359).
    • All usage refreshes go through it (hub.ts#L308-L351): the 5-minute loop, refreshUsage(id, force) (used by the panel's Reload and by bb pool account refresh), and the exhausted-account recheck.
    • A request counts as in flight until its streamed body ends (hub.ts#L1251-L1254, #L1304-L1333).
  • Publishing to Provider usage. The usage source publishes every stored window and drops only those with utilization === null. It passes the account-level observedAt, not each window's (usage-source.ts#L93-L156).
  • No expiry. Nothing expires a window by age or after its resetAt. Routing only ignores a window whose reset has passed (quota.ts#L182-L198).
  • Investigation: bb thread thr_agudxusj98 (private).

What you ruled out

Suggested priority and effort

Low priority. It is display-only here (3%, allowed). The window cleared at the first poll that found account A idle: 07:08:59Z, 2 h 7 min after the last 5h header. On an account that never goes idle it would stay.

Possible fixes:

  1. Let usage polls run while requests are in flight, at least for forced refreshes or when the stored windows are older than the poll interval. This looks small. Git blame on the guard stops at a refactor (Remove dead code and dedupe shared logic across the monorepo #3583), and the guard already existed before it, so I don't know what it protects.
  2. In quotaFromHeaders, treat a response that has 7d-* headers but no 5h-* headers as "no 5-hour window". This needs confirmation that Anthropic sends 5h-* whenever the limit exists. Account B's data is consistent with that, but it is one account.
  3. Pass each window's observedAt to Provider usage and mark old windows (Account Pooler: re-authenticate an existing account in place, add accounts disabled or with a priority, and show login expiry #6170).

Checks

  • Observed on the latest release (0.49.0). I checked the code on main at the SHA above but did not run main.
  • Searched open and closed issues and PRs: five_hour, 5-hour window, limitWindows, anthropic-ratelimit-unified, windowFromHeaders, in-flight usage refresh.

AGENT GENERATED

Activity

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

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority: Low · Effort: Low · area: providers.
    • Report: https://get-bb.github.io/reports/issues/7418.html — REPRODUCED, high root-cause confidence; verified again by the same agent in a second clean trusted checkout. Applied confirmed-repro.
    • Root cause: the in-flight guard skips authoritative usage refreshes, including forced refreshes, while partial headers retain older windows.
    • Regression: a real-plugin CLI test keeps a response streaming and checks that refresh removes an obsolete primary window. It fails before the fix in both checkouts and passes afterward; all 395 plugin tests, typecheck, and lint pass (three existing lint warnings, no errors). Provider responses are synthetic; no live account was accessed.
    • Ready PR: Allow usage refreshes while pooled accounts are streaming #7419 — removes the guard, retaining refresh deduplication and throttling; 94 changed text lines across two files. Not merged.

    AGENT GENERATED

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