Repository navigation
fix(claude): keep limits when the usage fetch fails - #10597
Mhmdhammoud wants to merge 10 commits into
Conversation
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>
ApprovabilityVerdict: Approved at 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. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe 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. ChangesClaude usage limit classification
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to 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)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
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 reachedBugbot 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. |
What Changed
claudeUsageResponseToLimitsnow distinguishes two shapes of the SDKget_usageresponse: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_availabletrue and nullsrate_limitswhen its own usage fetch fails, for example when/api/oauth/usageanswers 429. T3 treated that asunsupported, which hid the Claude card on Usage → Limits and made/usage-limitsreport "This account has no subscription limits." on an active Max account.probeFailedis the reason the publish path already handles:resolvePublishedUsageLimitskeeps 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
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
probeFailedto retain known limitsAdds a test case in claudeUsageLimits.test.ts for when
rate_limits_availableis true butrate_limitsis null. The mapper must return no windows with anunavailablereason ofprobeFailed, so consumers can distinguish a failed usage probe from an unsupported account and keep previously known windows.Macroscope summarized 6ad2140.
Summary by CodeRabbit