Skip to content

fix(claude): keep limits when the usage fetch fails - #10597

Open
Mhmdhammoud wants to merge 9 commits into
pingdotgg:mainfrom
Mhmdhammoud:fix/claude-usage-limits-throttled
Open

fix(claude): keep limits when the usage fetch fails#10597
Mhmdhammoud wants to merge 9 commits into
pingdotgg:mainfrom
Mhmdhammoud:fix/claude-usage-limits-throttled

Conversation

@Mhmdhammoud

@Mhmdhammoud Mhmdhammoud commented Sep 7, 2026

Copy link
Copy Markdown

What Changed

claudeUsageResponseToLimits now distinguishes two shapes of the SDK get_usage response:

  • rate_limits_available: falseunsupported (API key, Bedrock, Vertex, missing scope), as before.
  • rate_limits_available: true with rate_limits: nullprobeFailed, new.

One test added for the second shape.

Why

Claude Code keeps rate_limits_available true and nulls rate_limits when its own usage fetch fails, for example when /api/oauth/usage answers 429. T3 treated that as unsupported, which hid the Claude card on Usage → Limits and made /usage-limits report "This account has no subscription limits." on an active Max account.

probeFailed is the reason the publish path already handles: resolvePublishedUsageLimits keeps the last good windows until the next successful probe, so a throttled read now leaves the card in place instead of removing it.

Reproduced on a Max 20x account during a 24-minute 429 cooldown on the usage endpoint. The profile endpoint kept answering 200 the whole time.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes (server-only change)
  • I included a video for animation/interaction changes (n/a)

Verified with vp test run src/provider/Layers/claudeUsageLimits.test.ts (8 passed), lint on the two files, and the server typecheck.

Written by Claude Fable 5.1 via Claude Code in T3 Code.

🤖 Generated with Claude Code

Note

Classify failed Claude usage fetch as probeFailed to retain known limits

Adds a test case in claudeUsageLimits.test.ts for when rate_limits_available is true but rate_limits is null. The mapper must return no windows with an unavailable reason of probeFailed, so consumers can distinguish a failed usage probe from an unsupported account and keep previously known windows.

Macroscope summarized 6ad2140.

Summary by CodeRabbit

  • Bug Fixes
    • Improved usage-limit status reporting when rate-limit information cannot be fetched.
    • Distinguishes temporary fetch failures from unsupported rate-limit availability for more accurate status details.

Claude Code keeps `rate_limits_available` true and nulls `rate_limits` when its
usage fetch fails, e.g. when the endpoint answers 429. T3 mapped that to
`unsupported`, which hid the Claude card on Usage → Limits and made
/usage-limits claim the account has no subscription limits.

Report it as `probeFailed` instead, so the published snapshot keeps the last
good windows until the next successful probe.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Sep 7, 2026
@macroscopeapp

macroscopeapp Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 6ad2140

Macroscope's review found this PR approvable — This is a small, self-contained Claude usage-probe fix that preserves previously known limits only when a transient fetch fails, while leaving successful and unsupported responses unchanged. The new behavior is directly covered by a regression test.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: b6b6f473-9161-4068-93d4-d99de7b00330

📥 Commits

Reviewing files that changed from the base of the PR and between 83b865f and 1e3e06a.

📒 Files selected for processing (2)
  • apps/server/src/provider/Layers/claudeUsageLimits.test.ts
  • apps/server/src/provider/Layers/claudeUsageLimits.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/server/src/provider/Layers/claudeUsageLimits.test.ts
  • apps/server/src/provider/Layers/claudeUsageLimits.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The Claude usage response mapper now distinguishes failed usage probes from unsupported accounts. A test covers missing rate limit data when rate limits are reported as available.

Changes

Claude usage limit classification

Layer / File(s) Summary
Classify unavailable rate limits
apps/server/src/provider/Layers/claudeUsageLimits.ts, apps/server/src/provider/Layers/claudeUsageLimits.test.ts
The mapper returns probeFailed when rate_limits_available is true and rate_limits is null. It returns unsupported when availability is false. The test validates the failed-probe result.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 123f2

Claude usage probe failures are now distinguished from unsupported rate limits, preserving previously published limits until a successful probe. No current merge-blocking risk is identified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: preserving Claude usage limits when the usage fetch fails.
Description check ✅ Passed The description explains what changed, why the change is needed, the affected behavior, testing performed, and checklist status. It is focused and complete for a server-only change.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@cursor

cursor Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Bugbot is paused — on-demand spend limit reached

Bugbot uses usage-based billing for this team and has hit its on-demand spend limit.

A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant