Skip to content

Commit a7598ad

Browse files
committed
fix: skip Codex usage without an account
- custom model providers run with no account, so account/rateLimits/read always fails with -32600 - report usage as unsupported instead of a probe error
1 parent df26ef9 commit a7598ad

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,8 @@ export const checkCodexProviderStatus = Effect.fn("checkCodexProviderStatus")(fu
740740
? { status: "ready" as const, auth: managedAuth, message: undefined }
741741
: accountProbeStatus(snapshot);
742742
const usageLimits =
743-
snapshot.account.account?.type === "apiKey"
743+
// Only a ChatGPT login has quotas; a custom model provider runs with no account.
744+
!snapshot.account.account || snapshot.account.account.type === "apiKey"
744745
? makeUnavailableUsageLimits({ checkedAt, reason: "unsupported" })
745746
: snapshot.rateLimits === undefined || "failure" in snapshot.rateLimits
746747
? makeUnavailableUsageLimits({

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,22 @@ it.layer(
547547
}),
548548
);
549549

550+
it.effect("marks usage unsupported when a custom provider runs without an account", () =>
551+
Effect.gen(function* () {
552+
const status = yield* checkCodexProviderStatus(defaultCodexSettings, () =>
553+
Effect.succeed(
554+
makeCodexProbeSnapshot({
555+
account: { account: null, requiresOpenaiAuth: false },
556+
rateLimits: { failure: "Codex could not read usage (JSON-RPC -32600)." },
557+
}),
558+
),
559+
);
560+
561+
assert.strictEqual(status.status, "ready");
562+
assert.deepStrictEqual(status.usageLimits?.unavailable, { reason: "unsupported" });
563+
}),
564+
);
565+
550566
it.effect("returns an Amazon Bedrock label for codex Bedrock auth", () =>
551567
Effect.gen(function* () {
552568
const status = yield* checkCodexProviderStatus(defaultCodexSettings, () =>

0 commit comments

Comments
 (0)