Skip to content

Commit b5b4a9b

Browse files
committed
fix(failover): share transient network code policy
Signed-off-by: sallyom <[email protected]>
1 parent 0934155 commit b5b4a9b

2 files changed

Lines changed: 7 additions & 18 deletions

File tree

‎src/agents/embedded-agent-helpers/assistant-message-failures.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ describe("classifyAssistantFailoverReason", () => {
2626
});
2727

2828
it.each([
29+
"ENOTFOUND",
2930
"UND_ERR_CONNECT_TIMEOUT",
3031
"UND_ERR_DNS_RESOLVE_FAILED",
3132
"UND_ERR_CONNECT",

‎src/agents/failover/classification-rules.ts‎

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { normalizeOptionalLowercaseString } from "@openclaw/normalization-core/string-coerce";
2+
import { isTransientNetworkError } from "../../infra/retryable-network-errors.js";
23
import {
34
extractLeadingHttpStatus,
45
parseApiErrorInfo,
@@ -9,26 +10,10 @@ import {
910
isRateLimitErrorMessage,
1011
} from "./message-patterns.js";
1112
import type { FailoverClassification, FailoverReason, FailoverSignal } from "./signal.js";
12-
const TIMEOUT_ERROR_CODES = new Set([
13-
"ETIMEDOUT",
14-
"ESOCKETTIMEDOUT",
15-
"ECONNRESET",
16-
"ECONNABORTED",
17-
"ECONNREFUSED",
18-
"ENETUNREACH",
19-
"EHOSTUNREACH",
13+
const FAILOVER_TIMEOUT_ERROR_CODES = new Set([
2014
"EHOSTDOWN",
2115
"ENETRESET",
22-
"EPIPE",
23-
"EAI_AGAIN",
2416
"ERR_STREAM_PREMATURE_CLOSE",
25-
// Keep these aligned with src/infra/retryable-network-errors.ts.
26-
"UND_ERR_CONNECT_TIMEOUT",
27-
"UND_ERR_DNS_RESOLVE_FAILED",
28-
"UND_ERR_CONNECT",
29-
"UND_ERR_SOCKET",
30-
"UND_ERR_HEADERS_TIMEOUT",
31-
"UND_ERR_BODY_TIMEOUT",
3217
]);
3318
const NO_BODY_HTTP_WRAPPER_RE =
3419
/^(?:no body(?: response)?|no response body|status code \(no body\))$/i;
@@ -349,7 +334,10 @@ export function classifyFailoverReasonFromCode(raw: string | undefined): Failove
349334
case "OVERLOADED_ERROR":
350335
return "overloaded";
351336
default:
352-
return TIMEOUT_ERROR_CODES.has(normalized) ? "timeout" : null;
337+
return FAILOVER_TIMEOUT_ERROR_CODES.has(normalized) ||
338+
isTransientNetworkError({ code: normalized })
339+
? "timeout"
340+
: null;
353341
}
354342
}
355343
export function classifyCoreFailoverReasonFromErrorType(

0 commit comments

Comments
 (0)