@devries-cameron20 / t3code-1 / commits / c8c51af4e3
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(server): recover gateway cooldown after last error (#37692)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Maximilian Fabian Kirchner committed Nov 16, 2026 at 18:08 UTC c8c51af4e3f67ec9d121b3fb10b4cfd17adfd541
2 files changed +22 -4
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
+14
@@ -9472,6 +9472,20 @@ describe("ClaudeAdapterV2 background wake turns", () => {
9472 it.effect.each([
9473 { cooldown: " (reset after 1h2m3s)", seconds: 3723 },
9474 { cooldown: " (reset after 4m 6s) (last error: rate limited)", seconds: 246 },
9475 + {
9476 + cooldown:
9477 + " (last error: rate_limit_error: This request would exceed your account's rate limit. Please try again later.) (reset after 19h30m2s)",
9478 + seconds: 70202,
9479 + },
9480 + {
9481 + cooldown:
9482 + " (last error: All credentials for model upstream are cooling down (reset after 1h)) (reset after 1m)",
9483 + seconds: 60,
9484 + },
9485 + {
9486 + cooldown: " (last error: Request rejected (429) (reset after 1h) (last error: rate limited))",
9487 + seconds: 0,
9488 + },
9489 { cooldown: "", seconds: 0 },
9490 ])("keeps a gateway's reset on a direct 429 with cooldown '$cooldown'", (input) =>
9491 Effect.gen(function* () {
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
+8 -4
@@ -4769,12 +4769,16 @@ function providerFailureFromResult(
4769 apiErrorStatus === 429 && message.result.startsWith("API Error:")
4770 ? gatewayCooldownResetAt(
4771 // CLIProxyAPI nests upstream errors in its message; only its own cooldown counts.
4772 - (message.result.startsWith(
4772 + message.result.startsWith(
4773 "API Error: Request rejected (429) · All credentials for model ",
4774 )
4775 - ? /^API Error: Request rejected \(429\) · All credentials for model [^\s()]+ are cooling down \(reset after (?:(\d+)h ?)?(?:(\d+)m ?)?(?:(\d+)s)?\)/
4776 - : /\(reset after (?:(\d+)h ?)?(?:(\d+)m ?)?(?:(\d+)s)?\)/
4777 - ).exec(message.result),
4775 + ? (/^API Error: Request rejected \(429\) · All credentials for model [^\s()]+ are cooling down \(reset after (?:(\d+)h ?)?(?:(\d+)m ?)?(?:(\d+)s)?\)/.exec(
4776 + message.result,
4777 + ) ??
4778 + /^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(
4779 + message.result,
4780 + ))
4781 + : /\(reset after (?:(\d+)h ?)?(?:(\d+)m ?)?(?:(\d+)s)?\)/.exec(message.result),
4782 receivedAt,
4783 )
4784 : undefined;