diff --git a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts index 1d549d7f2c18b..cf533de93e4d6 100644 --- a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts +++ b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts @@ -9472,6 +9472,20 @@ describe("ClaudeAdapterV2 background wake turns", () => { it.effect.each([ { cooldown: " (reset after 1h2m3s)", seconds: 3723 }, { cooldown: " (reset after 4m 6s) (last error: rate limited)", seconds: 246 }, + { + cooldown: + " (last error: rate_limit_error: This request would exceed your account's rate limit. Please try again later.) (reset after 19h30m2s)", + seconds: 70202, + }, + { + cooldown: + " (last error: All credentials for model upstream are cooling down (reset after 1h)) (reset after 1m)", + seconds: 60, + }, + { + cooldown: " (last error: Request rejected (429) (reset after 1h) (last error: rate limited))", + seconds: 0, + }, { cooldown: "", seconds: 0 }, ])("keeps a gateway's reset on a direct 429 with cooldown '$cooldown'", (input) => Effect.gen(function* () { diff --git a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts index 5dcb77f7abddc..fa8d3684f0f23 100644 --- a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts +++ b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts @@ -4769,12 +4769,16 @@ function providerFailureFromResult( apiErrorStatus === 429 && message.result.startsWith("API Error:") ? gatewayCooldownResetAt( // CLIProxyAPI nests upstream errors in its message; only its own cooldown counts. - (message.result.startsWith( + message.result.startsWith( "API Error: Request rejected (429) · All credentials for model ", ) - ? /^API Error: Request rejected \(429\) · All credentials for model [^\s()]+ are cooling down \(reset after (?:(\d+)h ?)?(?:(\d+)m ?)?(?:(\d+)s)?\)/ - : /\(reset after (?:(\d+)h ?)?(?:(\d+)m ?)?(?:(\d+)s)?\)/ - ).exec(message.result), + ? (/^API Error: Request rejected \(429\) · All credentials for model [^\s()]+ are cooling down \(reset after (?:(\d+)h ?)?(?:(\d+)m ?)?(?:(\d+)s)?\)/.exec( + message.result, + ) ?? + /^API Error: Request rejected \(429\) · All credentials for model [^\s()]+ are cooling down \(last error: [\s\S]*\) \(reset after (?:(\d+)h ?)?(?:(\d+)m ?)?(?:(\d+)s)?\)$/.exec( + message.result, + )) + : /\(reset after (?:(\d+)h ?)?(?:(\d+)m ?)?(?:(\d+)s)?\)/.exec(message.result), receivedAt, ) : undefined;