anomalyco / anomalyco/opencode
[BUG]: Primary-agent switches silently keep the previous agent's model in V2
@neriousy is already working on this.
Since Aug 18, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
In the OpenCode 2 beta, switching primary agents changes the prompt and permissions but silently keeps the existing session model and variant.
For example, with Plan configured for provider/model-a#high and Build configured for provider/model-b#max, a Plan session remains on model A after Shift-Tab selects Build. The next request runs the Build agent on model A. Delegated children do use their own configured models, so the behavior is inconsistent between primary-agent switching and delegation.
This recreates the UX reported in #3550 and previously fixed by #3572. V2 now documents the separate session model, but the result is still surprising: an agent profile combines a prompt, permissions, and a model preference, and the UI presents the agent and model together.
This can silently run a role on a weaker, more expensive, or incompatible model and reasoning variant. It can also defeat an intended local-model boundary when a sensitive role is selected after a hosted-model role.
There is a legitimate opposite requirement in #41221: a model chosen manually should not be discarded on every agent switch. An unconditional "always switch" or "always preserve" rule makes one workflow fail.
Suggested behavior:
- Track whether the session model is following the agent default or pinned by the user.
- A new session initialized from an agent's configured model starts in follow-agent mode.
- In follow-agent mode, switching primary agents applies the new agent's configured model and variant.
- Selecting
/modelsor/variantsexplicitly pins the session choice, so it survives later agent switches. - Show when a session override is pinned and provide a simple "Use agent default" action to return to follow-agent mode.
- Update the selected agent and effective model atomically so plugins do not need timing-sensitive synchronization hooks.
That preserves explicit user choices while making configured role defaults behave like defaults. It prevents silent model/role mismatches without forcing plugin authors to build parallel preference stores or race the TUI.
Plugins
None required. The behavior reproduces with native V2 agents.<role>.model configuration.
OpenCode version
opencode2 v0.0.0-beta-17577
Steps to reproduce
- Configure two selectable primary agents with different native
modelvalues and variants. - Start a new session with the first agent and confirm its configured model is active.
- Shift-Tab to the second agent.
- Send a prompt.
- Observe that the second agent's prompt/permissions run with the first agent's session model instead of its configured model.
- As a control, delegate to a child with its own configured model and observe that the child uses its configured model.
Screenshot and/or share link
No public share link; the session contains private repository context.
Operating System
Fedora Linux 44
Terminal
OpenCode TUI on Linux
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.