mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 08:02:42 +00:00
Add HTTP 499 to transient error codes for model fallback (#41468)
Merged via squash.
Prepared head SHA: 0053bae140
Co-authored-by: zeroasterisk <23422+zeroasterisk@users.noreply.github.com>
Co-authored-by: altaywtf <9790196+altaywtf@users.noreply.github.com>
Reviewed-by: @altaywtf
This commit is contained in:
@@ -38,6 +38,7 @@ Docs: https://docs.openclaw.ai
|
|||||||
- Protocol/Swift model sync: regenerate pending node work Swift bindings after the landed `node.pending.*` schema additions so generated protocol artifacts are consistent again. (#41477) Thanks @mbelinky.
|
- Protocol/Swift model sync: regenerate pending node work Swift bindings after the landed `node.pending.*` schema additions so generated protocol artifacts are consistent again. (#41477) Thanks @mbelinky.
|
||||||
- Discord/reply chunking: resolve the effective `maxLinesPerMessage` config across live reply paths and preserve `chunkMode` in the fast send path so long Discord replies no longer split unexpectedly at the default 17-line limit. (#40133) thanks @rbutera.
|
- Discord/reply chunking: resolve the effective `maxLinesPerMessage` config across live reply paths and preserve `chunkMode` in the fast send path so long Discord replies no longer split unexpectedly at the default 17-line limit. (#40133) thanks @rbutera.
|
||||||
- Logging/probe observations: suppress structured embedded and model-fallback probe warnings on the console without hiding error or fatal output. (#41338) thanks @altaywtf.
|
- Logging/probe observations: suppress structured embedded and model-fallback probe warnings on the console without hiding error or fatal output. (#41338) thanks @altaywtf.
|
||||||
|
- Agents/fallback: treat HTTP 499 responses as transient in both raw-text and structured failover paths so Anthropic-style client-closed overload responses trigger model fallback reliably. (#41468) thanks @zeroasterisk.
|
||||||
|
|
||||||
## 2026.3.8
|
## 2026.3.8
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ describe("failover-error", () => {
|
|||||||
expect(resolveFailoverReasonFromError({ statusCode: "429" })).toBe("rate_limit");
|
expect(resolveFailoverReasonFromError({ statusCode: "429" })).toBe("rate_limit");
|
||||||
expect(resolveFailoverReasonFromError({ status: 403 })).toBe("auth");
|
expect(resolveFailoverReasonFromError({ status: 403 })).toBe("auth");
|
||||||
expect(resolveFailoverReasonFromError({ status: 408 })).toBe("timeout");
|
expect(resolveFailoverReasonFromError({ status: 408 })).toBe("timeout");
|
||||||
|
expect(resolveFailoverReasonFromError({ status: 499 })).toBe("timeout");
|
||||||
expect(resolveFailoverReasonFromError({ status: 400 })).toBe("format");
|
expect(resolveFailoverReasonFromError({ status: 400 })).toBe("format");
|
||||||
// Keep the status-only path behavior-preserving and conservative.
|
// Keep the status-only path behavior-preserving and conservative.
|
||||||
expect(resolveFailoverReasonFromError({ status: 500 })).toBeNull();
|
expect(resolveFailoverReasonFromError({ status: 500 })).toBeNull();
|
||||||
@@ -93,6 +94,12 @@ describe("failover-error", () => {
|
|||||||
message: ANTHROPIC_OVERLOADED_PAYLOAD,
|
message: ANTHROPIC_OVERLOADED_PAYLOAD,
|
||||||
}),
|
}),
|
||||||
).toBe("overloaded");
|
).toBe("overloaded");
|
||||||
|
expect(
|
||||||
|
resolveFailoverReasonFromError({
|
||||||
|
status: 499,
|
||||||
|
message: ANTHROPIC_OVERLOADED_PAYLOAD,
|
||||||
|
}),
|
||||||
|
).toBe("overloaded");
|
||||||
expect(
|
expect(
|
||||||
resolveFailoverReasonFromError({
|
resolveFailoverReasonFromError({
|
||||||
status: 429,
|
status: 429,
|
||||||
|
|||||||
@@ -443,6 +443,7 @@ describe("isLikelyContextOverflowError", () => {
|
|||||||
|
|
||||||
describe("isTransientHttpError", () => {
|
describe("isTransientHttpError", () => {
|
||||||
it("returns true for retryable 5xx status codes", () => {
|
it("returns true for retryable 5xx status codes", () => {
|
||||||
|
expect(isTransientHttpError("499 Client Closed Request")).toBe(true);
|
||||||
expect(isTransientHttpError("500 Internal Server Error")).toBe(true);
|
expect(isTransientHttpError("500 Internal Server Error")).toBe(true);
|
||||||
expect(isTransientHttpError("502 Bad Gateway")).toBe(true);
|
expect(isTransientHttpError("502 Bad Gateway")).toBe(true);
|
||||||
expect(isTransientHttpError("503 Service Unavailable")).toBe(true);
|
expect(isTransientHttpError("503 Service Unavailable")).toBe(true);
|
||||||
@@ -457,6 +458,19 @@ describe("isTransientHttpError", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("classifyFailoverReasonFromHttpStatus", () => {
|
||||||
|
it("treats HTTP 499 as transient for structured errors", () => {
|
||||||
|
expect(classifyFailoverReasonFromHttpStatus(499)).toBe("timeout");
|
||||||
|
expect(classifyFailoverReasonFromHttpStatus(499, "499 Client Closed Request")).toBe("timeout");
|
||||||
|
expect(
|
||||||
|
classifyFailoverReasonFromHttpStatus(
|
||||||
|
499,
|
||||||
|
'{"type":"error","error":{"type":"overloaded_error","message":"Overloaded"}}',
|
||||||
|
),
|
||||||
|
).toBe("overloaded");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("isFailoverErrorMessage", () => {
|
describe("isFailoverErrorMessage", () => {
|
||||||
it("matches auth/rate/billing/timeout", () => {
|
it("matches auth/rate/billing/timeout", () => {
|
||||||
const samples = [
|
const samples = [
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ const HTTP_STATUS_PREFIX_RE = /^(?:http\s*)?(\d{3})\s+(.+)$/i;
|
|||||||
const HTTP_STATUS_CODE_PREFIX_RE = /^(?:http\s*)?(\d{3})(?:\s+([\s\S]+))?$/i;
|
const HTTP_STATUS_CODE_PREFIX_RE = /^(?:http\s*)?(\d{3})(?:\s+([\s\S]+))?$/i;
|
||||||
const HTML_ERROR_PREFIX_RE = /^\s*(?:<!doctype\s+html\b|<html\b)/i;
|
const HTML_ERROR_PREFIX_RE = /^\s*(?:<!doctype\s+html\b|<html\b)/i;
|
||||||
const CLOUDFLARE_HTML_ERROR_CODES = new Set([521, 522, 523, 524, 525, 526, 530]);
|
const CLOUDFLARE_HTML_ERROR_CODES = new Set([521, 522, 523, 524, 525, 526, 530]);
|
||||||
const TRANSIENT_HTTP_ERROR_CODES = new Set([500, 502, 503, 504, 521, 522, 523, 524, 529]);
|
const TRANSIENT_HTTP_ERROR_CODES = new Set([499, 500, 502, 503, 504, 521, 522, 523, 524, 529]);
|
||||||
const HTTP_ERROR_HINTS = [
|
const HTTP_ERROR_HINTS = [
|
||||||
"error",
|
"error",
|
||||||
"bad request",
|
"bad request",
|
||||||
@@ -375,6 +375,12 @@ export function classifyFailoverReasonFromHttpStatus(
|
|||||||
}
|
}
|
||||||
return "timeout";
|
return "timeout";
|
||||||
}
|
}
|
||||||
|
if (status === 499) {
|
||||||
|
if (message && isOverloadedErrorMessage(message)) {
|
||||||
|
return "overloaded";
|
||||||
|
}
|
||||||
|
return "timeout";
|
||||||
|
}
|
||||||
if (status === 502 || status === 504) {
|
if (status === 502 || status === 504) {
|
||||||
return "timeout";
|
return "timeout";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user