fix(desktop): apply the configured model to Claude Code agents via ANTHROPIC_MODEL
Fixes #2692
Problem
Picking a model for a Claude Code agent in the desktop UI persists the selection but never applies it. The claude entry in KNOWN_ACP_RUNTIMES declares model_env_var: None and supports_acp_model_switching: false, so runtime_metadata_env_vars has 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.- Tests: pin the claude runtime shape (model env declared, provider locked), the derived-key classification (including case-insensitivity), and the claude-shaped
runtime_metadata_env_varsinjection. The tests intentionally assert the literal string so the const's value itself is pinned.
Notes for reviewers
- Users who worked around this by setting
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. - Local
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