Repository navigation
feat(v2): fall back to the next model instead of only waiting - #41
Merged
Merged
Conversation
In v2, fallbackModels is now an ordered chain. When a request fails with a rate limit or a transient upstream error, a session whose model is in the chain is switched (session.switchModel) to the next model after it and retried about one second later. Once the chain is exhausted, fallbackMode decides: cycle back to the session's own model after a cooldown, retry-last, stop, or wait (never switch). A session whose model is not in the chain keeps the wait behaviour. The next real user prompt puts the session back on its own model. OpenCode 2.0.31 keeps retrying past attempt 5 (its ceiling is about 10), so the timer that resumed at attempt 5 pushed an empty user message into a turn that was still running. A turn is now resumed only after session.execution.failed with a retryable error; interrupted turns stay stopped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Leave sessions whose model is not in fallbackModels to OpenCode by default, as 2.0.x did; "otherModels": "wait" opts into retrying the same model after a cooldown. - Register nothing for a non-wait config without fallback models, so a default config still does nothing. - Validate otherModels in config and cover the compatibility cases in tests.
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.
What
Implements the v1-style fallback chain for the OpenCode v2 entry point (
v2.ts) instead of only supportingfallbackMode: "wait".fallbackModelsis an ordered chain: on a rate limit / transient upstream error the session switches to the next model and retries after ~1s.cycle/retry-last/stopbehave like their v1 counterparts.waitmode keeps its existing single-model, exponential-backoff behavior.session.execution.failed, so an interrupted turn is not resumed.Backward compatibility
index.ts, 1.x line) is untouched.fallbackModels, so a non-waitconfig registers nothing, exactly like 2.0.x.otherModels: "ignore").otherModels: "wait"opts into waiting on the same model, matching 2.0.x wait behavior.package.jsongoes 2.0.3 -> 2.1.0; publishing stays under theopencode-v2npm tag, solatestremains the 1.x line.Tests
npm run typecheckpasses.__tests__/config/watcher.test.tsfs.watch timing tests, which fail identically onmainon macOS; they are untouched by this branch and CI runs on Ubuntu.