Skip to content

fix(acp): prefer default agent's model over config default for new sessions - #42836

Open
Qiiks wants to merge 1 commit into
anomalyco:devfrom
Qiiks:pr/acp-agent-default-model
Open

fix(acp): prefer default agent's model over config default for new sessions#42836
Qiiks wants to merge 1 commit into
anomalyco:devfrom
Qiiks:pr/acp-agent-default-model

Conversation

@Qiiks

@Qiiks Qiiks commented Aug 16, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #42835

Type of change

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

What does this PR do?

ACP session creation (session/new) resolved the default model via selectDefaultModel(snapshot), which reads the configured model (or falls back to the first provider model) — the default agent's assigned model was never considered. Since ACP passes that resolved model explicitly to session.create / session.prompt, the server-side precedence input.model ?? agent.model ?? currentModel (packages/opencode/src/session/prompt.ts) never reaches agent.model: ACP clients (e.g. Zed) start sessions with the wrong model whenever agents declare per-agent models (oh-my-openagent style configs).

This PR makes the default model resolution prefer the default agent's assigned model when it resolves to a discovered provider model, falling back to the configured default otherwise. Both snapshot construction paths apply the same precedence:

  • loadDirectorySnapshot (packages/opencode/src/acp/service.ts) — SDK-based path
  • loaderLayer (packages/opencode/src/acp/directory.ts) — Layer-based path

Client-explicit model selection (config option updates, prompt params) is unchanged and still wins.

How did you verify your code works?

  • New test prefers the default agent's assigned model over the configured model in packages/opencode/test/acp/service-session.test.ts — RED before the fix (session created with configured model), GREEN after (session created with agent model)
  • Full ACP suite: 129 pass / 0 fail (10 files)
  • tsgo --noEmit typecheck clean
  • Real-surface QA: built binary + opencode acp against a config with a default agent carrying an assigned model — session/new returns the agent's model in the model config option and the session row persists it (pre-fix: first provider model)

Screenshots / recordings

N/A (protocol layer change)

Checklist

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

…ssions

ACP session creation selected the default model from config (selectDefaultModel) and passed it explicitly to session.create, so the server-side resolution (input.model ?? agent.model ?? currentModel) never reached the default agent's assigned model. With agent configs that assign per-agent models, ACP clients (e.g. Zed) started sessions with the wrong model.

Prefer the default agent's model when it resolves to a discovered provider model, falling back to the configured default otherwise. Both snapshot construction paths (SDK-based loadDirectorySnapshot and the Layer-based loaderLayer) apply the same precedence.
Copilot AI lite review requested due to automatic review settings August 16, 2026 00:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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 creation ignores the default agent's assigned model

2 participants