feat: skip setModel() when model is provided via query Options#447
Open
hatawong wants to merge 1 commit intoagentclientprotocol:mainfrom
Open
feat: skip setModel() when model is provided via query Options#447hatawong wants to merge 1 commit intoagentclientprotocol:mainfrom
hatawong wants to merge 1 commit intoagentclientprotocol:mainfrom
Conversation
When a client passes `model` through `_meta.claudeCode.options` in `session/new`, the model is already set at CLI startup time via the `query()` Options parameter. Calling `setModel()` afterwards triggers an unnecessary `/model` command that: 1. Leaks into the ACP event stream as `user_message_chunk` 2. Adds an extra round-trip to every session creation 3. May override the client's intended model with the default This change adds an `optionsModel` parameter to `getAvailableModels()`. When present, it resolves the model for `currentModelId` reporting but skips the `setModel()` call, eliminating the `/model` command leak. The same `_meta.claudeCode.options` path also supports `effort`, which is spread into SDK Options and takes effect at CLI startup without any post-hoc command — no adapter changes needed for effort support. Backward compatible: clients that don't pass `_meta` get the existing behavior (setModel is called as before). Closes zed-industries#441
|
We require contributors to sign our Contributor License Agreement, and we don't have @hatawong on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
Author
|
@cla-bot check |
|
We require contributors to sign our Contributor License Agreement, and we don't have @hatawong on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
|
The cla-bot has been summoned, and re-checked this pull request! |
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.
Summary
When a client passes
modelthrough_meta.claudeCode.optionsinsession/new, the model is already set at CLI startup time via thequery()Options parameter. The subsequentsetModel()call ingetAvailableModels()is unnecessary and causes two issues:/modelcommand leaks into the ACP event stream —setModel()triggers a/modelCLI command whose output appears asuser_message_chunkevents, polluting the client's UIsetModel()call to every session creationChanges
optionsModelparameter togetAvailableModels()optionsModelis present, resolve it against available models forcurrentModelIdreporting but skip thesetModel()calloptions.model(which comes from_meta.claudeCode.optionsspread) at the call siteEffort support
The same
_meta.claudeCode.optionspath also supportseffort— it gets spread into SDKOptionsand takes effect at CLI startup viaquery({ options: { effort } }). No adapter changes needed for effort support; this PR unblocks it by establishing the pattern of passing config through_metainstead of post-hoc commands.This addresses #441 — effort can now be passed through
_meta.claudeCode.options.effortwithout waiting for a runtimesetEffort()API.Backward compatibility
Clients that don't pass
_meta.claudeCode.options.modelget the existing behavior —setModel()is called as before. Only clients that explicitly provide a model via_metabenefit from the optimization.Test plan
session/newwith_meta: { claudeCode: { options: { model: "claude-opus-4-6" } } }→ no/modelcommand in event streamsession/newwithout_meta→ existingsetModel()behavior unchanged_meta.claudeCode.options.effort→ effort takes effect at CLI startup🤖 Generated with Claude Code