Repository navigation
feat(server): hub accounts show Claude banked resets - #26229
EhsanulHaqueSiam wants to merge 1 commit into
Conversation
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — Claude hub accounts now display banked resets and support the existing explicit Use reset action. Redemption remains user-triggered, with grant validation, retry deduplication, and reported cooldown-clear failures limiting operational risk. You can add or adjust custom eligibility rules. Learn more. |
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes.
|
| Layer / File(s) | Summary |
|---|---|
Read Claude reset credits apps/server/src/provider/claudeResetCredits.ts, apps/server/src/usage/cliproxyApi.ts, apps/server/src/usage/cliproxyApi.test.ts, docs/user/usage.md |
The Claude usage request uses a newer CLI user agent and requests reset-grant data. The reader maps available grant data into usage limits. Tests check the mapped credit and request parameter. The docs describe platform availability and hub reporting. |
Claim Claude reset credits apps/server/src/usage/cliproxyApi.ts, apps/server/src/usage/cliproxyApi.test.ts |
Consumption dispatches Claude accounts to grant claims and Codex accounts to credit redemption. Claude claims validate grant and organization data, submit an idempotent request, and map provider outcomes. Tests cover claim outcomes, repeated request data, and cooldown clearing for account "a". |
Priority:
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Feature
Sequence Diagram(s)
sequenceDiagram
participant Caller
participant consume
participant claimClaudeGrant
participant AnthropicAPI
Caller->>consume: Submit credit consumption for enabled Claude account
consume->>claimClaudeGrant: Pass Claude account and grant data
claimClaudeGrant->>AnthropicAPI: Submit reset claim with organization UUID and request ID
AnthropicAPI-->>claimClaudeGrant: Return claim response
claimClaudeGrant-->>consume: Return mapped claim outcome
consume-->>Caller: Return consumption result
Possibly related issues
Suggested reviewers: kanaliseren, juliusmarminge
Merge Risk: 
Minimal · previous review d1fdd
-
No confirmed issue remains that should block merging. Normal validation can proceed.
Pre-merge checks: 
4
-
Full details: Title check
-
Explanation
The title 'feat(server): hub accounts show Claude banked resets' follows conventional commit format and names the main change: hub-pooled Claude accounts now display banked reset credits. The changeset decodes the Claude reset-grant block from the usage response, requests it with a newer CLI user agent, and adds a Claude claim path for 'Use reset'. The title covers the primary display objective. It does not mention the claim path or the user agent change, but it does not need to cover every detail.
Full details: Description check
-
Explanation
The description follows the template's Problem, Change, Scope and approval, and Verification sections. It states the bug (hub Claude accounts never show banked reset credits), the root cause (old user agent
claude-code/2.1.273getsineligible_reason: "cli_version", and the usage request lacks the grant block), and the fix (new user agent pluscedar_ember=1, a Use reset claim path through/api/oauth/profileandreset_rate_limitswith a UUIDv5 request id, and a cooldown clear). It names the existing issue#10395as the prior context and explains why no new triaged issue exists. Verification lists the focused test file run with 15 passing tests, thevp run check:changedrun, a read-only live-hub check, and what was not checked. The Scope and approval section is a judgment call: it argues the change is a focused fix inside an established capability, but no maintainer approval comment is linked. The template asks for that explicitly, so the reviewer must decide whether the argument is enough.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
|
@coderabbitai review |
|
A CLIProxyAPI hub account for Claude never showed banked reset credits in Usage > Limits. The hub source only decoded the 5-hour, weekly and model windows, and Anthropic reports the reset-grant block only to requests that identify as a Claude CLI of version 2.1.280 or newer; the source sent an older, differently shaped user agent. Request the usage endpoint with the grant flag and a current CLI user agent, map the grant block with the existing direct-login reader, and let Use reset claim a grant through the hub the same way the CLI does, then clear the account's hub cooldown.
d1fdd18 to
dec16ab
Compare
Problem
A Claude account pooled through a CLIProxyAPI hub never shows its banked reset credits under Usage → Limits, although the same account shows them in the hub's own panel and the docs promise that "Codex and Claude accounts with banked reset credits show a ticket count and the Use reset action". The hub usage source only decoded the 5-hour, weekly and per-model windows, and the request it sent could not have received grants anyway: Anthropic reports the
cedar_embergrant block only to requests that identify as a Claude CLI of version 2.1.280 or newer. The source sentclaude-code/2.1.273, which the endpoint answers withineligible_reason: "cli_version"(any other user agent gets"surface").Change
/api/oauth/usage?cedar_ember=1&skip_spend=1withclaude-cli/2.1.312 (external, cli), and map the grant block with the existingclaudeResetCreditsToContractreader, so hub Claude accounts carryresetCreditslike hub Codex accounts do./api/oauth/profile, POSTreset_rate_limitswith a UUIDv5 request id (idempotent across retries and environments), map the result, then clear the account's hub cooldown. Without this, the credit would show but the existing action would fail for Claude hub accounts.Server only; the contracts, clients and the Use reset UI are unchanged.
Scope and approval
No triaged issue exists for this. It is a focused fix inside an established capability rather than a new feature: #10395 added hub reset credits ("CLIProxyAPI accounts could show usage windows without their banked reset credits") and the Use reset action for hub accounts, but only wired the Codex side, so hub Claude accounts stayed on the old behaviour the docs already said was fixed. The change reuses the native Claude reset reader and claim outcome mapping from
claudeResetCredits.ts, keeps redemption user-triggered through the existing action, and does not touch Codex accounts or the clients.Verification
vp test run apps/server/src/usage/cliproxyApi.test.ts: 15 tests pass, including the two new ones:claude-cli/user agent; asserts thecedar_ember=1request and the mappedresetCredits).resetthennot_limitedoutcomes, identical idempotent claim bodies, onereset-quotacall for that account).vp run check:changed: format, lint, knip, typecheck and tests pass.free_reset_oct_2026, 1 of 1, expires Dec 1). The usage endpoint rate limits after a dozen reads in a few minutes, so the live check is a single read.