Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions crates/goose/src/agents/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -433,9 +433,7 @@ impl Agent {
session: &Session,
) -> (String, Result<ToolCallResult, ErrorData>) {
// 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(
Expand Down Expand Up @@ -654,6 +652,17 @@ impl Agent {
{
return false;
}
if let Some(ref session_id) = self.extension_manager.get_context().await.session_id {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DOsinga I'm reading the session type here by way of the extension manager + platform extension context, which feels a bit roundabout but is also currently the most direct way.

Do we want to tie an agent to a session more directly? we of course map session id to agent, but the agent doesn't necessarily know its session

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the long run agents should be per-session right? with multiple sessions being possible per app instance and those two concepts coupled.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah we map session ID to agent right now, I'm just thinking should we keep a pointer in the other direction too

if matches!(
SessionManager::get_session(session_id, false)
.await
.ok()
.map(|session| session.session_type),
Some(SessionType::SubAgent)
) {
return false;
}
}
Comment on lines +655 to +665
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SessionManager::get_session() call could fail silently with .ok(), which would cause subagent tools to be shown even when there's an error fetching the session. Consider logging the error case to help diagnose issues where the subagent tool incorrectly appears.

Copilot uses AI. Check for mistakes.
!self
.extension_manager
.list_extensions()
Expand Down
Loading