Skip to content

fix(shared): a model-scoped Claude limit no longer blocks other Claude models - #32016

Open
na-zar wants to merge 3 commits into
pingdotgg:mainfrom
na-zar:fix/claude-model-scoped-limit
Open

na-zar wants to merge 3 commits into
pingdotgg:mainfrom
na-zar:fix/claude-model-scoped-limit

Conversation

@na-zar

@na-zar na-zar commented Nov 6, 2026

Copy link
Copy Markdown

Problem

When Claude's model-scoped weekly bucket is used up (Weekly · Fable, window id seven_day_fable), T3 Code treats every Claude model as out of usage. New-thread selection falls back to the other provider, and text generation skips Claude, even though models such as Opus 5.5 still work. Reproduction details: #32015.

The cause is exhaustedUsageWindow in packages/shared/src/usageLimits.ts. It has model-aware cases for cursor, antigravity and opencode, but claudeAgent falls through to default: return exhausted[0].

Change

Add a claudeAgent case. A seven_day_<model> window, which claudeUsageResponseToLimits builds from the CLI's model_scoped entries, now blocks only a selected model whose slug contains that model name. For example, seven_day_fable blocks claude-fable-5-1 but not claude-opus-5-5. Session (five_hour), overall Weekly (seven_day) and Monthly spend still block every Claude model, as before.

Scope and approval

Fixes #32015. This is a small, focused fix for an obvious bug: one switch case beside the existing per-driver cases, plus table rows in the existing test. It changes no contracts or UI.

Verification

  • Added four claudeAgent rows to the existing "matches %s pools %s to %s" table in packages/shared/src/usageLimits.test.ts:
    • Fable bucket at 100% with Opus selected: Opus stays selected.
    • Fable bucket at 100% with Fable selected: falls back.
    • Overall seven_day at 100% with Opus selected: falls back.
    • five_hour at 100% with Opus selected: falls back.
  • vp test run packages/shared/src/usageLimits.test.ts: 66 passed. With the fix reverted, the Fable-bucket/Opus row fails as expected (1 failed, 65 passed).
  • vp check on both files and vp run typecheck in packages/shared both pass.
  • Not checked: the running app against a live account whose Fable limit is used up.

Written with Claude Opus 5.5 in Claude Code.

🤖 Generated with Claude Code

…e models

A used-up "Weekly · Fable" bucket (seven_day_fable) made exhaustedUsageWindow
treat every Claude model as out of usage, because claudeAgent fell through to
the default case. Match seven_day_<model> windows to the selected model, as
the cursor, antigravity and opencode cases already do.

Fixes pingdotgg#32015

Co-Authored-By: Claude Opus 5.5 <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 Nov 6, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at b41ef48

Macroscope's review found this PR approvable — Claude model-specific weekly limits now affect only the matching model, preventing unnecessary fallback for other Claude models. Global limits and existing provider eligibility safeguards remain unchanged.

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

@coderabbitai

coderabbitai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Claude Agent fallback selection now filters model-scoped weekly usage windows by the requested model. Tests cover Fable and Opus cases, including a general weekly window combined with a Fable-scoped window.

Changes: Claude usage fallback

Layer / File(s) Summary
Filter exhausted windows by model
packages/shared/src/usageLimits.ts, packages/shared/src/usageLimits.test.ts
exhaustedUsageWindow matches a scoped weekly window only when its scope appears in the normalized model name. Tests verify fallback selection for Fable and Opus models.

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

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: juliusmarminge

Merge Risk: Minimal · up to 75f17

The model-specific fallback change is mergeable after normal checks. The supplied cases show an exhausted Fable limit leaves Opus available, while an overall weekly limit still applies.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: model-scoped Claude limits no longer block other Claude models. It uses an appropriate conventional commit format.
Description check Passed The description includes all required sections: Problem, Change, Scope and approval, and Verification. It explains the affected behavior, implementation, linked issue, focused tests, observed results,…
Linked Issues check Passed [#32015] exhaustedUsageWindow now handles claudeAgent. It normalizes the selected model and applies an exhausted seven_day_<scope> window only when the model slug contains <scope>. Unscoped `s…
Out of Scope Changes check Passed The pull request changes only the shared Claude usage-window matching logic and its existing fallback test table. These changes directly support [#32015]. No unrelated contract, UI, or provider behavi…
Full details: Description check

Explanation

The description includes all required sections: Problem, Change, Scope and approval, and Verification. It explains the affected behavior, implementation, linked issue, focused tests, observed results, and the remaining live-account test limitation.

Full details: Linked Issues check

Explanation

[#32015] exhaustedUsageWindow now handles claudeAgent. It normalizes the selected model and applies an exhausted seven_day_&lt;scope&gt; window only when the model slug contains &lt;scope&gt;. Unscoped seven_day, five_hour, and other windows still apply to all Claude models. The added table rows cover the Fable and Opus cases and the overall weekly case. The shared function serves both new-thread fallback and server model-selection callers.

Full details: Out of Scope Changes check

Explanation

The pull request changes only the shared Claude usage-window matching logic and its existing fallback test table. These changes directly support [#32015]. No unrelated contract, UI, or provider behavior changes appear in the reviewed diff.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between b41ef48 and 75f1786.

Files selected for processing: 2

  • packages/shared/src/usageLimits.test.ts
  • packages/shared/src/usageLimits.ts

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

@juliusmarminge juliusmarminge added bugfix Fix PR opened by an issue lead; enters the PR loop pr:gate-failed A land gate failed labels Nov 6, 2026
@saviocmc

saviocmc commented Nov 7, 2026

Copy link
Copy Markdown

Note

Written by Claude Opus 5.5 in Claude Code, on behalf of saviocmc.

This is the same fix as #28676, opened on Nov 1: the same claudeAgent case in exhaustedUsageWindow, with only a code comment added here. I'm not the author of either PR. I hit this bug and tested the fix.

Both PRs list a live check against an account with a spent Fable limit as not done. I ran that check on #28676 with Weekly · Fable at 0% left and the account-wide weekly at 42% left. With Fable as the default and Opus as the fallback, a new thread started on Fable before the change and on Opus 5.5 after it, with the fallback notice. Since the logic is identical, the same result applies here. Details and screenshots: #28676 (comment)

Copy link
Copy Markdown
Member

The automated pipeline stopped on this pull request and will not merge it:

the proof has no capture anyone can open:

  • Permanent blocker: first-party Claude OAuth usage, limit, and renewal flows are unavailable on this VM, as specified in the brief.
  • Unnecessary fallback for an unaffected Claude default remains unverified on both commits.
  • Fallback for the exhausted-model control and eligibility during text generation remain unverified.
  • No captures or public upload URLs exist; ghdrop upload was not attempted because no evidence was captured.

It stays open for a person to finish or close.

@saviocmc

Copy link
Copy Markdown

Note

Written by Claude Opus 5.5 in Claude Code, on behalf of saviocmc.

The pipeline stopped this PR because it found no capture it could open. These are the captures from my live test, embedded here directly. To be clear about what they show:

  • What ran: a dev build of fix(shared): Claude falls back to another model when only one model's weekly limit is spent #28676 at 89eaad0, based on 2b1021c. It is not a run of this PR's head. Its claudeAgent case in exhaustedUsageWindow is identical to this PR's at 75f1786, apart from the code comment. Between the two commits, resolveNewThreadModelSelection and claudeUsageLimits.ts are unchanged.
  • Account: one Claude login, with Weekly · Fable at 0% left and the account-wide Weekly at 42% left.
  • Case covered: the exhausted-model control. Default Fable 5.1, fallback Opus 5.5, both on the same Claude instance. I opened a new thread draft and sent no turn.
  • Not covered: an unaffected Claude default (Opus as the default staying on Opus while Fable is spent), and text generation.

Before the fix, with usageLimits.ts reverted to 2b1021c, the draft starts on Fable 5.1 with no fallback notice:

Before the fix: new thread on Fable 5.1

With the fix, the draft starts on Opus 5.5 with "Using Claude Opus 5.5 · Claude is out of usage":

With the fix: new thread on Opus 5.5

The account's limits on the same dev server:

Usage limits: Weekly 42% left, Weekly Fable 0% left

This branch has not been deployed

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

Labels

bugfix Fix PR opened by an issue lead; enters the PR loop pr:gate-failed A land gate failed 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.

[Bug]: Exhausted Fable weekly limit marks all Claude models as out of usage

3 participants