mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-15 04:27:20 +03:00
fix(core): stop retrying ChatGPT workspace usage limits (#62823)
This commit is contained in:
committed by
GitHub
Unverified
parent
fee1ca5aa9
commit
71f3696424
@@ -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",
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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"],
|
||||
|
||||
Reference in New Issue
Block a user