From 1a3ef13690b91c691c59889b3d58d4afd8ef8f5f Mon Sep 17 00:00:00 2001 From: Jack Amadeo Date: Mon, 15 Dec 2025 15:34:59 -0500 Subject: [PATCH] Don't show subagent tool when we're a subagent --- crates/goose/src/agents/agent.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/crates/goose/src/agents/agent.rs b/crates/goose/src/agents/agent.rs index 6715929ba12e..15462c8a71ea 100644 --- a/crates/goose/src/agents/agent.rs +++ b/crates/goose/src/agents/agent.rs @@ -46,7 +46,7 @@ use crate::recipe::{Author, Recipe, Response, Settings, SubRecipe}; use crate::scheduler_trait::SchedulerTrait; use crate::security::security_inspector::SecurityInspector; use crate::session::extension_data::{EnabledExtensionsState, ExtensionState}; -use crate::session::{Session, SessionManager}; +use crate::session::{Session, SessionManager, SessionType}; use crate::tool_inspection::ToolInspectionManager; use crate::tool_monitor::RepetitionInspector; use crate::utils::is_token_cancelled; @@ -433,9 +433,7 @@ impl Agent { session: &Session, ) -> (String, Result) { // Prevent subagents from creating other subagents - if session.session_type == crate::session::SessionType::SubAgent - && tool_call.name == SUBAGENT_TOOL_NAME - { + if session.session_type == SessionType::SubAgent && tool_call.name == SUBAGENT_TOOL_NAME { return ( request_id, Err(ErrorData::new( @@ -654,6 +652,17 @@ impl Agent { { return false; } + if let Some(ref session_id) = self.extension_manager.get_context().await.session_id { + if matches!( + SessionManager::get_session(session_id, false) + .await + .ok() + .map(|session| session.session_type), + Some(SessionType::SubAgent) + ) { + return false; + } + } !self .extension_manager .list_extensions()