Disallow subagents with no extensions (#5825)
This commit is contained in:
@@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user