Skip to content

Commit acc5581

Browse files
alexhancockjamadeo
authored andcommitted
fix: disallow runaway subagent chains (#5659)
1 parent faac835 commit acc5581

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

crates/goose/src/agents/agent.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,20 @@ impl Agent {
394394
cancellation_token: Option<CancellationToken>,
395395
session: &Session,
396396
) -> (String, Result<ToolCallResult, ErrorData>) {
397+
if session.session_type == crate::session::SessionType::SubAgent
398+
&& (tool_call.name == DYNAMIC_TASK_TOOL_NAME_PREFIX
399+
|| tool_call.name == SUBAGENT_EXECUTE_TASK_TOOL_NAME)
400+
{
401+
return (
402+
request_id,
403+
Err(ErrorData::new(
404+
ErrorCode::INVALID_REQUEST,
405+
"Subagents cannot create other subagents".to_string(),
406+
None,
407+
)),
408+
);
409+
}
410+
397411
if tool_call.name == PLATFORM_MANAGE_SCHEDULE_TOOL_NAME {
398412
let arguments = tool_call
399413
.arguments

0 commit comments

Comments
 (0)