Repository navigation
Closed as not planned
Closed as not planned
Copy link
Description
Description
When switching agents via ACP JSON-RPC session/set_mode, the agent's configured model from opencode.json is not applied to the session. The session continues using whatever model was set before the mode switch.
This is the ACP counterpart to #7099, which describes the same problem for the HTTP REST API.
Root Cause
setSessionMode() in packages/opencode/src/acp/agent.ts only sets session.modeId but never updates session.model:
async setSessionMode(params: SetSessionModeRequest): Promise<SetSessionModeResponse | void> {
const session = this.sessionManager.get(params.sessionId)
const availableModes = await this.loadAvailableModes(session.cwd)
if (!availableModes.some((mode) => mode.id === params.modeId)) {
throw new Error(`Agent not found: ${params.modeId}`)
}
this.sessionManager.setMode(params.sessionId, params.modeId)
// session.model is never updated here
}Additionally, loadAvailableModes() strips the model and variant fields from agent configs, so even if setSessionMode wanted to look up the model, the data isn't available.
Proposed Fix
Three changes in packages/opencode/src/acp/agent.ts:
- Extend
ModeOptiontype to includemodel?andvariant? - Pass
modelandvariantthrough inloadAvailableModes() - In
setSessionMode(), after setting the mode, updatesession.modelandsession.variantif the selected agent has a configured model
async setSessionMode(params: SetSessionModeRequest): Promise<SetSessionModeResponse | void> {
const session = this.sessionManager.get(params.sessionId)
const availableModes = await this.loadAvailableModes(session.cwd)
- if (!availableModes.some((mode) => mode.id === params.modeId)) {
+ const selectedMode = availableModes.find((mode) => mode.id === params.modeId)
+ if (!selectedMode) {
throw new Error(`Agent not found: ${params.modeId}`)
}
this.sessionManager.setMode(params.sessionId, params.modeId)
+
+ if (selectedMode.model) {
+ this.sessionManager.setModel(session.id, {
+ providerID: ProviderID.make(selectedMode.model.providerID),
+ modelID: ModelID.make(selectedMode.model.modelID),
+ })
+ this.sessionManager.setVariant(session.id, selectedMode.variant)
+ }
}Steps to Reproduce
- Configure agent-specific models in
opencode.json:{ "model": "anthropic/claude-sonnet-4-5", "agent": { "custom": { "model": "anthropic/claude-opus-4" } } } - Connect via ACP client
- Create a session, then call
session/set_modewithmodeId: "custom" - Send a prompt — observes that
claude-sonnet-4-5is used instead ofclaude-opus-4
Related
- Server API ignores agent's configured model when only agent parameter is passed #7099 — Same problem for the HTTP REST API
Reacted by Neil Okamoto, Ezra Wijaya and Jesús Guerreiro Real de Asua
Metadata
Metadata
Assignees
Labels
No labels
Activity
github-actions commentedon Jul 4, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.