Skip to content
Source
Sign inSign up
pingdotgg/t3code

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

ClosedMhmdhammoud(GitHub profile, opens in a new tab)wants to merge 10 commits intomain fromrefs/pull/10597/headopened View on GitHub

What 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: true with rate_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.

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.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    2. 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](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      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 83b865fec704b177804aa6b9b695aefea4ccd04a and 1e3e06ab7e38edf5175e7b2cda885c70f04ffc4e.

      📒 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 nameStatusExplanation
      Title check✅ PassedThe title clearly describes the main change: preserving Claude usage limits when the usage fetch fails.
      Description check✅ PassedThe 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✅ PassedDocstring 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✅ PassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes check✅ PassedCheck 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.
    4. 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.

    5. 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.

    6. 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.

    7. juliusmarminge closed this

Sign in to join this conversation.