fix(claude): keep limits when the usage fetch fails #10597
main fromrefs/pull/10597/head·opened View on GitHubWhat Changed#
claudeUsageResponseToLimits now distinguishes two shapes of the SDK get_usage response:
rate_limits_available: false→unsupported(API key, Bedrock, Vertex, missing scope), as before.rate_limits_available: truewithrate_limits: null→probeFailed, 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.
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.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
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 83b865fec704b177804aa6b9b695aefea4ccd04a and 1e3e06ab7e38edf5175e7b2cda885c70f04ffc4e.
📒 Files selected for processing (2)
apps/server/src/provider/Layers/claudeUsageLimits.test.tsapps/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.tsThe mapper returns probeFailedwhenrate_limits_availableis true andrate_limitsis null. It returnsunsupportedwhen availability is false. The test validates the failed-probe result.Estimated code review effort: 2 (Simple) | ~10 minutes
Merge Risk: ⚪ Minimal · up to
123f2Claude 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.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.
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.
Thanks for the PR. We're not taking changes to the orchestration and provider layers right now: that part of the server is being rewritten for V2, and merging into the current code would either conflict with or be thrown away by that work.
Closing for now. If this is still an issue once V2 lands, please reopen (or open a fresh PR against the new code) and we'll take a proper look.
juliusmarminge closed this
Sign in to join this conversation.
Approvability#
Verdict: Approved at
6ad2140Macroscope'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](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).