Skip to content

Commit 3d5a374

Browse files
Luzivogclaude
andcommitted
fix(server): hide ChatGPT limits when Codex uses a custom provider
When Codex runs with a custom `model_provider`, `account/read` reports no account, but `account/rateLimits/read` still answers from the ChatGPT login saved in the Codex home. T3 showed those limits as this instance's, with no email, so the Limits page listed the same ChatGPT account twice next to a CLIProxy source that pools it. Report Codex usage limits as unsupported unless the account is a ChatGPT login, extending the existing API key case. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent d15210c commit 3d5a374

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

‎apps/server/src/provider/Layers/CodexProvider.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,8 +655,12 @@ export const checkCodexProviderStatus = Effect.fn("checkCodexProviderStatus")(fu
655655

656656
const snapshot = probeResult.success.value;
657657
const accountStatus = accountProbeStatus(snapshot.account);
658+
// Plan limits only exist for a ChatGPT login. Without one (API key, Bedrock,
659+
// or a custom `model_provider`, which reports no account), Codex can still
660+
// answer the usage read from a ChatGPT login saved in its home, which this
661+
// instance's turns don't draw on.
658662
const usageLimits =
659-
snapshot.account.account?.type === "apiKey"
663+
snapshot.account.account?.type !== "chatgpt"
660664
? makeUnavailableUsageLimits({ checkedAt, reason: "unsupported" })
661665
: snapshot.rateLimits === undefined || "failure" in snapshot.rateLimits
662666
? makeUnavailableUsageLimits({

‎apps/server/src/provider/Layers/ProviderRegistry.test.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,34 @@ it.layer(Layer.mergeAll(NodeServices.layer, ServerSettingsModule.layerTest(), Te
481481
}),
482482
);
483483

484+
it.effect("does not report ChatGPT usage limits for a custom model provider", () =>
485+
Effect.gen(function* () {
486+
// A custom `model_provider` has no account, but Codex still answers
487+
// the usage read from the ChatGPT login saved in its home.
488+
const status = yield* checkCodexProviderStatus(defaultCodexSettings, () =>
489+
Effect.succeed(
490+
makeCodexProbeSnapshot({
491+
account: { account: null, requiresOpenaiAuth: false },
492+
rateLimits: {
493+
snapshot: {
494+
limitId: "codex",
495+
primary: {
496+
usedPercent: 14,
497+
windowDurationMins: 10_080,
498+
resetsAt: 1_791_049_011,
499+
},
500+
},
501+
resetCredits: { availableCount: 1 },
502+
},
503+
}),
504+
),
505+
);
506+
507+
assert.deepStrictEqual(status.usageLimits?.windows, []);
508+
assert.strictEqual(status.usageLimits?.unavailable?.reason, "unsupported");
509+
}),
510+
);
511+
484512
it.effect("returns an api key label for codex api key auth", () =>
485513
Effect.gen(function* () {
486514
const status = yield* checkCodexProviderStatus(defaultCodexSettings, () =>

0 commit comments

Comments
 (0)