Skip to content

Switch OpenCode V2 model with approved agent - #1569

Merged
backnotprop merged 1 commit into
backnotprop:mainfrom
rcdailey:fix/opencode-v2-agent-model
Sep 18, 2026
Merged

backnotprop merged 1 commit into
backnotprop:mainfrom
rcdailey:fix/opencode-v2-agent-model

Conversation

@rcdailey

Copy link
Copy Markdown
Contributor

OpenCode stores the session agent and model independently. Approving a plan currently selects Build while leaving Plan's model active when the agents have different model configurations.

This preserves model metadata from V2 agent discovery and applies switchAgent followed by switchModel, matching OpenCode's own clients. Hosts that cannot apply both selections avoid a partial switch, and failures continue to leave plan approval intact.

OpenCode stores the session agent and model independently, so V2 plan
approval could select Build while continuing with Plan's configured
model.

Carry validated agent model metadata into the approval handoff and apply
the two durable session selections in OpenCode's order. Older hosts
avoid a partial switch, while switch failures remain non-blocking for
approval.
@backnotprop
backnotprop merged commit c24c026 into backnotprop:main Sep 18, 2026
24 checks passed
@backnotprop

Copy link
Copy Markdown
Owner

Merged, thanks. Verified against the V2 wire shape (AgentV2Info.model is the ModelRef, so the id/variant read is right) and the CLI bridge path is untouched. One optional follow-up if you feel like it: when the host lacks switchModel but the agent has a configured model, the PR skips the agent switch entirely, while a throwing switchModel keeps the agent and warns. Treating both the same (switch the agent, warn about the model) would remove that inconsistency and keep older hosts switching agents as they did before. Will go out in 0.27.17.

@rcdailey

Copy link
Copy Markdown
Contributor Author

Thanks for the quick merge; I wanted to provide the screenshot below to show the fix working in action during local testing.

image

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.

2 participants