Fix: treat HTTP 500 as a transient failover error (#55332)

HTTP 500 (Internal Server Error) was not triggering model fallback,
causing agents to fail outright instead of trying the next candidate.
This is inconsistent with TRANSIENT_HTTP_ERROR_CODES which already
includes 500. Aligns the direct status check with that constant.

Co-authored-by: Craig McWilliams <craigamcw@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Craig Allan-McWilliams
2026-03-27 00:05:15 +00:00
committed by GitHub
parent da845ce598
commit 984f98be95
2 changed files with 3 additions and 3 deletions

View File

@@ -70,8 +70,8 @@ describe("failover-error", () => {
expect(resolveFailoverReasonFromError({ status: 499 })).toBe("timeout");
expect(resolveFailoverReasonFromError({ status: 400 })).toBe("format");
expect(resolveFailoverReasonFromError({ status: 422 })).toBe("format");
// Keep the status-only path behavior-preserving and conservative.
expect(resolveFailoverReasonFromError({ status: 500 })).toBeNull();
// Transient server errors (500/502/503/504) should trigger failover as timeout.
expect(resolveFailoverReasonFromError({ status: 500 })).toBe("timeout");
expect(resolveFailoverReasonFromError({ status: 502 })).toBe("timeout");
expect(resolveFailoverReasonFromError({ status: 503 })).toBe("timeout");
expect(resolveFailoverReasonFromError({ status: 504 })).toBe("timeout");

View File

@@ -494,7 +494,7 @@ export function classifyFailoverReasonFromHttpStatus(
}
return "timeout";
}
if (status === 502 || status === 504) {
if (status === 500 || status === 502 || status === 504) {
return "timeout";
}
if (status === 529) {