Repository navigation
Description
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:
- Responses without
anthropic-ratelimit-unified-5h-*headers carry the old window forward unchanged. - 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.
refreshAccountUsageskips 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
mainat365d7c5237ae270be0555b5b44ea61020252713e. None ofquota.ts,usage.ts,usage-source.tsorhub.tshas changed since Store Account Pooler's Claude 5-hour and 7-day limits as limit windows #7191. - The installed
account-pool/dist/server.jshas the same logic:return o===null&&a===null&&c===null?l:{…,observedAt:r,source:"header"}andasync 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.
- 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.
- Run
bb pool account list --jsonand open Provider usage. - 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):
- Call
quotaFromHeaderswith apreviousquota whose primary window is{utilization: 0.03, resetAt: 10:00Z, observedAt: 05:01:56Z}. - Pass headers that hold only
7d-utilization,7d-reset,7d-statusandrepresentative-claim: seven_day_overage_included. - It returns the same primary object (old
observedAt,source: "header") and sets the account-levelobservedAtto 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 readfive_hourorseven_daywould 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.
- B has a 5-hour limit (representative claim
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,windowFromHeadersreturns the previous window unchanged. When any of them is present, it stampsobservedAt: now(quota.ts#L93-L105).- Header writes for account A continue, but its primary
observedAtstays at 05:01:56Z. So no response since then has carried a 5h header. - Store Account Pooler's Claude 5-hour and 7-day limits as limit windows #7191 kept this merge on purpose ("a missing header means 'not sent'").
- Header writes for account A continue, but its primary
- 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
observedAtmoves forward on any new window orrepresentative-claimheader (quota.ts#L147-L159). - In-flight guard.
refreshAccountUsagereturns 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 bybb 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).
- All usage refreshes go through it (hub.ts#L308-L351): the 5-minute loop,
- Publishing to Provider usage. The usage source publishes every stored window and drops only those with
utilization === null. It passes the account-levelobservedAt, 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
- Not a reopen of Account Pooler keeps stale 5-hour values when an account has no 5-hour limit (five_hour: null) or no window running (resets_at: null) #7149. Store Account Pooler's Claude 5-hour and 7-day limits as limit windows #7191 fixed that report's path, a usage response with
five_hour: null, and tests it (usage.test.ts#L52). Here that path doesn't run while account A is busy, because of the in-flight guard, and Store Account Pooler's Claude 5-hour and 7-day limits as limit windows #7191 left the header merge unchanged. - Not panel caching. The pool's own stored state holds the same window.
- Probably not a failing usage call. Usage-poll failures aren't logged (hub.ts#L387, claude-adapter.ts#L120-L133), so
plugin.logcan't rule it out. But the same polls updated every idle account, and account A was busy in every sample. - Not a duplicate of Provider usage retains Claude Max badge after paid subscription lapses, with only a generic refresh warning #6685 or Claude usage: 429 from /api/oauth/usage is not cached, Retry-After is ignored, and the last good value is dropped #6669 (error handling in Provider usage and in the Claude Code provider) or Account Pooler: rejected OAuth refresh (invalid_grant) leaves Claude account
readywith stale quota instead of error #7121 (pool error state afterinvalid_grant). - Related to Account Pooler: re-authenticate an existing account in place, add accounts disabled or with a priority, and show login expiry #6170 (comment): Provider usage shows pool values without their age.
- The 5-hour limit really is gone. The usage poll at 07:08:59Z rebuilt account A's windows without a primary window, which happens only when the response has no usable
five_hourbucket (usage.ts#L124-L133). Before that, 5h headers stopped after 05:01:56Z while 7d headers continued.
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:
- 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.
- In
quotaFromHeaders, treat a response that has7d-*headers but no5h-*headers as "no 5-hour window". This needs confirmation that Anthropic sends5h-*whenever the limit exists. Account B's data is consistent with that, but it is one account. - Pass each window's
observedAtto 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
mainat the SHA above but did not runmain. - Searched open and closed issues and PRs: five_hour, 5-hour window, limitWindows, anthropic-ratelimit-unified, windowFromHeaders, in-flight usage refresh.
AGENT GENERATED
Activity
bb-slop-cop commentedon Nov 11, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotproviders.confirmed-repro.