Error-class-bound fallthrough for OpenRouter models[] fallback#334
Merged
Conversation
Add an optional `fallthrough?: boolean` to the ErrorResponse fixture type. In the OpenRouter models[] fallback loop, when a matched error response sets `fallthrough: false`, treat it as terminal (stop the loop, serve that error, no failover) instead of falling through to the next candidate. Absent/`true` keeps the current backward-compatible fall-through. This reproduces OpenRouter's inconsistent-by-error-class failover: a 403 budget-exceeded / generic provider error is served as terminal, while 429/503 fail over. The per-fixture gate composes with the request-level `provider.allow_fallbacks`: fall-through happens only when BOTH allow it. Threads the field through types.ts (ErrorResponse) and the fixture-loader (response-level, carried by the existing normalizeResponse shallow clone). validateFixtures rejects a non-boolean `fallthrough` at load, so the fail-closed half cannot silently fail open on a "false"/0/null author typo. Documents it in the OpenRouter docs fallback section and write-fixtures skill.
commit: |
jpr5
marked this pull request as ready for review
July 23, 2026 01:54
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.
Error-class-bound fallthrough for the OpenRouter
models[]fallback engineFollow-up to #328. That PR shipped
models[]failover (an error-fixture candidate falls through to the next model, unlessprovider.allow_fallbacks:false). But real OpenRouter fails over inconsistently by error class — the loudest authentic user complaint (openclaw#60191, #45834, #19249): a403 budget-exceededor generic "provider error" does not advance to the next model (it retries the same primary), while 429/503 do. Users can't rehearse that.What this adds
An optional
fallthrough?: booleanon the error fixture response:models[]candidate (fully backward-compatible).fallthrough: false→ the error is terminal: the loop stops and serves that error, no failover — reproducing "this error class doesn't fail over."It composes with the request-level
provider.allow_fallbacks:false(either signal makes an error terminal). A dev models an error class by settingfallthrough:falseon that class's fixture (e.g. the 403) and leaving 429/503 fixtures to default — so they can reproduce the exact failure that burned them and assert their handling, and the positive "fallback saved me" path.Correctness
validateFixturesrejects a non-booleanfallthrough("false",0,null) — without this, a JSON author's"false"string would silently invert TERMINAL→fall-through (fail-closed quietly failing open).response.model; a terminal error is served as the OpenRouter error envelope ({error:{code,message,metadata?}}, nomodelfield).Testing / review
fallthrough:falseterminal, default fall-through, composition, and the non-boolean load-time rejection.pnpm test); tsc/lint/build/exports clean. No version bump (release is separate).🤖 Generated with Claude Code
https://claude.ai/code/session_018yy1y2Cwc31DaB4UNqvT8K