fix(acp): prefer default agent's model over config default for new sessions - #42836
Open
Qiiks wants to merge 1 commit into
Open
fix(acp): prefer default agent's model over config default for new sessions#42836Qiiks wants to merge 1 commit into
Qiiks wants to merge 1 commit into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #42835
Type of change
What does this PR do?
ACP session creation (
session/new) resolved the default model viaselectDefaultModel(snapshot), which reads the configuredmodel(or falls back to the first provider model) — the default agent's assigned model was never considered. Since ACP passes that resolved model explicitly tosession.create/session.prompt, the server-side precedenceinput.model ?? agent.model ?? currentModel(packages/opencode/src/session/prompt.ts) never reachesagent.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 pathloaderLayer(packages/opencode/src/acp/directory.ts) — Layer-based pathClient-explicit model selection (config option updates, prompt params) is unchanged and still wins.
How did you verify your code works?
prefers the default agent's assigned model over the configured modelin packages/opencode/test/acp/service-session.test.ts — RED before the fix (session created with configured model), GREEN after (session created with agent model)tsgo --noEmittypecheck cleanopencode acpagainst a config with a default agent carrying an assigned model —session/newreturns 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