fix: disallow runaway subagent chains (#5659)
This commit is contained in:
@@ -412,6 +412,20 @@ impl Agent {
|
|||||||
cancellation_token: Option<CancellationToken>,
|
cancellation_token: Option<CancellationToken>,
|
||||||
session: &Session,
|
session: &Session,
|
||||||
) -> (String, Result<ToolCallResult, ErrorData>) {
|
) -> (String, Result<ToolCallResult, ErrorData>) {
|
||||||
|
if session.session_type == crate::session::SessionType::SubAgent
|
||||||
|
&& (tool_call.name == DYNAMIC_TASK_TOOL_NAME_PREFIX
|
||||||
|
|| tool_call.name == SUBAGENT_EXECUTE_TASK_TOOL_NAME)
|
||||||
|
{
|
||||||
|
return (
|
||||||
|
request_id,
|
||||||
|
Err(ErrorData::new(
|
||||||
|
ErrorCode::INVALID_REQUEST,
|
||||||
|
"Subagents cannot create other subagents".to_string(),
|
||||||
|
None,
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if tool_call.name == PLATFORM_MANAGE_SCHEDULE_TOOL_NAME {
|
if tool_call.name == PLATFORM_MANAGE_SCHEDULE_TOOL_NAME {
|
||||||
let arguments = tool_call
|
let arguments = tool_call
|
||||||
.arguments
|
.arguments
|
||||||
|
|||||||
Reference in New Issue
Block a user