Repository navigation
Show stale and rate-limited usage honestly in the usage panel - #8455
Merged
Merged
Conversation
Anthropic's /api/oauth/usage can answer 429 with a Retry-After for one
account. The Claude and Codex adapters discarded every non-OK usage
response without a trace, so the pool kept the last good reading and the
usage panel showed it as current indefinitely, even after the window's
reset time had passed ("83%, resets now" for days).
Account Pooler: adapters report whether a usage check failed and, for a
429, when to retry. The hub skips checks for that account until then, and
the usage source reports the failure ("Anthropic is rate-limiting usage
checks for this account.") until a check succeeds, so the panel shows the
reason next to the last update instead of presenting it as fresh.
Provider usage panel and settings: windows whose reset time has passed are
no longer drawn with their old percentage, for every usage source. An
account whose windows have all reset says "Limits have reset since the
last update." and a refresh error only claims "Showing last update." when
there is still something shown.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
scowalt
pushed a commit
to scowalt/bb
that referenced
this pull request
Dec 1, 2026
…#8455) ## Human comments ## What was wrong Anthropic's `/api/oauth/usage` can answer `429` with a `Retry-After` for a single account. In one live case the endpoint had been returning 429 for four days. Account Pooler's Claude and Codex adapters dropped every non-OK usage response, and `refreshAccountUsage` ended in `.catch(() => undefined)`, so the pool kept the last good reading and reported the account as healthy. The Provider usage panel then drew that reading as current indefinitely, including windows whose reset time had already passed. The account showed "7d 83%, resets now" for days after the limit had reset. ## What changed **Account Pooler** (`plugins/account-pool`) - `ProviderAdapter.refreshUsage` now returns `{ kind: "done" } | { kind: "failed"; retryAt }`. A 429 records `retryAt` from `Retry-After`. Other non-OK responses, unparseable bodies and thrown errors count as failed checks. - The hub skips usage checks for an account until `retryAt` has passed. This applies to forced refreshes too, since the endpoint would refuse them anyway. - Until a check succeeds, the usage source reports the failure: "Anthropic is rate-limiting usage checks for this account." (or "OpenAI …"), or "Couldn’t check usage for this account." for other failures. Provider usage already shows a source error next to the cached measurement as a refresh error. **Provider usage** (`plugins/provider-usage`, footer card and settings) - Windows whose `resetsAt` has passed are no longer drawn with their old percentage, for every usage source. - An account whose windows have all reset says "Limits have reset since the last update." - A refresh error only appends "Showing last update." when some windows are still shown. - New Ladle scenario "stale usage" with one account per state. There are no wire, CLI or guide changes. Related: get-bb#7739 covers the silent-refresh-failure part. Disabled-source handling, warn logging and per-reading age are not addressed here. get-bb#6669 is the same 429 pattern in `provider-claude-code`, which this PR does not touch. ## How you verified - Reproduced live: `bb pool account list --json` showed the account's last observation 4 days old, with `resetAt` 2 days in the past. Calling `/api/oauth/usage` with that account's token returned `429`, with `Retry-After: 2977` counting down. The pool showed no error. - `server.test.ts`, "backs off usage checks the provider rate-limits and reports the failure until a check succeeds": a 429 is reported as an error, no upstream call is made before `Retry-After`, and the next check after it recovers. The test fails when the hub's backoff check is removed (an extra `/usage` call). - `app.test.tsx` gains a `reset-since-update` case: a window past its reset shows no percentage, and the refresh error is shown without "Showing last update." - Ladle ("stale usage" row in `plugins--provider-usage--disclosure` and `--settings`), rendered on main and on this branch for six states: healthy, checks failing, partly reset, fully reset, failing and reset, and no reading. On main every stale account shows its old percentages, with "now" or "Resetting now" for windows that already reset. On this branch reset windows are gone and failing checks show their reason. - `pnpm exec turbo run typecheck lint test --filter=bb-plugin-account-pool --filter=bb-plugin-bb--provider-usage` passes (406 and 26 tests). > AGENT GENERATED 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
Anthropic's
/api/oauth/usagecan answer429with aRetry-Afterfor a single account. In one live case the endpoint had been returning 429 for four days. Account Pooler's Claude and Codex adapters dropped every non-OK usage response, andrefreshAccountUsageended in.catch(() => undefined), so the pool kept the last good reading and reported the account as healthy. The Provider usage panel then drew that reading as current indefinitely, including windows whose reset time had already passed. The account showed "7d 83%, resets now" for days after the limit had reset.What changed
Account Pooler (
plugins/account-pool)ProviderAdapter.refreshUsagenow returns{ kind: "done" } | { kind: "failed"; retryAt }. A 429 recordsretryAtfromRetry-After. Other non-OK responses, unparseable bodies and thrown errors count as failed checks.retryAthas passed. This applies to forced refreshes too, since the endpoint would refuse them anyway.Provider usage (
plugins/provider-usage, footer card and settings)resetsAthas passed are no longer drawn with their old percentage, for every usage source.There are no wire, CLI or guide changes.
Related: #7739 covers the silent-refresh-failure part. Disabled-source handling, warn logging and per-reading age are not addressed here. #6669 is the same 429 pattern in
provider-claude-code, which this PR does not touch.How you verified
bb pool account list --jsonshowed the account's last observation 4 days old, withresetAt2 days in the past. Calling/api/oauth/usagewith that account's token returned429, withRetry-After: 2977counting down. The pool showed no error.server.test.ts, "backs off usage checks the provider rate-limits and reports the failure until a check succeeds": a 429 is reported as an error, no upstream call is made beforeRetry-After, and the next check after it recovers. The test fails when the hub's backoff check is removed (an extra/usagecall).app.test.tsxgains areset-since-updatecase: a window past its reset shows no percentage, and the refresh error is shown without "Showing last update."plugins--provider-usage--disclosureand--settings), rendered on main and on this branch for six states: healthy, checks failing, partly reset, fully reset, failing and reset, and no reading. On main every stale account shows its old percentages, with "now" or "Resetting now" for windows that already reset. On this branch reset windows are gone and failing checks show their reason.pnpm exec turbo run typecheck lint test --filter=bb-plugin-account-pool --filter=bb-plugin-bb--provider-usagepasses (406 and 26 tests).🤖 Generated with Claude Code