CodeWhale
CodeWhale copied to clipboard
Bug: Provider config overridden by environment variable when switching profiles
Bug Description
When using the /profile command to switch configuration profiles, even if the profile correctly configures provider = "openrouter" (or any non-deepseek provider), the provider displayed after switching remains deepseek instead of the provider configured in the profile.
Steps to Reproduce
- Configure a profile in
config.toml:
[profiles.google]
provider = "openrouter"
default_text_model = "deepseek-v4-pro"
- Start codewhale (default uses deepseek provider)
- Use
/profile googlecommand to switch to google profile - Observe the system message shows:
Provider: deepseek, it should beopenrouter
Root Cause Analysis
In crates/cli/src/lib.rs line 1432, when starting up, the CLI sets the DEEPSEEK_PROVIDER environment variable. When switching profiles, the apply_env_overrides function reads this environment variable and overrides the provider configured in the profile.
fn apply_env_overrides(config: &mut Config) {
if let Ok(value) = std::env::var("DEEPSEEK_PROVIDER") {
config.provider = Some(value); // This overrides the profile configuration!
}
}
Expected Behavior
After switching profiles, the provider configured in the profile should be displayed, not overridden by the environment variable set at startup.