From 3ea2d2a928ea8bce3de0c2212cca1160a65567d0 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Sat, 2 May 2026 05:35:55 -0400 Subject: [PATCH] fix(failover): improve internal server error classification (#73844) * fix(failover): improve internal server error classification * fix: cover bare internal server status --------- Co-authored-by: Altay --- CHANGELOG.md | 1 + .../pi-embedded-helpers/failover-matches.test.ts | 11 +++++++++++ src/agents/pi-embedded-helpers/failover-matches.ts | 5 ++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c937c8d44c..deee70e2e16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -213,6 +213,7 @@ Docs: https://docs.openclaw.ai - Gateway/config: log config health-state write failures instead of silently hiding config observe-recovery write errors. Thanks @sallyom. - Diagnostics: reset stuck-session timers on reply, tool, status, block, and ACP progress events, and back off repeated `session.stuck` diagnostics while a session remains unchanged. Supersedes #72010. Thanks @rubencu. - Gateway/agents: avoid rebuilding core tools for plugin-only allowlists and keep the full plugin registry cache warm across scoped plugin loads, reducing per-turn latency spikes. Fixes #75882, #75907, #75906, #75887, and #75851. (#75922) Thanks @obviyus. +- Agents/failover: classify bare `status: internal server error` provider messages as retryable server errors so model fallback can rotate instead of stopping. (#73844) Thanks @thesomewhatyou. ## 2026.4.30 diff --git a/src/agents/pi-embedded-helpers/failover-matches.test.ts b/src/agents/pi-embedded-helpers/failover-matches.test.ts index c60de3e0494..0e1a022ca93 100644 --- a/src/agents/pi-embedded-helpers/failover-matches.test.ts +++ b/src/agents/pi-embedded-helpers/failover-matches.test.ts @@ -4,6 +4,7 @@ import { isBillingErrorMessage, isOverloadedErrorMessage, isRateLimitErrorMessage, + isServerErrorMessage, } from "./failover-matches.js"; describe("Z.ai vendor error codes (#48988)", () => { @@ -92,3 +93,13 @@ describe("Z.ai vendor error codes (#48988)", () => { }); }); }); + +describe("server error status classification", () => { + it("classifies a bare internal server error status as server error", () => { + expect(isServerErrorMessage("status: internal server error")).toBe(true); + }); + + it("does not classify prefixed plain internal server error status prose", () => { + expect(isServerErrorMessage("Proxy notice: Status: Internal Server Error")).toBe(false); + }); +}); diff --git a/src/agents/pi-embedded-helpers/failover-matches.ts b/src/agents/pi-embedded-helpers/failover-matches.ts index 63a67110313..3a023d5ac55 100644 --- a/src/agents/pi-embedded-helpers/failover-matches.ts +++ b/src/agents/pi-embedded-helpers/failover-matches.ts @@ -309,5 +309,8 @@ export function isServerErrorMessage(raw: string): boolean { return true; } const scrubbed = value.replace(STATUS_INTERNAL_SERVER_ERROR_RE, "").trim(); - return scrubbed.length > 0 && matchesErrorPatterns(scrubbed, ERROR_PATTERNS.serverError); + if (scrubbed === "") { + return true; + } + return matchesErrorPatterns(scrubbed, ERROR_PATTERNS.serverError); }