Skip to content

Commit ed6dd66

Browse files
maweibinclaude
andcommitted
fix(agents): classify upstream transport errors as fallback-worthy (#95519)
classifyBusinessDenialErrorPayloadReason now also returns timeout, overloaded, and server_error failover reasons, so provider upstream errors (e.g. HTTP 500, timeout, overloaded) correctly trigger model fallback instead of being silently ignored. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
1 parent a21144d commit ed6dd66

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/agents/embedded-agent-runner/result-fallback-classifier.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ describe("classifyEmbeddedAgentRunResultForModelFallback", () => {
282282
expect(result).toBeNull();
283283
});
284284

285-
it("does not retry non-business transport error payloads", () => {
285+
it("retries transport error payloads as fallback-worthy", () => {
286286
const result = classifyEmbeddedAgentRunResultForModelFallback({
287287
provider: "custom",
288288
model: "llama-3.1",
@@ -299,7 +299,12 @@ describe("classifyEmbeddedAgentRunResultForModelFallback", () => {
299299
},
300300
});
301301

302-
expect(result).toBeNull();
302+
expect(result).toEqual({
303+
message: "custom/llama-3.1 ended with a provider error: HTTP 500: internal server error",
304+
reason: "timeout",
305+
code: "embedded_error_payload",
306+
rawError: "HTTP 500: internal server error",
307+
});
303308
});
304309

305310
it("keeps tool-authored incomplete summaries fallback-eligible", () => {

src/agents/embedded-agent-runner/result-fallback-classifier.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,10 @@ function classifyHarnessResult(params: {
150150
function classifyBusinessDenialErrorPayloadReason(
151151
errorText: string,
152152
provider: string,
153-
): Extract<FailoverReason, "auth" | "auth_permanent" | "billing" | "rate_limit"> | null {
153+
): Extract<
154+
FailoverReason,
155+
"auth" | "auth_permanent" | "billing" | "rate_limit" | "timeout" | "overloaded" | "server_error"
156+
> | null {
154157
if (!errorText.trim()) {
155158
return null;
156159
}
@@ -160,6 +163,9 @@ function classifyBusinessDenialErrorPayloadReason(
160163
case "auth_permanent":
161164
case "billing":
162165
case "rate_limit":
166+
case "timeout":
167+
case "overloaded":
168+
case "server_error":
163169
return failoverReason;
164170
default:
165171
return null;

0 commit comments

Comments
 (0)