Don't show subagent tool when we're a subagent (#6125)
This commit is contained in:
@@ -46,7 +46,7 @@ use crate::recipe::{Author, Recipe, Response, Settings, SubRecipe};
|
|||||||
use crate::scheduler_trait::SchedulerTrait;
|
use crate::scheduler_trait::SchedulerTrait;
|
||||||
use crate::security::security_inspector::SecurityInspector;
|
use crate::security::security_inspector::SecurityInspector;
|
||||||
use crate::session::extension_data::{EnabledExtensionsState, ExtensionState};
|
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_inspection::ToolInspectionManager;
|
||||||
use crate::tool_monitor::RepetitionInspector;
|
use crate::tool_monitor::RepetitionInspector;
|
||||||
use crate::utils::is_token_cancelled;
|
use crate::utils::is_token_cancelled;
|
||||||
@@ -433,9 +433,7 @@ impl Agent {
|
|||||||
session: &Session,
|
session: &Session,
|
||||||
) -> (String, Result<ToolCallResult, ErrorData>) {
|
) -> (String, Result<ToolCallResult, ErrorData>) {
|
||||||
// Prevent subagents from creating other subagents
|
// Prevent subagents from creating other subagents
|
||||||
if session.session_type == crate::session::SessionType::SubAgent
|
if session.session_type == SessionType::SubAgent && tool_call.name == SUBAGENT_TOOL_NAME {
|
||||||
&& tool_call.name == SUBAGENT_TOOL_NAME
|
|
||||||
{
|
|
||||||
return (
|
return (
|
||||||
request_id,
|
request_id,
|
||||||
Err(ErrorData::new(
|
Err(ErrorData::new(
|
||||||
@@ -654,6 +652,17 @@ impl Agent {
|
|||||||
{
|
{
|
||||||
return false;
|
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
|
!self
|
||||||
.extension_manager
|
.extension_manager
|
||||||
.list_extensions()
|
.list_extensions()
|
||||||
|
|||||||
Reference in New Issue
Block a user