Skip to content

Commit d01266a

Browse files
committed
fix(delegate): respect chat.defaultAgent setting when no agent is specified
When the delegate tool is invoked without an explicit agent name, it was unconditionally falling back to the hardcoded DEFAULT_AGENT_NAME ("q_cli_default"), ignoring the user's chat.defaultAgent setting. Fix the fallback chain to: 1. Use the explicitly provided agent name (unchanged) 2. Fall back to chat.defaultAgent setting if set 3. Fall back to DEFAULT_AGENT_NAME as last resort Fixes #3174
1 parent e14ea18 commit d01266a

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

crates/chat-cli/src/cli/chat/tools/delegate.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ use crate::cli::{
3636
Agent,
3737
DEFAULT_AGENT_NAME,
3838
};
39+
use crate::database::settings::Setting;
3940
use crate::os::Os;
4041
use crate::theme::StyledText;
4142
use crate::util::env_var::get_all_env_vars;
@@ -99,7 +100,14 @@ impl Delegate {
99100
.as_ref()
100101
.ok_or(eyre::eyre!("Task description is required for launch operation"))?;
101102

102-
let agent_name = self.agent.as_deref().unwrap_or(DEFAULT_AGENT_NAME);
103+
// Respect chat.defaultAgent setting before falling back to the hardcoded default.
104+
// See: #3174
105+
let configured_default = os.database.settings.get_string(Setting::ChatDefaultAgent);
106+
let agent_name = self
107+
.agent
108+
.as_deref()
109+
.or(configured_default.as_deref())
110+
.unwrap_or(DEFAULT_AGENT_NAME);
103111

104112
launch_agent(os, agent_name, agents, task).await?
105113
},

0 commit comments

Comments
 (0)