Skip to content

Store Account Pooler's Claude 5-hour and 7-day limits as limit windows - #7191

Merged
ymichael merged 2 commits into
mainfrom
bb/triage-and-resolve-issue-7149-thr_zesahud2s8
Nov 6, 2026
Merged

ymichael merged 2 commits into
mainfrom
bb/triage-and-resolve-issue-7149-thr_zesahud2s8

Conversation

@ymichael

@ymichael ymichael commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Account Pooler stored Claude's shared limits in dedicated fiveHour*/sevenDay* fields, and the usage refresh (quotaFromUsage) fell back to the previous value for each field. GET /api/oauth/usage returning five_hour: null (the account has no 5-hour limit) therefore kept the last observation. five_hour: { utilization: 0, resets_at: null } (no window running) kept a reset from days ago, which Settings showed as "resets in 1m". A stale rejected 5-hour window kept the account exhausted, so requests got 429 until that stale reset passed. Codex didn't have this bug: it already stored limits as a limitWindows list rebuilt from each usage response. Reported in #7149.

What changed

  • Storage shape: Claude now records its limits in limitWindows, the list Codex already uses. The 5-hour limit is the primary window (300 min) and the 7-day limit is the secondary window (10080 min). The fiveHour*/sevenDay* fields are removed from AccountQuota/AccountSummary (src/contracts.ts).
  • Usage refresh (src/usage.ts): a usage response rebuilds the list, so a null bucket drops its window and a null reset clears it. A response with neither bucket keeps the previous windows.
  • Rate-limit headers (src/quota.ts): they now write into the same windows and still merge field by field with the previous window, because a missing header means "not sent".
  • Readers: routing (quotaWindows), the settings row and dialog, the provider-usage source and the CLI now read one shape for both providers. The settings UI keeps Claude's own labels ("5H"/"7D", "5 hour"/"7 day") and its empty 5H/7D slots for an account with no observed usage. The only visible change is that a window Anthropic no longer reports disappears, and a stale reset is no longer shown.
  • Migration (src/store.ts): an appended migration copies the stored five_hour_*/seven_day_* columns into limit_windows_json and nulls them. The columns stay so older builds can still open the database.
  • CLI/JSON: bb pool account list --json and bb pool status --json no longer include fiveHourUtilization, fiveHourResetAt, fiveHourStatus, sevenDayUtilization, sevenDayResetAt and sevenDayStatus. The same data is in limitWindows. The bb pool account list table drops its 5h/5h reset/7d/7d reset columns; the existing Windows column now shows Claude's windows (5h=…; 7d=…). No docs or skills referenced the removed fields or columns.
  • Dead code: removed the unused governingWeeklyResetAt and longestLimitWindow.
  • Provider usage source (src/usage-source.ts): Account Pooler now lists only signed-in (OAuth) accounts to Provider usage. API-key accounts are billed per token and have no usage windows. Before, each one showed up as a "Claude Code" row that said "Usage has not been observed for this account." or "No usage limits reported for this plan." Fetching an API-key account id now reports it as unknown.

This goes further than the issue's suggested fix (clear the fields on null). It makes Claude use the same window model as Codex, so the field-by-field fallback that caused the bug no longer exists on the usage path.

How you verified

  • Typecheck, lint and tests for the package: pnpm exec turbo run typecheck lint test --filter=bb-plugin-account-pool passes 393/393. The 3 lint warnings in app.tsx already exist on main.
  • New src/usage.test.ts: five_hour: null drops a rejected 5-hour window and the account is no longer exhausted, resets_at: null clears the reset, and a response with neither bucket keeps the previous windows. The first two cases failed on main.
  • New store test: the migration moves Claude columns into windows, leaves Codex rows alone and nulls the old columns. I also ran the migration on a VACUUM INTO copy of a real Account Pooler database (2 Claude rows and 1 Codex row); every row converted and read back through QuotaStore.
  • New app tests: Claude keeps the "7 day" label (not Codex's "Weekly"), and an unobserved Claude account shows empty 5H/7D slots. Both fail if the label is changed to "Weekly".
  • Provider usage source: the server test now adds an API-key account next to an OAuth account and checks that only the OAuth account is listed and that fetching the API-key id is rejected. It fails without the filter.
  • End to end through the in-process server (a temporary test, not committed), with a stale rejected 5-hour window followed by five_hour: null:
    • main: still exhausted, request → 429
    • this branch: ready, request → 200
  • Side by side on two dev instances (main and this branch), each given the same stale state and the issue's usage responses through its own code:
    • Account A (previously 5-hour-rejected, now no 5-hour limit): main shows "Exhausted · resets in 1h 59m"; this branch shows Ready with no 5H column.
    • Account B (no 5-hour limit): main shows "5 hour 0% · resets in 1m" from a 6-day-old reset; this branch shows only the 7-day row.
    • Account C (idle window): main shows "resets in 1m"; this branch shows 0% with no reset.

Fixes #7149

AGENT GENERATED

🤖 Generated with Claude Code

ymichael and others added 2 commits November 6, 2026 10:18
Claude quotas kept dedicated fiveHour*/sevenDay* fields, and the usage
refresh fell back to the previous value for each one. `five_hour: null`
(no five-hour limit) therefore kept the last observation, `resets_at: null`
(no window running) kept a past reset, and a stale rejected five-hour window
kept the account exhausted until that reset passed.

Claude now records these limits in `limitWindows`, the list Codex already
uses: the five-hour limit is the 300-minute primary window and the seven-day
limit the 10080-minute secondary window. A usage response rebuilds the list,
so an absent bucket drops its window and a null reset clears it. Rate-limit
headers still merge into the previous window, because a missing header means
"not sent". Routing, the settings row and dialog, the provider-usage source,
and the CLI now read one shape for both providers. The settings UI keeps
Claude's own labels ("5 hour", "7 day") and shows empty 5H and 7D slots for
an account with no observed usage; the only visible change is that a window
Anthropic no longer reports disappears.

A migration copies the stored columns into limit_windows_json and nulls
them; the columns stay so older builds can still open the database.
`bb pool account list --json` and `bb pool status --json` no longer include
the fiveHour*/sevenDay* fields, and the CLI table drops its 5h/7d columns
in favour of the existing Windows column. The unused governingWeeklyResetAt
and longestLimitWindow are removed.

Fixes #7149

Co-Authored-By: Claude Opus 5.5 <[email protected]>
API-key accounts are billed per token and have no subscription usage
windows, yet Account Pooler published every pooled account to Provider
usage. Each one appeared as a "Claude Code" row that said "Usage has not
been observed for this account." or "No usage limits reported for this
plan." The usage source now lists only signed-in (OAuth) accounts and
treats an API-key account id as unknown when fetched.

Co-Authored-By: Claude Opus 5.5 <[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.

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)

1 participant