From 7790e984191505e7999c01f70a40408cbf446cd9 Mon Sep 17 00:00:00 2001 From: MaxFabian25 <216908004+MaxFabian25@users.noreply.github.com> Date: Mon, 16 Nov 2026 17:10:36 +0100 Subject: [PATCH 1/3] test(server): reproduce lost gateway cooldown after last error --- .../Adapters/ClaudeAdapterV2.test.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts index 1d549d7f2c18b..6f17d166971c5 100644 --- a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts +++ b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts @@ -9472,6 +9472,24 @@ 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: rate_limit_error (reset after 1h))", + seconds: 0, + }, + { + cooldown: " (last error: upstream (last error: rate limited) (reset after 1h))", + seconds: 0, + }, { cooldown: "", seconds: 0 }, ])("keeps a gateway's reset on a direct 429 with cooldown '$cooldown'", (input) => Effect.gen(function* () { From 907988ef40e3386ff3656eb13a17142257f24676 Mon Sep 17 00:00:00 2001 From: MaxFabian25 <216908004+MaxFabian25@users.noreply.github.com> Date: Mon, 16 Nov 2026 17:27:37 +0100 Subject: [PATCH 2/3] fix(server): recover gateway cooldown after last error --- .../Adapters/ClaudeAdapterV2.test.ts | 4 ++++ .../src/orchestration-v2/Adapters/ClaudeAdapterV2.ts | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts index 6f17d166971c5..a923939ee6a47 100644 --- a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts +++ b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts @@ -9490,6 +9490,10 @@ describe("ClaudeAdapterV2 background wake turns", () => { cooldown: " (last error: upstream (last error: rate limited) (reset after 1h))", seconds: 0, }, + { + 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; From 22f969dae406f4162455dbe5a2a0b47bf0f52954 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Mon, 16 Nov 2026 16:46:54 +0000 Subject: [PATCH 3/3] test(server): drop gateway cooldown rows the other cases already cover Co-Authored-By: Claude Opus 5.5 --- .../src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts index a923939ee6a47..cf533de93e4d6 100644 --- a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts +++ b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts @@ -9482,14 +9482,6 @@ describe("ClaudeAdapterV2 background wake turns", () => { " (last error: All credentials for model upstream are cooling down (reset after 1h)) (reset after 1m)", seconds: 60, }, - { - cooldown: " (last error: rate_limit_error (reset after 1h))", - seconds: 0, - }, - { - cooldown: " (last error: upstream (last error: rate limited) (reset after 1h))", - seconds: 0, - }, { cooldown: " (last error: Request rejected (429) (reset after 1h) (last error: rate limited))", seconds: 0,