diff --git a/packages/core/src/plugin/provider/chatgpt.ts b/packages/core/src/plugin/provider/chatgpt.ts index 2e4a88fe4a9..a7738b86e5b 100644 --- a/packages/core/src/plugin/provider/chatgpt.ts +++ b/packages/core/src/plugin/provider/chatgpt.ts @@ -51,6 +51,7 @@ const fallbackModels = new Set([ ]) const nonRetryableSharingCodes = [ "subscription_sharing_usage_limit_exceeded", + "subscription_sharing_workplace_individual_usage_limit_exceeded", "subscription_sharing_user_not_eligible", "subscription_sharing_unsupported_capability", "subscription_sharing_route_not_supported", diff --git a/packages/core/src/session/to-session-error.ts b/packages/core/src/session/to-session-error.ts index 91c90545046..f2d86735287 100644 --- a/packages/core/src/session/to-session-error.ts +++ b/packages/core/src/session/to-session-error.ts @@ -13,6 +13,8 @@ const tokenSharingMessages = { "ChatGPT token sharing isn't available for this account. Connect with an API key or choose another provider.", subscription_sharing_usage_limit_exceeded: "ChatGPT usage limit reached. Check ChatGPT Settings → Usage for details.", + subscription_sharing_workplace_individual_usage_limit_exceeded: + "You've reached the usage limit your ChatGPT workspace admin set for you. Ask them to raise it in the OpenAI Admin Console.", subscription_sharing_usage_unavailable: "ChatGPT usage can't be checked right now. Try again later.", subscription_sharing_unsupported_capability: "This request uses a feature ChatGPT token sharing doesn't support. Remove the unsupported feature and try again.", diff --git a/packages/core/test/plugin/provider-chatgpt.test.ts b/packages/core/test/plugin/provider-chatgpt.test.ts index fe4bbdecff2..ae9391c7813 100644 --- a/packages/core/test/plugin/provider-chatgpt.test.ts +++ b/packages/core/test/plugin/provider-chatgpt.test.ts @@ -265,8 +265,12 @@ describe("ChatGPTPlugin", () => { }), ) - for (const source of ["http", "stream"] as const) { - it.effect(`stops retries for ChatGPT usage limits from ${source} failures`, () => + for (const [source, code] of [ + ["http", "subscription_sharing_usage_limit_exceeded"], + ["stream", "subscription_sharing_usage_limit_exceeded"], + ["http", "subscription_sharing_workplace_individual_usage_limit_exceeded"], + ] as const) { + it.effect(`stops retries for ${code} from ${source} failures`, () => Effect.gen(function* () { const credentials = yield* Credential.Service yield* credentials.create({ @@ -284,10 +288,10 @@ describe("ChatGPTPlugin", () => { const hooks = yield* PluginHooks.Service const body = source === "http" - ? JSON.stringify({ error: { code: "subscription_sharing_usage_limit_exceeded" } }) + ? JSON.stringify({ error: { code } }) : JSON.stringify({ type: "response.failed", - response: { error: { code: "subscription_sharing_usage_limit_exceeded" } }, + response: { error: { code } }, }) const cause = new AIError({ reason: new RateLimitError({ diff --git a/packages/core/test/session-error.test.ts b/packages/core/test/session-error.test.ts index 70a336adfd2..0c07cc20824 100644 --- a/packages/core/test/session-error.test.ts +++ b/packages/core/test/session-error.test.ts @@ -262,6 +262,7 @@ describe("toSessionError", () => { const cases = [ ["subscription_sharing_user_not_eligible", "token sharing isn't available for this account"], ["subscription_sharing_usage_limit_exceeded", "ChatGPT usage limit reached"], + ["subscription_sharing_workplace_individual_usage_limit_exceeded", "workspace admin"], ["subscription_sharing_usage_unavailable", "Try again later"], ["subscription_sharing_unsupported_capability", "Remove the unsupported feature"], ["subscription_sharing_route_not_supported", "Check the configured endpoint"],