CodeWhale
CodeWhale copied to clipboard
Bug: Profile切换时provider配置被环境变量覆盖
Bug 描述
当使用 /profile 命令切换配置profile时,即使profile中正确配置了 provider = "openrouter"(或其他非deepseek provider),切换后显示的provider仍然是 deepseek,而不是profile中配置的provider。
复现步骤
- 在
config.toml中配置一个profile:
[profiles.google]
provider = "openrouter"
default_text_model = "deepseek-v4-pro"\n```
2. 启动 codewhale(默认使用 deepseek provider)
3. 使用 `/profile google` 命令切换到 google profile
4. 观察系统消息显示:`Provider: deepseek`,应该是 `openrouter`
## 根本原因
在 `crates/cli/src/lib.rs` 第1432行,启动时CLI会设置 `DEEPSEEK_PROVIDER` 环境变量。当切换profile时,`apply_env_overrides` 函数会读取这个环境变量并覆盖profile中配置的provider。
```rust
fn apply_env_overrides(config: &mut Config) {
if let Ok(value) = std::env::var("DEEPSEEK_PROVIDER") {
config.provider = Some(value); // 这里覆盖了profile的配置!
}
}
预期行为
切换profile后,应该显示profile中配置的provider,而不是被启动时的环境变量覆盖。