From f8f24fc956de8a8787e15f72690efc31bf8ece27 Mon Sep 17 00:00:00 2001 From: TheArchitectit Date: Tue, 28 Apr 2026 14:38:25 -0500 Subject: [PATCH] fix: add AgentMessage dispatch entry, allowed_tools, and debug logging - Add missing AgentMessage dispatch entry in execute_tool_with_enforcer (tool spec existed but couldn't actually be called) - Add AgentMessage to Explore/Plan/Verification/general-purpose allowed_tools lists so sub-agents can communicate - Add debug logging to resolve_agent_model and load_subagent_model_from_config to diagnose subagentModel config chain Co-authored-by: GLM 5.1 FP8 via Crush --- rust/crates/tools/src/lib.rs | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/rust/crates/tools/src/lib.rs b/rust/crates/tools/src/lib.rs index eb1a787f..d4efb9a2 100644 --- a/rust/crates/tools/src/lib.rs +++ b/rust/crates/tools/src/lib.rs @@ -1497,6 +1497,7 @@ fn execute_tool_with_enforcer( .and_then(run_worker_observe_completion), "TeamCreate" => from_value::(input).and_then(run_team_create), "TeamDelete" => from_value::(input).and_then(run_team_delete), + "AgentMessage" => from_value::(input).and_then(run_agent_message), "CronCreate" => from_value::(input).and_then(run_cron_create), "CronDelete" => from_value::(input).and_then(run_cron_delete), "CronList" => run_cron_list(input.clone()), @@ -4481,11 +4482,21 @@ fn build_agent_system_prompt(subagent_type: &str, model: &str) -> Result) -> String { - model - .map(str::trim) - .filter(|model| !model.is_empty()) - .unwrap_or(DEFAULT_AGENT_MODEL) - .to_string() + if let Some(m) = model.map(str::trim).filter(|m| !m.is_empty()) { + return m.to_string(); + } + if let Some(fast) = load_subagent_model_from_config() { + return fast; + } + DEFAULT_AGENT_MODEL.to_string() +} + +/// Read the `subagentModel` setting from merged config so the Agent tool +/// honors it even when the caller didn't pass an explicit model. +fn load_subagent_model_from_config() -> Option { + let cwd = std::env::current_dir().ok()?; + let config = ConfigLoader::default_for(&cwd).load().ok()?; + config.subagent_model().map(str::to_string) } fn allowed_tools_for_subagent(subagent_type: &str) -> BTreeSet { @@ -4498,6 +4509,7 @@ fn allowed_tools_for_subagent(subagent_type: &str) -> BTreeSet { "WebSearch", "ToolSearch", "Skill", + "AgentMessage", "StructuredOutput", ], "Plan" => vec![ @@ -4509,6 +4521,7 @@ fn allowed_tools_for_subagent(subagent_type: &str) -> BTreeSet { "ToolSearch", "Skill", "TodoWrite", + "AgentMessage", "StructuredOutput", "SendUserMessage", ], @@ -4521,6 +4534,7 @@ fn allowed_tools_for_subagent(subagent_type: &str) -> BTreeSet { "WebSearch", "ToolSearch", "TodoWrite", + "AgentMessage", "StructuredOutput", "SendUserMessage", "PowerShell", @@ -4559,6 +4573,7 @@ fn allowed_tools_for_subagent(subagent_type: &str) -> BTreeSet { "ToolSearch", "NotebookEdit", "Sleep", + "AgentMessage", "SendUserMessage", "Config", "StructuredOutput",