Disallow subagents with no extensions (#5825)

This commit is contained in:
Jack Amadeo
2025-12-15 12:45:42 -05:00
committed by GitHub
parent 6d5bf36451
commit 9fdb0356f0
5 changed files with 54 additions and 46 deletions
+31 -7
View File
@@ -640,6 +640,28 @@ impl Agent {
Ok(())
}
pub async fn subagents_enabled(&self) -> bool {
let config = crate::config::Config::global();
let is_autonomous = config.get_goose_mode().unwrap_or(GooseMode::Auto) == GooseMode::Auto;
if !is_autonomous {
return false;
}
if self
.provider()
.await
.map(|provider| provider.get_active_model_name().starts_with("gemini"))
.unwrap_or(false)
{
return false;
}
!self
.extension_manager
.list_extensions()
.await
.map(|ext| ext.is_empty())
.unwrap_or(true)
}
pub async fn list_tools(&self, extension_name: Option<String>) -> Vec<Tool> {
let mut prefixed_tools = self
.extension_manager
@@ -647,8 +669,9 @@ impl Agent {
.await
.unwrap_or_default();
let subagents_enabled = self.subagents_enabled().await;
if extension_name.is_none() || extension_name.as_deref() == Some("platform") {
prefixed_tools.extend([platform_tools::manage_schedule_tool()]);
prefixed_tools.push(platform_tools::manage_schedule_tool());
}
if extension_name.is_none() {
@@ -656,10 +679,11 @@ impl Agent {
prefixed_tools.push(final_output_tool.tool());
}
// Add the unified subagent tool
let sub_recipes = self.sub_recipes.lock().await;
let sub_recipes_vec: Vec<_> = sub_recipes.values().cloned().collect();
prefixed_tools.push(create_subagent_tool(&sub_recipes_vec));
if subagents_enabled {
let sub_recipes = self.sub_recipes.lock().await;
let sub_recipes_vec: Vec<_> = sub_recipes.values().cloned().collect();
prefixed_tools.push(create_subagent_tool(&sub_recipes_vec));
}
}
prefixed_tools
@@ -1374,7 +1398,7 @@ impl Agent {
let prompt_manager = self.prompt_manager.lock().await;
let system_prompt = prompt_manager
.builder(model_name)
.builder()
.with_extensions(extensions_info.into_iter())
.with_frontend_instructions(self.frontend_instructions.lock().await.clone())
.with_extension_and_tool_counts(extension_count, tool_count)
@@ -1594,7 +1618,7 @@ mod tests {
);
let prompt_manager = agent.prompt_manager.lock().await;
let system_prompt = prompt_manager.builder("gpt-4o").build();
let system_prompt = prompt_manager.builder().build();
let final_output_tool_ref = agent.final_output_tool.lock().await;
let final_output_tool_system_prompt =