fix(agents): fallback on embedded upstream errors#96260
Closed
harjothkhara wants to merge 1 commit into
Closed
Conversation
Contributor
Author
|
Closing as a duplicate — standing down in favor of the existing open fixes for #95519. Patch-level comparison of the open PRs:
This PR adds nothing those don't already cover, and broadening the gate further is wider than the reported bug (higher merge-risk on an |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #95519
What Problem This Solves
Embedded agent runs could end immediately on provider-side transient failures even when
agents.defaults.model.fallbackswas configured. In particular, structured provider payloads such as{"type":"upstream_error","message":"Upstream request failed"}were surfaced asLLM request failedinstead of advancing to the next configured fallback model.Why This Change Was Made
The embedded result fallback classifier already delegates provider payload text to the shared failover matcher, but it only accepted auth, billing, and rate-limit reasons. This patch lets the embedded path also treat shared transient provider reasons (
overloaded,server_error, andtimeout) as fallback-safe, while preserving the existing guards for visible output, hook blocks, replay-invalid state, committed delivery evidence, and unclassified application errors.The shared matcher also now recognizes structured
server_error/upstream_errorJSON fields even when the JSON has spaces around:rather than the exact compact string.User Impact
Users with configured model fallbacks should now get the next fallback candidate for transient upstream provider failures instead of a failed turn after the primary provider returns an upstream error.
Evidence
Behavior addressed: Embedded provider error payloads with
upstream_error, HTTP 500 server errors, or existing shared transient failover classifications now produceembedded_error_payloadfallback classifications sorunWithModelFallbackcan advance to the next configured candidate.Real environment tested: Local OpenClaw checkout on macOS, Node 24.16.0, using the repo vitest wrapper in this Codex worktree.
Exact steps run after the patch:
Evidence after fix:
result-fallback-classifier.test.ts+failover-matches.test.ts: 49 tests passed.outcome-fallback-runtime-contract.test.ts+model-fallback.test.ts: 92 tests passed.oxfmt --check: all matched files use the correct format.run-oxlint.mjs: passed for the touched files.git diff --check: passed.autoreview: clean, no accepted/actionable findings reported.Observed result: Structured
upstream_errorpayloads classify asserver_error, embedded provider payloads classify asembedded_error_payload, and existing fallback-loop tests continue to pass.What was not tested: Live gateway/provider run against an actual failing upstream service. The issue is covered with source-level classifier proof and fallback-loop unit coverage.
AI-assisted: yes. This PR was implemented with Codex assistance; I reviewed the code paths, focused tests, and autoreview result before opening it.