diff --git a/crates/agent/src/agent.rs b/crates/agent/src/agent.rs index 0418547c33c0e891a4d703d0c92e006e475bef07..39747f6ff93b7378bbff375bd001cf1ac1b20658 100644 --- a/crates/agent/src/agent.rs +++ b/crates/agent/src/agent.rs @@ -1603,14 +1603,6 @@ impl NativeThreadEnvironment { )); } - let running_count = parent_thread.running_subagent_count(); - if running_count >= MAX_PARALLEL_SUBAGENTS { - return Err(anyhow!( - "Maximum parallel subagents ({}) reached. Wait for existing subagents to complete.", - MAX_PARALLEL_SUBAGENTS - )); - } - let allowed_tools = match allowed_tools { Some(tools) => { let parent_tool_names: std::collections::HashSet<&str> = diff --git a/crates/agent/src/tests/mod.rs b/crates/agent/src/tests/mod.rs index b117a8b54c43a8157641077958c6e197caff8e53..8d04ab297a5559acaf7c6743a9b416d17bd395fb 100644 --- a/crates/agent/src/tests/mod.rs +++ b/crates/agent/src/tests/mod.rs @@ -4818,85 +4818,6 @@ async fn test_parent_cancel_stops_subagent(cx: &mut TestAppContext) { }); } -#[gpui::test] -async fn test_thread_environment_max_parallel_subagents_enforced(cx: &mut TestAppContext) { - init_test(cx); - always_allow_tools(cx); - - cx.update(|cx| { - cx.update_flags(true, vec!["subagents".to_string()]); - }); - - let fs = FakeFs::new(cx.executor()); - fs.insert_tree(path!("/test"), json!({})).await; - let project = Project::test(fs.clone(), [path!("/test").as_ref()], cx).await; - let project_context = cx.new(|_cx| ProjectContext::default()); - let context_server_store = project.read_with(cx, |project, _| project.context_server_store()); - let context_server_registry = - cx.new(|cx| ContextServerRegistry::new(context_server_store.clone(), cx)); - cx.update(LanguageModelRegistry::test); - let model = Arc::new(FakeLanguageModel::default()); - let thread_store = cx.new(|cx| ThreadStore::new(cx)); - let native_agent = NativeAgent::new( - project.clone(), - thread_store, - Templates::new(), - None, - fs, - &mut cx.to_async(), - ) - .await - .unwrap(); - let parent_thread = cx.new(|cx| { - Thread::new( - project.clone(), - project_context, - context_server_registry, - Templates::new(), - Some(model.clone()), - cx, - ) - }); - - let mut handles = Vec::new(); - for _ in 0..MAX_PARALLEL_SUBAGENTS { - let handle = cx - .update(|cx| { - NativeThreadEnvironment::create_subagent_thread( - native_agent.downgrade(), - parent_thread.clone(), - "some title".to_string(), - "some task".to_string(), - None, - None, - cx, - ) - }) - .expect("Expected to be able to create subagent thread"); - handles.push(handle); - } - - let result = cx.update(|cx| { - NativeThreadEnvironment::create_subagent_thread( - native_agent.downgrade(), - parent_thread.clone(), - "some title".to_string(), - "some task".to_string(), - None, - None, - cx, - ) - }); - assert!(result.is_err()); - assert_eq!( - result.err().unwrap().to_string(), - format!( - "Maximum parallel subagents ({}) reached. Wait for existing subagents to complete.", - MAX_PARALLEL_SUBAGENTS - ) - ); -} - #[gpui::test] async fn test_subagent_tool_returns_summary(cx: &mut TestAppContext) { init_test(cx); diff --git a/crates/agent/src/thread.rs b/crates/agent/src/thread.rs index 2abfa7b4b182a74d32adbb4acf181855e0a6659b..e41656469d8213f9a0a38a03aafc533d3eadaa1f 100644 --- a/crates/agent/src/thread.rs +++ b/crates/agent/src/thread.rs @@ -61,7 +61,6 @@ use uuid::Uuid; const TOOL_CANCELED_MESSAGE: &str = "Tool canceled by user"; pub const MAX_TOOL_NAME_LENGTH: usize = 64; pub const MAX_SUBAGENT_DEPTH: u8 = 4; -pub const MAX_PARALLEL_SUBAGENTS: usize = 8; /// Context passed to a subagent thread for lifecycle management #[derive(Clone, Debug, Serialize, Deserialize)] @@ -2616,13 +2615,6 @@ impl Thread { .collect() } - pub fn running_subagent_count(&self) -> usize { - self.running_subagents - .iter() - .filter(|s| s.upgrade().is_some()) - .count() - } - pub fn is_subagent(&self) -> bool { self.subagent_context.is_some() }