Skip to content

feat(server): hub accounts show Claude banked resets - #26229

Open
EhsanulHaqueSiam wants to merge 1 commit into
pingdotgg:mainfrom
EhsanulHaqueSiam:feat/hub-claude-reset-credits
Open

EhsanulHaqueSiam wants to merge 1 commit into
pingdotgg:mainfrom
EhsanulHaqueSiam:feat/hub-claude-reset-credits

Conversation

@EhsanulHaqueSiam

@EhsanulHaqueSiam EhsanulHaqueSiam commented Oct 28, 2026 •

Copy link
Copy Markdown

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_ember grant block only to requests that identify as a Claude CLI of version 2.1.280 or newer. The source sent claude-code/2.1.273, which the endpoint answers with ineligible_reason: "cli_version" (any other user agent gets "surface").

Change

  • Request /api/oauth/usage?cedar_ember=1&skip_spend=1 with claude-cli/2.1.312 (external, cli), and map the grant block with the existing claudeResetCreditsToContract reader, so hub Claude accounts carry resetCredits like hub Codex accounts do.
  • Use reset on a hub Claude account claims the grant through the hub the way the CLI does: read the organization from /api/oauth/profile, POST reset_rate_limits with 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.
  • Docs: hub section and the macOS note.

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:
    • "maps Claude scoped windows and banked resets without a scheduler plugin" (the stub answers only a claude-cli/ user agent; asserts the cedar_ember=1 request and the mapped resetCredits).
    • "claims a Claude grant through the hub and clears only that account's cooldown" (profile → organization, reset then not_limited outcomes, identical idempotent claim bodies, one reset-quota call for that account).
  • vp run check:changed: format, lint, knip, typecheck and tests pass.
  • Live hub, read only: with the old user agent the account came back with windows only; with the new one it also returns the grant (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.
  • Not checked: claiming a grant against the live endpoint, to avoid spending a real reset. The claim path is covered by the stubbed test.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Oct 28, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at d1fdd18

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.

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration
Commits

Reviewing files that changed from the base of the PR and between d1fdd18 and dec16ab.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 68495b6 and d1fdd18.

Files selected for processing: 4
  • apps/server/src/provider/claudeResetCredits.ts
  • apps/server/src/usage/cliproxyApi.test.ts
  • apps/server/src/usage/cliproxyApi.ts
  • docs/user/usage.md

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

Walkthrough

Claude usage responses can now include reset-credit data. Credit consumption supports Claude grant claims as well as Codex credit redemption. The usage documentation describes Claude reset availability by server platform.

Changes: Claude reset credits

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: Normal

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
Loading

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: Passed 4
Check name Status Explanation
Title check Passed 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 changese…
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.
Description check Passed 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…
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.273 gets ineligible_reason: "cli_version", and the usage request lacks the grant block), and the fix (new user agent plus cedar_ember=1, a Use reset claim path through /api/oauth/profile and reset_rate_limits with a UUIDv5 request id, and a cooldown clear). It names the existing issue #10395 as the prior context and explains why no new triaged issue exists. Verification lists the focused test file run with 15 passing tests, the vp run check:changed run, 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.

@EhsanulHaqueSiam

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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.

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

size:L 100-499 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.

1 participant