fix(desktop): apply the configured model to Claude Code agents via ANTHROPIC_MODEL - #2695
Closed
bosoud wants to merge 1 commit into
Closed
fix(desktop): apply the configured model to Claude Code agents via ANTHROPIC_MODEL#2695bosoud wants to merge 1 commit into
bosoud wants to merge 1 commit into
Conversation
…THROPIC_MODEL The claude runtime entry declared model_env_var: None, so the model picked in the agent UI was persisted but never reached the spawned session — Claude Code agents always ran on the user's global default, with no error or warning. Goose (GOOSE_MODEL) and Buzz Agent (BUZZ_AGENT_MODEL) already have this channel; claude was the only harness with a model picker but no application path. Declare ANTHROPIC_MODEL as the claude runtime's model env var — the override the Claude CLI honors (verified: ANTHROPIC_MODEL=x claude --print reports x), inherited by the adapter's child process, and the same key readiness.rs already maps to the anthropic provider. Provider stays locked, so runtime_metadata_env_vars injects the model only. Add ANTHROPIC_MODEL to DERIVED_PROVIDER_MODEL_ENV_KEYS so a stale persisted copy cannot shadow the structured model field after a UI edit — the same treatment the other derived model keys get. Fixes block#2692 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CqMxL1inNtU7icywZxbrGY Signed-off-by: Abdulwahab <bosoud@me.com>
3 tasks
This was referenced Jul 25, 2026
Author
|
Closing in favor of #2701, which now carries the shared-const approach and the runtime-shape regression test. Thanks for folding those in @Chessing234 — one PR with everything beats two with halves. (For anyone landing here from #2692: the fix ships via #2701.) |
wpfleger96
pushed a commit
that referenced
this pull request
Jul 28, 2026
…itch (#2795) ## Summary Fixes #2794. Related: #2692. `resolve_model_switch_method()` reads the `configId` key from each `session/new` `configOptions` entry and skips entries that lack it. `claude-agent-acp` (v0.61.0) keys its entries with `id`, so every model-category entry was skipped, the desired model never matched, and Claude Code sessions fell back to the CLI default from the user's `~/.claude/settings.json`. The only trace was a `pool::model` WARN that never reaches the per-agent log files. This is the ACP-side half of the symptom reported in #2692. The open desktop-side PRs (#2695, #2701, #2696) inject `ANTHROPIC_MODEL` at spawn, which masks the problem for spawn-time selection but leaves the config-option switch path broken. ## Changes - `resolve_model_switch_method()` accepts either `configId` or `id` when extracting the config id. The set request is unchanged: the ACP SDK schema takes `configId` as the request param and the adapter resolves it against its `id`-keyed entries, so only the read side needed fixing. - Regression test with an `id`-keyed `configOptions` payload mirroring the real adapter response (including `models: null`, so the unstable fallback path cannot rescue the match). - Doc comment on `extract_model_config_options()` notes the key drift. ## Testing `cargo test -p buzz-acp --lib`: 599 passed, 0 failed. The new test fails on main and passes with this change. Verified against the real adapter: a stdio JSON-RPC probe of the bundled `claude-agent-acp` 0.61.0 confirms `session/new` returns `id`-keyed config options with `opus[1m]` present as a value, and the SDK's `SetSessionConfigOptionRequest` schema accepts `{sessionId, configId, value}` as sent by `session_set_config_option()`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: chillerno1 <gh.chiller@pm.me> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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.
Fixes #2692
Problem
Picking a model for a Claude Code agent in the desktop UI persists the selection but never applies it. The
claudeentry inKNOWN_ACP_RUNTIMESdeclaresmodel_env_var: Noneandsupports_acp_model_switching: false, soruntime_metadata_env_varshas no channel to carry the saved model into the spawned session — the agent silently runs on the user's global Claude Code default. Goose (GOOSE_MODEL) and Buzz Agent (BUZZ_AGENT_MODEL) both have this channel; claude was the only harness with a model picker but no application path behind it.Observed in the wild: a stock agent set to Sonnet answering as
claude-fable-5, across restarts, with no error anywhere.Changes
discovery.rs: the claude runtime declaresmodel_env_var: Some(ANTHROPIC_MODEL_ENV_KEY). The Claude CLI honorsANTHROPIC_MODELas a session model override (verified:ANTHROPIC_MODEL=claude-sonnet-5 claude --print "<model id?>"→claude-sonnet-5), and the ACP adapter's childclaudeprocess inherits the spawn env.provider_lockedstaystrue, so only the model is injected — no provider env is written for this harness.env_vars.rs: newANTHROPIC_MODEL_ENV_KEYconst as the single source of truth for the key — referenced by the runtime entry, theDERIVED_PROVIDER_MODEL_ENV_KEYSlist (so a stale persisted copy can't shadow the structured model field after a UI edit, same treatment as the other derived keys), and the readiness provider-model mapping inreadiness.rs, which already used the literal"ANTHROPIC_MODEL"for the anthropic provider. Three call sites, one definition, no drift.runtime_metadata_env_varsinjection. The tests intentionally assert the literal string so the const's value itself is pinned.Notes for reviewers
ANTHROPIC_MODELmanually in the agent's env vars: on the next provider/model edit the derived-key rule strips the manual copy, and the structured field takes over — which is the intended convergence.cargo testfordesktop/src-tauricould not be run on my machine (Intel mac —sherpa-onnx-syshas no usable static lib here, unrelated to this change); CI's Desktop Core job is the authoritative check for this PR.🤖 Generated with Claude Code
https://claude.ai/code/session_01CqMxL1inNtU7icywZxbrGY