diff --git a/crates/goose/src/agents/prompt_manager.rs b/crates/goose/src/agents/prompt_manager.rs index 87c3bbb938..6794806853 100644 --- a/crates/goose/src/agents/prompt_manager.rs +++ b/crates/goose/src/agents/prompt_manager.rs @@ -113,6 +113,12 @@ impl PromptManager { Value::String(suggest_disable_extensions_prompt.to_string()), ); + // Add the mode to the context for conditional rendering + let config = Config::global(); + let goose_mode = config.get_param("GOOSE_MODE").unwrap_or("auto".to_string()); + context.insert("goose_mode", Value::String(goose_mode.clone())); + context.insert("is_autonomous", Value::Bool(goose_mode == "auto")); + // First check the global store, and only if it's not available, fall back to the provided model_name let model_to_use: Option = get_current_model().or_else(|| model_name.map(|s| s.to_string())); @@ -139,8 +145,6 @@ impl PromptManager { }; let mut system_prompt_extras = self.system_prompt_extras.clone(); - let config = Config::global(); - let goose_mode = config.get_param("GOOSE_MODE").unwrap_or("auto".to_string()); if goose_mode == "chat" { system_prompt_extras.push( "Right now you are in the chat only mode, no access to any tool use and system." diff --git a/crates/goose/src/agents/reply_parts.rs b/crates/goose/src/agents/reply_parts.rs index c4b7b34d1b..c1a9a982e6 100644 --- a/crates/goose/src/agents/reply_parts.rs +++ b/crates/goose/src/agents/reply_parts.rs @@ -40,9 +40,20 @@ impl Agent { // Get tools from extension manager let mut tools = self.list_tools_for_router().await; + let config = crate::config::Config::global(); + let is_autonomous = config.get_param("GOOSE_MODE").unwrap_or("auto".to_string()) == "auto"; + // If router is disabled and no tools were returned, fall back to regular tools if !router_enabled && tools.is_empty() { + // Get all tools but filter out subagent tools if not in autonomous mode tools = self.list_tools(None).await; + if !is_autonomous { + // Filter out subagent-related tools + tools.retain(|tool| { + tool.name != crate::agents::subagent_execution_tool::subagent_execute_task_tool::SUBAGENT_EXECUTE_TASK_TOOL_NAME + && tool.name != crate::agents::recipe_tools::dynamic_task_tools::DYNAMIC_TASK_TOOL_NAME_PREFIX + }); + } } // Add frontend tools diff --git a/crates/goose/src/agents/todo_extension.rs b/crates/goose/src/agents/todo_extension.rs index ac29a96c6e..5bb6d9eae5 100644 --- a/crates/goose/src/agents/todo_extension.rs +++ b/crates/goose/src/agents/todo_extension.rs @@ -62,8 +62,8 @@ impl TodoClient { - [ ] Implement feature X - [ ] Update API - [ ] Write tests - - [ ] Run tests (subagent in parallel) - - [ ] Run lint (subagent in parallel) + - [ ] Run tests + - [ ] Run lint - [ ] Blocked: waiting on credentials "#}.to_string()), }; diff --git a/crates/goose/src/prompts/system.md b/crates/goose/src/prompts/system.md index d5200172c4..f8bda7cd96 100644 --- a/crates/goose/src/prompts/system.md +++ b/crates/goose/src/prompts/system.md @@ -48,7 +48,7 @@ No extensions are defined. You should let the user know that they should add ext {% endif %} {{tool_selection_strategy}} - +{% if is_autonomous %} # sub agents Execute self contained tasks where step-by-step visibility is not important through subagents. @@ -60,6 +60,7 @@ Execute self contained tasks where step-by-step visibility is not important thro - Provide all needed context — subagents cannot see your context - Use extension filters to limit resource access - Use return_last_only when only a summary or simple answer is required — inform subagent of this choice. +{% endif %} # Response Guidelines