Skip to content

ACP: Support per-session model selection via session/set_config #31750

Description

@stupidsexyhermes

Problem

Hermes Agent (and likely other ACP clients) cannot select a specific model per session when using OpenCode via ACP. Each opencode acp process spawns a new session, but the model is always read from opencode.json at startup. There is no way for the ACP client to tell OpenCode which model to use for a given session.

The OpenCode TUI supports model switching via the /model command, but this is only accessible interactively.

What We Tried

  1. --model flag on opencode acp: Not supported. The ACP command only accepts --print-logs.
  2. OPENCODE_MODEL env var: Not respected. OpenCode reads from opencode.json exclusively.
  3. Text hint in prompt: Hermes includes "Hermes requested model hint: openai/gpt-5.5" in the prompt text, but this is just text -- OpenCode ignores it and uses the config file model.
  4. session/set_config with configId: "model": Returns "Method not found" in v1.15.13.
  5. Config file swap before spawn: Works but is racy for parallel sessions and fragile (requires write access, file locking, cleanup on crash).

Proposed Solution

The ACP session lifecycle should support model selection. The source code shows partial implementation (setModel/getModel on ACPSessionManager, PR #3358), but the session/set_config method is not yet exposed in the released ACP protocol.

Option A: session/new with model parameter

{
  "method": "session/new",
  "params": {
    "cwd": "/project",
    "mcpServers": [],
    "model": "openai/gpt-5.5"
  }
}

Cleanest approach -- client specifies the model at session creation time, no extra round-trip needed.

Option B: session/set_config after session/new

{
  "method": "session/set_config",
  "params": {
    "sessionId": "ses_...",
    "configId": "model",
    "value": "openai/gpt-5.5"
  }
}

Matches the existing configId/value pattern already used in the TUI.

Option C: CLI argument

opencode acp --model openai/gpt-5.5

Simplest for CLI users but less flexible than protocol-level support.

Use Case

Hermes Agent runs model routing: complex tasks go to GPT-5.5, medium tasks to GLM-5-turbo, simple tasks to MiniMax-M2.7. Each delegate_task spawns a fresh opencode acp process. Without per-session model selection, all tasks use whatever model is in opencode.json.

Currently working around this by temporarily swapping opencode.json before each spawn, which is fragile and not parallel-safe.

Environment

  • OpenCode: 1.15.13
  • OS: Windows 10 (Git Bash)
  • ACP client: Hermes Agent (Python)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions