fix: disallow runaway subagent chains (#5659)

This commit is contained in:
Alex Hancock
2025-11-10 16:46:53 -05:00
committed by GitHub
parent 9291e721d7
commit d3f723d76d
+14
View File
@@ -412,6 +412,20 @@ impl Agent {
cancellation_token: Option<CancellationToken>,
session: &Session,
) -> (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 {
let arguments = tool_call
.arguments