Repository navigation
fix(server): scope Claude hub usage to its organization - #26634
HelpsHelps2 wants to merge 1 commit into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — Claude hub usage now includes the account's organization identifier so usage can be scoped appropriately. The additional read-only profile request uses existing timeout and unavailable-usage handling, without changing permissions or charges. You can add or adjust custom eligibility rules. Learn more. |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Profile contract apps/server/src/usage/cliproxyApi.ts |
A Claude profile schema and decoder require an organization UUID that is a trimmed, non-empty string. |
Profile lookup and workspace identity apps/server/src/usage/cliproxyApi.ts, apps/server/src/usage/cliproxyApi.test.ts |
Claude account reads fetch and decode the profile before requesting usage. The result uses the profile organization UUID as its workspace ID. Tests cover distinct organizations and profile failures; the account fixture allows an omitted id_token. |
Priority:
Estimated code review effort: 2 (Simple) | ~12 minutes
Change: Bug fix
Sequence Diagram(s)
sequenceDiagram
participant ClaudeAccountRead
participant OAuthProfileEndpoint
participant ProfileDecoder
participant ClaudeUsageEndpoint
ClaudeAccountRead->>OAuthProfileEndpoint: Fetch OAuth profile
OAuthProfileEndpoint-->>ClaudeAccountRead: Profile JSON
ClaudeAccountRead->>ProfileDecoder: Decode profile JSON
ProfileDecoder-->>ClaudeAccountRead: Organization UUID
ClaudeAccountRead->>ClaudeUsageEndpoint: Request usage
Possibly related issues
pingdotgg/t3code#23054— The issue concerns pooled-limit identity merging for Codex accounts. This change supplies Claude organization UUIDs as workspace identity, but does not address Codex identity resolution.
Possibly related PRs
- pingdotgg/t3code#25480 — Both changes modify Claude usage reads through CLIProxyAPI.
- pingdotgg/t3code#26229 — Both changes use Claude CLIProxyAPI profile and usage data.
- pingdotgg/t3code#23781 — Both changes affect CLIProxyAPI usage-pool identity resolution.
Suggested labels: size:M
Suggested reviewers: juliusmarminge, maria-rcks
Merge Risk: 
Minimal · up to 194f7
-
Claude hub usage is scoped by organization. No merge-blocking issue was identified.
Pre-merge checks: 
4
-
Full details: Description check
-
Explanation
The description covers the problem, implementation, scope justification, focused verification, observed results, limitations, and agent details. It is complete and directly aligned with the requested fix.
-
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.
Problem
Usage → Limits can merge a Claude Team subscription reported by CLIProxyAPI into a personal Max subscription with the same email. With the direct business provider disabled or removed, the business entry disappears and the Max entry can display the business quota instead.
The native Claude provider reports its organization as
auth.workspaceId. The hub adapter currently reports a workspace only for Codex. The shared account resolver therefore assigns an unscoped Claude hub report to the only enabled native workspace for that email, even when it is a different subscription.Change
Read
/api/oauth/profilethrough the existing hubapi-callendpoint using the same selected credential as the usage request. Publishorganization.uuidas the Claude hub account's existingworkspaceIdfield. The existing shared merger can then keep personal and business quotas separate and deduplicate a native/hub pair for the same organization.A failed profile request or missing/blank organization ID produces the existing unavailable-account state instead of publishing quota under an ambiguous identity. Codex reporting and request routing are unchanged. No new contract fields, settings, or client-specific changes are needed; all clients consume the corrected hub snapshot.
This adds one profile request per Claude account during a hub quota read. It does not download credential files or expose profile bodies in errors.
Scope and approval
This is a small, focused fix for an obvious identity mismatch in the existing Claude hub reporting capability, under the exception in CONTRIBUTING.md. It fills an existing workspace identity field; it does not add account switching, a new integration, or a new product behavior. One existing adapter test is extended for same-email subscriptions, with a failure table for unavailable organization identity.
Verification
workspaceId, and failed/malformed profile responses still allowed ambiguous usage to be published.vp test run apps/server/src/usage/cliproxyApi.test.ts packages/shared/src/usageLimits.test.ts— 55 tests passed. These cover hub organization reporting and the existing shared logic for keeping workspaces separate and merging duplicates.vp run check:changed— format, lint, both knip passes, generated GraphQL checks, typechecks for the three affected packages, and all 17 hub-adapter tests passed.0.1.4-nightly.20261028.3824, and CLIProxyAPI8.0.45:/auth-filesomitted the Claude organization ID;/api/oauth/profilereturned HTTP 200 and its organization UUID matched the business credential. The installed account resolver reproduced the personal/business merge with the native business provider disabled, and separate identities when the hub report carried the business organization ID.Written with GPT-6.1 Sol in the Codex harness, running through T3 Code.