Skip to content

Claude usage: 429 from /api/oauth/usage is not cached, Retry-After is ignored, and the last good value is dropped #6669

Open

Description

@Kylo6

bb 0.48.0 (macOS), provider-claude-code bundled.

What happens

Several readers poll provider usage: the Provider usage settings section every 60 s, the sidebar footer card every 2 min and on focus, plugins through sdk.system.usageLimits(), and the CLI through bb settings usage. Anthropic then answers 429 on GET https://api.anthropic.com/api/oauth/usage. From then on claude-code reads status: "error" ("Anthropic temporarily throttled this usage check…") with no windows, often for long stretches. On 30 Oct we sampled once per minute from 14:44Z to 15:04Z: 17 errors out of 21 reads.

Why it self-sustains (from the shipped code)

  1. server/src/services/system/usage-limits.ts: ttlMs is 10_000 for a good result and 0 for an error. While Anthropic throttles, every reader triggers a new upstream call, which prolongs the throttling.
  2. provider-claude-code getClaudeProviderUsage (dist/host.js) maps a 429 to an error but discards the Retry-After header. Claude Code CLI 2.1.314 handles the same endpoint differently: it remembers a 429 per bearer for Retry-After, or 5 min without one (capped at 1 h), and shows "last-known usage".
  3. The provider-usage.v1.getResource source in provider-claude-code caches only ok results (60 s) and overwrites the stored value with the error state. Consumers outside the bundled Provider usage plugin therefore lose the last good windows; only observedAt survives.

Suggested fix

  • Cache an error result until Retry-After (default about 5 min, capped), keyed like the good result, so that every reader shares one backoff.
  • Keep the last good windows next to the error state (for example lastGood: { windows, observedAt }) so that plugins can show a stale value with its age instead of nothing.
  • Optionally, raise the good-result TTL to the order of minutes: weekly and 5-hour percentages do not need 10 s freshness.

Workaround on our side: a plugin reads usageLimits() once every 5 min, backs off 10, 20, then 30 min on errors, keeps the last good value with its age, and serves it to our other readers. The native panel still polls on its own.

Activity

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

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority: Medium · Effort: Medium.
    • Labels: providers, provider-claude-code, confirmed-repro.
    • Reproduction report: REPRODUCED · root-cause confidence: high.
    • Root cause: the provider discards retry timing, server errors receive zero cache lifetime, and the usage resource replaces successful windows with an uncached error.
    • Evidence: provider/resource tests and server test reproduce three assertion failures in two clean checkouts of 9662c45478. All 11 existing focused tests pass. Responses are synthetic; live Anthropic throttling duration was not verified.
    • No PR: a complete repair needs cross-boundary retry/stale-result contracts and policy decisions, outside this rule’s simple-fix limits.

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

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions