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 <crush@charm.land>
This commit is contained in:
parent
5b707a2fd6
commit
0d833fe4f2
|
|
@ -1525,6 +1525,7 @@ fn execute_tool_with_enforcer(
|
|||
.and_then(run_worker_observe_completion),
|
||||
"TeamCreate" => from_value::<TeamCreateInput>(input).and_then(run_team_create),
|
||||
"TeamDelete" => from_value::<TeamDeleteInput>(input).and_then(run_team_delete),
|
||||
"AgentMessage" => from_value::<AgentMessageInput>(input).and_then(run_agent_message),
|
||||
"CronCreate" => from_value::<CronCreateInput>(input).and_then(run_cron_create),
|
||||
"CronDelete" => from_value::<CronDeleteInput>(input).and_then(run_cron_delete),
|
||||
"CronList" => run_cron_list(input.clone()),
|
||||
|
|
@ -4728,21 +4729,36 @@ fn build_agent_system_prompt(subagent_type: &str, model: &str) -> Result<Vec<Str
|
|||
|
||||
fn resolve_agent_model(model: Option<&str>) -> String {
|
||||
if let Some(m) = model.map(str::trim).filter(|m| !m.is_empty()) {
|
||||
eprintln!("[agent] resolve_agent_model: using explicit model={m}");
|
||||
return m.to_string();
|
||||
}
|
||||
if let Some(fast) = load_subagent_model_from_config() {
|
||||
eprintln!("[agent] resolve_agent_model: using subagentModel from config={fast}");
|
||||
return fast;
|
||||
}
|
||||
eprintln!("[agent] resolve_agent_model: falling back to DEFAULT_AGENT_MODEL={DEFAULT_AGENT_MODEL}");
|
||||
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()))
|
||||
})
|
||||
let cwd = match std::env::current_dir() {
|
||||
Ok(p) => p,
|
||||
Err(e) => {
|
||||
eprintln!("[agent] load_subagent_model_from_config: current_dir() failed: {e}");
|
||||
return None;
|
||||
}
|
||||
};
|
||||
match ConfigLoader::default_for(&cwd).load() {
|
||||
Ok(config) => {
|
||||
let result = config.subagent_model().map(|m| m.to_string());
|
||||
eprintln!("[agent] load_subagent_model_from_config: cwd={} subagent_model={result:?}", cwd.display());
|
||||
result
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("[agent] load_subagent_model_from_config: ConfigLoader::load() failed: {e}");
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn allowed_tools_for_subagent(subagent_type: &str) -> BTreeSet<String> {
|
||||
|
|
@ -4755,6 +4771,7 @@ fn allowed_tools_for_subagent(subagent_type: &str) -> BTreeSet<String> {
|
|||
"WebSearch",
|
||||
"ToolSearch",
|
||||
"Skill",
|
||||
"AgentMessage",
|
||||
"StructuredOutput",
|
||||
],
|
||||
"Plan" => vec![
|
||||
|
|
@ -4766,6 +4783,7 @@ fn allowed_tools_for_subagent(subagent_type: &str) -> BTreeSet<String> {
|
|||
"ToolSearch",
|
||||
"Skill",
|
||||
"TodoWrite",
|
||||
"AgentMessage",
|
||||
"StructuredOutput",
|
||||
"SendUserMessage",
|
||||
],
|
||||
|
|
@ -4778,6 +4796,7 @@ fn allowed_tools_for_subagent(subagent_type: &str) -> BTreeSet<String> {
|
|||
"WebSearch",
|
||||
"ToolSearch",
|
||||
"TodoWrite",
|
||||
"AgentMessage",
|
||||
"StructuredOutput",
|
||||
"SendUserMessage",
|
||||
"PowerShell",
|
||||
|
|
@ -4816,6 +4835,7 @@ fn allowed_tools_for_subagent(subagent_type: &str) -> BTreeSet<String> {
|
|||
"ToolSearch",
|
||||
"NotebookEdit",
|
||||
"Sleep",
|
||||
"AgentMessage",
|
||||
"SendUserMessage",
|
||||
"Config",
|
||||
"StructuredOutput",
|
||||
|
|
|
|||
Loading…
Reference in New Issue