Skip to content

Commit 38e53e6

Browse files
tan7virclaude
andcommitted
fix(usage): stop the hub claiming a Claude plan it cannot know
The hub's Anthropic OAuth usage read carries no subscription tier, but the adapter labelled every Claude account "Claude Subscription". Once the plan label is part of the pooled account identity, that placeholder can never match a native "Claude Max Subscription" and would split one subscription reported natively and by a hub into two accounts. The hub now omits the plan for Claude accounts, so its read merges with the native tier as before. The same-plan merge test uses a Codex pair, where both sides share codexPlanLabel, and a new test pins the native Claude tier plus tierless hub read case. Co-Authored-By: Claude Fable 5.1 <[email protected]>
1 parent 2d059ce commit 38e53e6

2 files changed

Lines changed: 52 additions & 4 deletions

File tree

‎apps/server/src/usage/cliproxyApi.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,11 @@ export const makeCliproxyApi = Effect.gen(function* () {
221221
]
222222
: [],
223223
);
224+
// The OAuth usage read carries no subscription tier, and the pooled
225+
// views treat a plan label as part of the account's identity, so the
226+
// hub claims none rather than a placeholder a native tier would not match.
224227
return {
225228
...base,
226-
plan: "Claude Subscription",
227229
usageLimits: claudeUsageResponseToLimits({
228230
checkedAt,
229231
response: {

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

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,10 +402,54 @@ describe("pools", () => {
402402
});
403403

404404
it("still merges same-email accounts when both sides report the same plan", () => {
405+
const native = provider({
406+
auth: {
407+
status: "authenticated",
408+
409+
label: "ChatGPT Plus Subscription",
410+
},
411+
usageLimits: { checkedAt, windows: [{ ...window, usedPercent: 40 }] },
412+
});
413+
const input = new Map([
414+
[
415+
EnvironmentId.make("env-a"),
416+
{
417+
...laptop,
418+
serverConfig: {
419+
providers: [native],
420+
usageLimitSources: [
421+
{
422+
...source,
423+
accounts: [
424+
{
425+
426+
driver: ProviderDriverKind.make("codex"),
427+
428+
plan: "ChatGPT Plus Subscription",
429+
usageLimits: {
430+
checkedAt: "2026-09-03T11:30:00.000Z",
431+
windows: [{ ...window, usedPercent: 55 }],
432+
},
433+
},
434+
],
435+
},
436+
],
437+
},
438+
},
439+
],
440+
]);
441+
expect(collectLimitAccounts(input)).toHaveLength(1);
442+
});
443+
444+
it("merges a native Claude tier with the hub's tierless read of the same account", () => {
405445
const native = provider({
406446
driver: claude,
407447
instanceId: ProviderInstanceId.make("claude"),
408-
auth: { status: "authenticated", email: "[email protected]", label: "Claude Subscription" },
448+
auth: {
449+
status: "authenticated",
450+
451+
label: "Claude Max Subscription",
452+
},
409453
usageLimits: { checkedAt, windows: [{ ...window, usedPercent: 40 }] },
410454
});
411455
const input = new Map([
@@ -423,7 +467,6 @@ describe("pools", () => {
423467
424468
driver: claude,
425469
426-
plan: "Claude Subscription",
427470
usageLimits: {
428471
checkedAt: "2026-09-03T11:30:00.000Z",
429472
windows: [{ ...window, usedPercent: 55 }],
@@ -436,7 +479,10 @@ describe("pools", () => {
436479
},
437480
],
438481
]);
439-
expect(collectLimitAccounts(input)).toHaveLength(1);
482+
const accounts = collectLimitAccounts(input);
483+
expect(accounts).toHaveLength(1);
484+
expect(accounts[0]?.plan).toBe("Claude Max Subscription");
485+
expect(accounts[0]?.limits.windows[0]?.usedPercent).toBe(55);
440486
});
441487

442488
it("keeps same-email Codex instances apart when their plans differ", () => {

0 commit comments

Comments
 (0)