fix(agents): classify upstream transport errors as fallback-worthy#96619
fix(agents): classify upstream transport errors as fallback-worthy#96619maweibin wants to merge 1 commit into
Conversation
…penclaw#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]>
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Close as superseded: the useful central fix is already covered by the stronger open canonical PR, while this branch misses the exact reported Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Canonical path: Use #95542 as the canonical landing path for the linked upstream-error bug; propose any broader HTTP 500 or overloaded embedded payload behavior as a focused follow-up if maintainers want it. So I’m closing this here and keeping the remaining discussion on #95542. Review detailsBest possible solution: Use #95542 as the canonical landing path for the linked upstream-error bug; propose any broader HTTP 500 or overloaded embedded payload behavior as a focused follow-up if maintainers want it. Do we have a high-confidence way to reproduce the issue? Yes at source level: current main routes embedded provider error payloads through a narrow helper and treats a null result classification as a successful attempt, so the reported upstream_error shape can stop fallback rotation. Is this the best way to solve the issue? No: this branch is a plausible partial fix, but the best current solution is the canonical PR that maps the exact structured Security review: Security review cleared: The diff only changes an internal TypeScript classifier and its colocated test; it does not touch secrets, dependencies, scripts, package metadata, or code-execution infrastructure. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against a21144d8a606. |
|
ClawSweeper applied the proposed close for this PR.
|
AI-assisted: This PR was developed with Claude Code (Anthropic) assistance.
What Problem This Solves
Issue #95519 reports that provider upstream errors (HTTP 500, timeout, overloaded) do not trigger model fallback. When
classifyEmbeddedAgentRunResultForModelFallbackencounters a transport error payload, it currently returnsnull— the error is silently ignored and no fallback model is attempted.Impact: Users who configure model fallback get no fallback when the primary provider returns a transient upstream error (e.g., HTTP 500, timeout, overloaded). The session silently continues with the error rather than retrying with a different model/provider.
Root Cause
classifyBusinessDenialErrorPayloadReason()insrc/agents/embedded-agent-runner/result-fallback-classifier.ts:150-167only returnedauth,auth_permanent,billing, andrate_limitfailover reasons. TheclassifyFailoverReason()helper already recognizestimeout,overloaded, andserver_error, but the classifier's return type and switch statement excluded them, causing the function to returnnullfor those error types.Summary of Changes
src/agents/embedded-agent-runner/result-fallback-classifier.ts(+3 lines)Extended the
classifyBusinessDenialErrorPayloadReasonreturn type and switch statement to also includetimeout,overloaded, andserver_error:Added cases to the switch statement for the three new reasons.
src/agents/embedded-agent-runner/result-fallback-classifier.test.ts(+5 / -1)Updated the "does not retry non-business transport error payloads" test:
nullfor"HTTP 500: internal server error"(no fallback){ reason: "timeout", code: "embedded_error_payload" }(triggers fallback)Evidence
1. Real Behavior Proof — 9/9 proof cases pass
2. Full test suite — 18/18 tests pass
3. oxlint clean
4. Build clean
5. Behavior comparison
null)reason: "timeout"null)reason: "timeout"null)reason: "overloaded"reason: "auth"reason: "billing"reason: "rate_limit"null)6. Code invariance proof
Merge Risk Assessment
Risk Category: Low — expands fallback eligibility to more error types.
What Could Go Wrong: More aggressive fallback could consume additional model budget on transient errors. Mitigated by the fact that these are already recognized as provider errors by
classifyFailoverReason— this change only allows the fallback mechanism to act on them.Why It's Safe:
timeout/overloaded/server_errorby the existing helpernull(no behavioral change)Not modified:
src/agents/embedded-agent-helpers/errors.ts,src/agents/embedded-agent-helpers/failover-matches.ts,src/agents/embedded-agent-helpers/types.ts.All Proof Cases Passed
Closes #95519