Skip to content

fix(acp): session/set_mode now activates agent's configured model#18621

Open
systemfreund wants to merge 1 commit intoanomalyco:devfrom
systemfreund:fix/acp-set-mode-activates-model
Open

fix(acp): session/set_mode now activates agent's configured model#18621
systemfreund wants to merge 1 commit intoanomalyco:devfrom
systemfreund:fix/acp-set-mode-activates-model

Conversation

@systemfreund
Copy link
Copy Markdown

@systemfreund systemfreund commented Mar 22, 2026

Issue for this PR

Closes #18620

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

session/set_mode only updated session.modeId but never called setModel()/setVariant(), so the session kept using the default or previously configured model instead of the one configured for the selected agent.

The root cause is twofold:

  1. loadAvailableModes() stripped model and variant from agent configs when building the mode list, so setSessionMode() had no model data available.
  2. setSessionMode() only called this.sessionManager.setMode() without updating the model.

The fix extends ModeOption to carry model and variant, passes them through in loadAvailableModes(), and adds the setModel()/setVariant() calls in setSessionMode() when the selected agent has a configured model.

Ref #7099

How did you verify your code works?

  1. Added 4 unit tests in packages/opencode/test/acp/set-session-mode.test.ts — all pass
  2. Built the binary and manually verified that switching agents via ACP now activates the configured model

Screenshots / recordings

N/A — backend/protocol change, no UI.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Mar 22, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@systemfreund systemfreund force-pushed the fix/acp-set-mode-activates-model branch 4 times, most recently from ee97605 to 314af37 Compare March 24, 2026 12:53
When switching agents via session/set_mode, only the session's modeId
was updated but the model remained unchanged. This caused the session
to keep using the previously configured (or default) model instead of
the model configured for the selected agent.

Now setSessionMode() also updates session.model and session.variant
when the selected agent has a configured model, matching the behavior
users expect when switching agents.

Closes anomalyco#18620
Ref anomalyco#7099
@systemfreund systemfreund force-pushed the fix/acp-set-mode-activates-model branch from 314af37 to 101e8c4 Compare March 24, 2026 19:38
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.

ACP: session/set_mode does not activate the agent's configured model

1 participant