fix(agent-mode): support opencode 1.15.13 model API + force-upgrade older#2557
Merged
Conversation
…orce-upgrade older opencode opencode 1.15.13 (anomalyco/opencode#29929 "promote next ACP implementation") dropped the dedicated ACP `models` state and moved the model catalog into a `category:"model"` config option. The plugin only read `models`, so against 1.15.13 the picker showed BYOK models as "Not offered by agent" and the current model as a raw provider UUID that failed to run. Derive the catalog from the `category:"model"` config option when `models` is absent and route switching through `session/set_config_option` (via a new ModelState.apply spec). Pin the managed binary to 1.15.13 and prompt users on older opencode to upgrade — managed reinstall or `opencode upgrade` for custom binaries — from both the chat view and the configure dialog. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b5016d937f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…picker opencode ≥ 1.15.13 advertises its catalog via a `category:"model"` config option whose entries carry no per-model effort; effort is a sibling `category:"thought_level"` option opencode only surfaces for the *active* model. So `translateBackendState` could only attach effortOptions to the current model, leaving every other picker row with no effort stepper until it was selected. Eagerly, right after a session's catalog loads, probe each enabled model once to learn its effort and cache it for the picker. The probe loop reuses the existing warm probe session (a model switch is ~ms; creating a session is ~1s) and runs before the warm entry is published, restoring the original model in a finally — so the session the manager adopts is never left on a probed model (race-free). opencode-only via a new optional descriptor hook `prefetchEffortCatalog`; other backends are untouched. - descriptor.ts: add optional `prefetchEffortCatalog` to BackendDescriptor - opencode/descriptor.ts: implement it (skip missing-key models, swallow per-model errors, restore original; frozen EMPTY_EFFORT_CATALOG) - AgentModelPreloader: effortCatalog cache + getEffortCatalog + run prefetch in runProbe before publishing warm; clear on clearCached/shutdown - AgentSessionManager: getEffortCatalog passthrough - agentModelPickerHelpers: buildEffortOptionsByModelKey falls back to the prefetch cache for non-active rows (live effort wins for the active model) - useAgentModelPicker: include the effort-catalog in the picker re-render signal Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ssion Enabling a new model restarts the backend, but when the active chat tab was on that backend, restartBackendNow recreated the session without re-probing. clearCached had already wiped the per-model effort catalog, and a live session's attachModelCacheSync mirrors catalog state but not the effort catalog — so effort steppers vanished for every model until a plugin reload. Couple restart with probing: for an installed backend, always run the preloader probe (which re-runs the effort prefetch). When a tab on the backend is active, await the probe and let the replacement session adopt the warm proc — still a single spawn, with the per-model switch flicker kept on the throwaway probe session. The only restart-without-probe case left is an uninstalled backend, which runProbe already self-guards. Also reformats one unrelated builtinSkills test line via `npm run format`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Fixes the agent-mode bug from #2547 where opencode BYOK models showed as "Not offered by agent" and the selected model rendered as a raw provider UUID that failed to run. The cause: opencode 1.15.13 (sst/opencode#29929, "promote next ACP implementation") dropped the dedicated ACP
modelsstate and moved the model catalog into acategory:"model"config option, which the plugin never read. This PR derives the catalog from that config option whenmodelsis absent and routes model switching throughsession/set_config_option(via a newModelState.applyspec), with codex/claude unaffected. It also pins the managed binary to 1.15.13 and prompts users on older opencode to upgrade — managed reinstall oropencode upgradefor a custom binary — from both the chat view and the configure dialog. Verified withtsc, eslint, the production esbuild build, and the full jest suite (all green, plus new tests for the config-option catalog, the apply spec,applyModelWireIddispatch, and acompareSemverutil).🤖 Generated with Claude Code