Skip to content

fix(agent-mode): support opencode 1.15.13 model API + force-upgrade older#2557

Merged
zeroliu merged 4 commits into
v4-previewfrom
zeroliu/beijing
Jun 4, 2026
Merged

fix(agent-mode): support opencode 1.15.13 model API + force-upgrade older#2557
zeroliu merged 4 commits into
v4-previewfrom
zeroliu/beijing

Conversation

@zeroliu

@zeroliu zeroliu commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

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 models state and moved the model catalog into a category:"model" config option, which the plugin never read. This PR derives the catalog from that config option when models is absent and routes model switching through session/set_config_option (via a new ModelState.apply spec), with codex/claude unaffected. It also pins the managed binary to 1.15.13 and prompts users on older opencode to upgrade — managed reinstall or opencode upgrade for a custom binary — from both the chat view and the configure dialog. Verified with tsc, eslint, the production esbuild build, and the full jest suite (all green, plus new tests for the config-option catalog, the apply spec, applyModelWireId dispatch, and a compareSemver util).

🤖 Generated with Claude Code

…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>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/agentMode/session/translateBackendState.ts
zeroliu and others added 3 commits June 4, 2026 09:32
…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>
@zeroliu zeroliu requested a review from logancyang June 4, 2026 15:01
@zeroliu zeroliu merged commit 4102574 into v4-preview Jun 4, 2026
2 checks passed
@zeroliu zeroliu deleted the zeroliu/beijing branch June 4, 2026 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant