refactor: remove SubAgent tool, make Agent use subagentModel config

Match Claude Code's architecture: a single Agent tool with subagent_type
(Explore/Plan/Verification) that uses the subagentModel setting when
no explicit model override is provided. The separate SubAgent tool is
removed since it duplicated existing functionality.
This commit is contained in:
TheArchitectit 2026-04-28 12:34:34 -05:00
parent daffe1aeae
commit c9fa7ec145
3 changed files with 28 additions and 6 deletions

View File

@ -1131,17 +1131,24 @@ impl RuntimeConfig {
pub fn lsp_auto_start(&self) -> bool { pub fn lsp_auto_start(&self) -> bool {
self.feature_config.lsp_auto_start self.feature_config.lsp_auto_start
} }
<<<<<<< HEAD
======= =======
pub fn rules_import(&self) -> &RulesImportConfig { pub fn rules_import(&self) -> &RulesImportConfig {
&self.feature_config.rules_import &self.feature_config.rules_import
} }
>>>>>>> 22f948b7 (feat: project rules with .claw/rules/ and multi-framework auto-import) >>>>>>> 22f948b7 (feat: project rules with .claw/rules/ and multi-framework auto-import)
======= =======
=======
>>>>>>> 6b0af2bc (refactor: remove SubAgent tool, make Agent use subagentModel config)
#[must_use] #[must_use]
pub fn subagent_model(&self) -> Option<&str> { pub fn subagent_model(&self) -> Option<&str> {
self.feature_config.subagent_model.as_deref() self.feature_config.subagent_model.as_deref()
} }
<<<<<<< HEAD
>>>>>>> 7e7baeaa (feat: SubAgent tool for fast sub-agent delegation) >>>>>>> 7e7baeaa (feat: SubAgent tool for fast sub-agent delegation)
=======
>>>>>>> 6b0af2bc (refactor: remove SubAgent tool, make Agent use subagentModel config)
} }
impl RuntimeFeatureConfig { impl RuntimeFeatureConfig {

View File

@ -233,7 +233,11 @@ fn prompt_fast_model(
main_model: Option<&str>, main_model: Option<&str>,
) -> Result<Option<String>, Box<dyn std::error::Error>> { ) -> Result<Option<String>, Box<dyn std::error::Error>> {
println!(); println!();
<<<<<<< HEAD
println!(" \x1b[1mFast Model (for Agent subtasks)\x1b[0m"); println!(" \x1b[1mFast Model (for Agent subtasks)\x1b[0m");
=======
println!(" Fast Model (for Agent subtasks)");
>>>>>>> 6b0af2bc (refactor: remove SubAgent tool, make Agent use subagentModel config)
println!(" A smaller/cheaper model used by the Agent tool when spawning"); println!(" A smaller/cheaper model used by the Agent tool when spawning");
println!(" Explore, Plan, or Verification sub-agents. This saves tokens"); println!(" Explore, Plan, or Verification sub-agents. This saves tokens");
println!(" by using a fast model for information-gathering tasks."); println!(" by using a fast model for information-gathering tasks.");

View File

@ -675,7 +675,7 @@ pub fn mvp_tool_specs() -> Vec<ToolSpec> {
}, },
ToolSpec { ToolSpec {
name: "Agent", name: "Agent",
description: "Launch a background agent task that runs asynchronously. For synchronous read-only exploration, use SubAgent instead. Agent is for long-running background work that should not block the conversation.", description: "Launch a specialized agent task. Use subagent_type to select the agent role: Explore (read-only search), Plan (explore + todo), Verification (explore + bash + todo), or general-purpose (full access). The agent uses subagentModel from settings if set, otherwise the default model.",
input_schema: json!({ input_schema: json!({
"type": "object", "type": "object",
"properties": { "properties": {
@ -4493,11 +4493,22 @@ fn build_agent_system_prompt(subagent_type: &str, model: &str) -> Result<Vec<Str
} }
fn resolve_agent_model(model: Option<&str>) -> String { fn resolve_agent_model(model: Option<&str>) -> String {
model if let Some(m) = model.map(str::trim).filter(|m| !m.is_empty()) {
.map(str::trim) return m.to_string();
.filter(|model| !model.is_empty()) }
.unwrap_or(DEFAULT_AGENT_MODEL) if let Some(fast) = load_subagent_model_from_config() {
.to_string() return fast;
}
DEFAULT_AGENT_MODEL.to_string()
}
fn load_subagent_model_from_config() -> Option<String> {
std::env::current_dir().ok().and_then(|cwd| {
ConfigLoader::default_for(&cwd)
.load()
.ok()
.and_then(|config| config.subagent_model().map(|m| m.to_string()))
})
} }
fn allowed_tools_for_subagent(subagent_type: &str) -> BTreeSet<String> { fn allowed_tools_for_subagent(subagent_type: &str) -> BTreeSet<String> {