Repository navigation
fix(opencode): allow model picks when discovery is unavailable - #31985
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review.
|
…3-opencode-version-gates
|
Supported OpenCode launches can be refused before starting when catalog or model discovery is incomplete. This PR lets the exact picked model reach the existing launch operation without requiring catalog membership or a matching model echo. The final difference from main is still model preparation, not version eligibility. For v2, the overlay uses OpenCode’s first resolved selectable agent. A stale config default cannot create a blank agent; if discovery returns no agent, only the top-level model changes and existing agent entries remain untouched. The recorded initial-empty and settled-list responses from real OpenCode 2.0.19 cover a stale Main’s #33307/#33436 policy is retained: stable 1.x from 1.18.30 below 2; 2.0.16 and stable 2.0.19 or later below 3. Picked-model launches on 2.0.14/15/17/18, unknown versions, prereleases and 3.x remain refused. Refused users are told to update OpenCode or omit their model choice, with all seven locales covered. Existing-worktree workers refuse before dispatch under either mode default, matching main; preflight repeats neither metadata discovery nor full terminal preparation. The no-model startup-submit bug is separately tracked as STA-12110 and is not fixed here. Actual model application and resumed-model switching remain the existing limitation tracked in STA-11727. With discovery absent, a preserved agent-specific model can still override the top-level model. The design preserves the requested model in launch preparation; these contracts do not prove provider execution. Focused corrections are in Later main integration: merge Main integration after #33249: merge Verified on reviewed head
Late automated review comments were independently traced. Empty-agent polling is the already-recorded one-shot discovery limitation; the initial empty snapshots are covered and the top-level-only fallback is intentional. Custom-argument preflight identifies a deferred P2 timing difference: eligible-v2 terminal workers with unsupported configured arguments fail after dispatch and leave a failed receipt, whereas main rejected them before dispatch. Unsafe versions still refuse before effects. Native ACP workers use fixed arguments and can proceed, so the suggested unconditional guard would reject that separate path too. This focused correction retains version-only preflight and the existing terminal preparation boundary; it does not claim identical timing for every refusal. The earlier 129-test result on For Brennan’s review: resolved agent selection, model overlay, worker refusal before dispatch. Historical investigation screenshots (old 2.0.14 policy; not final acceptance evidence)All six no-keypress measurements stayed unsent. A later manual submission reached a provider quota error, with no successful reply. Those results support the retained unsafe-release refusal and separate STA-12110 report. Old main refused the picked model: Old head after manual submission received a provider quota error: |
…election (#33307) OpenCode model selection accepts per-major floors (1.x >= 1.18.30, 2.x >= 2.0.14; prereleases and 3.x refused) instead of exact version allowlists, so current releases launch with a picked model again. Fixes #26611. Supersedes #26683, #31985. Co-authored-by: ggbdpq <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 2

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
f4bc0da4-b26f-4ee8-98e5-137f83105be7
Files selected for processing: 20-
src/main/opencode/opencode-launch-model-config.tssrc/main/opencode/opencode-launch-model-context-cleanup.test.tssrc/main/opencode/opencode-launch-model-context.test.tssrc/main/opencode/opencode-launch-model-context.tssrc/main/opencode/opencode-model-startup-plan.test.tssrc/main/opencode/opencode-model-startup-plan.tssrc/main/opencode/opencode-resolved-agents.fixture.jsonsrc/main/runtime/orchestration-opencode-model-host.test.tssrc/main/runtime/rpc/methods/orchestration-worker-start-mode-selection.test.tssrc/main/runtime/terminal/wait/terminal-interactive-wait.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/fr.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/pt.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/lib/ipc-error.test.tssrc/renderer/src/lib/ipc-error.tssrc/shared/agent-launch-model-preferences.ts
Files skipped from review as they are similar to previous changes: 1-
- src/shared/agent-launch-model-preferences.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
-
…election (stablyai#33307) OpenCode model selection accepts per-major floors (1.x >= 1.18.30, 2.x >= 2.0.14; prereleases and 3.x refused) instead of exact version allowlists, so current releases launch with a picked model again. Fixes stablyai#26611. Supersedes stablyai#26683, stablyai#31985. Co-authored-by: ggbdpq <[email protected]> (cherry picked from commit d170b5a)


Supported OpenCode launches can be rejected before they start because a model catalog is incomplete, the CLI reports a different model name, or optional agent discovery fails. This PR lets the selected model reach the existing launch operation despite those discovery failures.
The remaining change compared with main is catalog and readback handling, not version support. Legacy launches pass the exact selected model through the existing flag without catalog approval. Eligible v2 launches use an optional resolved-agent lookup and a launch-only configuration overlay; they no longer require catalog membership or a matching model echo. The overlay targets the first resolved selectable agent. When none is discovered, it changes only the top-level model, preserving existing agents and never inventing an agent from a stale default or a guessed
buildname.Main’s #33307 and #33436 policies are preserved: stable 1.x from 1.18.30 below 2; 2.0.16 and stable 2.0.19 or later below 3. Picked-model launches on 2.0.14/15/17/18, unknown versions, prereleases and 3.x remain refused. The error names OpenCode and tells the user to update it or launch without a model choice; the renderer translates this guidance in all seven supported locales. Existing-worktree workers are refused before dispatch, including when native workers are the default, matching main. Their preflight checks placement and version without repeating metadata discovery or full terminal preparation.
No startup-prompt fix is included. The separate no-model startup-submit issue is STA-12110. This change preserves the requested model; it does not add a guarantee that the CLI applies it or switches a resumed session’s model. Those existing limitations remain tracked in STA-11727. Existing placement, argument and configuration limits remain.
Validation covers real OpenCode 2.0.19 output for a stale
default_agentand disabledbuild, both at the initial empty-list snapshot and after agent resolution. Checked-in contract tests feed those captured shapes through the parser and overlay writer, verifying the resolved agent and preserved configuration. The empty response was transient; it is not evidence of persistent discovery failure. CI executed all six changed regression files successfully (78 tests), plus the writer configuration file (eight tests), on its merge commit incorporating76149fc1. These cover unsafe-version guidance, pre-dispatch worker refusal under both mode defaults, cleanup and renderer localization. These tests prove model preparation and refusal handling, not provider inference.A retained P2 limitation is that eligible-v2 terminal workers with unsupported configured arguments fail after dispatch, leaving a failed receipt; main refused those arguments before dispatch. Unsafe-version refusal is restored before effects. Native ACP workers use a separate fixed argument list and remain eligible. The status comment records the independent disposition of this distinction.
All applicable CI checks passed on the final head. The full-path review and focused delta review classify the changed flows as CLI/orchestration and copy tests rows. The final status comment records the exact head, test execution, CI result and evidence limits. Historical 129-test evidence on
4253aaa9predates these corrections; assertions that relied on raw config defaults or late worker failure are superseded.Earlier investigation on OpenCode 2.0.14 found six unsent first prompts, and a later manual submission reached a provider quota error. Neither result is a passing test of the final accepted-version policy. Historical successful 1.18.32 replies cover the unchanged legacy transport.