Skip to content

fix: resolve model aliases in setSessionConfigOption (#401)#403

Open
mudrii wants to merge 1 commit intozed-industries:mainfrom
mudrii:fix/model-alias-resolution-in-config-option
Open

fix: resolve model aliases in setSessionConfigOption (#401)#403
mudrii wants to merge 1 commit intozed-industries:mainfrom
mudrii:fix/model-alias-resolution-in-config-option

Conversation

@mudrii
Copy link

@mudrii mudrii commented Mar 9, 2026

Summary

Fixes #401 by enabling model alias/fuzzy resolution in setSessionConfigOption when updating the model config option.

Root cause

setSessionConfigOption validated model values using an exact string match against config option values (model IDs like claude-opus-4-5):

const validValue = allValues.find((o) => o.value === params.value);

Clients often send human-friendly model preferences (opus, sonnet, Claude Sonnet), which failed this exact check and produced:

  • Invalid value for config option model: <value>

The file already had resolveModelPreference(...), which supports exact/display/substring/tokenized matching, but that logic was only used in model initialization paths and not in setSessionConfigOption.

What changed

1) Fuzzy model resolution in setSessionConfigOption

  • Kept the existing exact-match validation path.
  • When configId === "model" and exact match fails, map config option entries to ModelInfo[] (value + displayName) and call resolveModelPreference(...).
  • If resolution succeeds, use the resolved canonical model ID (resolvedValue) for:
    • query.setModel(...)
    • session.configOptions current value update
    • response payload (configOptions)

2) Notification behavior unchanged by design

  • Intentionally did not add updateConfigOption(...) in setSessionConfigOption.
  • This preserves existing behavior/tests that verify no config_option_update notification is sent for this RPC (response already returns full configOptions).

Tests

Added focused coverage in src/tests/session-config-options.test.ts under describe("setSessionConfigOption"):

  • resolves model alias opus -> claude-opus-4-5
  • resolves model alias sonnet -> claude-sonnet-4-5
  • resolves display name Claude Sonnet -> claude-sonnet-4-5
  • still accepts exact model ID
  • still throws for invalid model value (gpt-4)

Behavior before / after

Before

  • setSessionConfigOption({ configId: "model", value: "opus" }) -> error

After

  • same call resolves to canonical ID and succeeds:
    • setModel("claude-opus-4-5")
    • returned configOptions.model.currentValue === "claude-opus-4-5"

Verification

  • npm run build
  • npm test ✅ (all tests passing)

@cla-bot
Copy link

cla-bot bot commented Mar 9, 2026

We require contributors to sign our Contributor License Agreement, and we don't have @mudrii 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'.

@mudrii mudrii force-pushed the fix/model-alias-resolution-in-config-option branch from e5bfa93 to ae45898 Compare March 9, 2026 19:20
@cla-bot
Copy link

cla-bot bot commented Mar 9, 2026

We require contributors to sign our Contributor License Agreement, and we don't have @mudrii 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'.

@mudrii mudrii changed the title fix: resolve model aliases in setSessionConfigOption fix: resolve model aliases in setSessionConfigOption (#401) Mar 9, 2026
@mudrii
Copy link
Author

mudrii commented Mar 9, 2026

We require contributors to sign our Contributor License Agreement, and we don't have @mudrii 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'.

signed

@cla-bot cla-bot bot added the cla-signed label Mar 9, 2026
@cla-bot
Copy link

cla-bot bot commented Mar 9, 2026

The cla-bot has been summoned, and re-checked this pull request!

)

setSessionConfigOption used exact-match validation for the model config
option. Model options are stored with full identifiers like
'claude-opus-4-6', but ACP clients (e.g. acpx 'set model opus') pass
human-friendly aliases like 'opus' or display names like 'Claude Opus'.
The exact match fails, returning 'Invalid value for config option'.

The fix falls back to the existing resolveModelPreference() function
when the exact match fails for model config options. This function
already implements fuzzy matching (exact, substring, tokenized) but
was only wired up for unstable_setSessionModel, not the config option
path.

Additionally, the resolved canonical model ID (not the caller-supplied
alias) is now used for all downstream operations (setModel call and
configOptions currentValue update), ensuring consistent state.
@mudrii mudrii force-pushed the fix/model-alias-resolution-in-config-option branch from ae45898 to caaae6c Compare March 14, 2026 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Claude ACP session-level 'set model opus' fails with Internal error on 0.21.0

1 participant