Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
agent: Remove `MAX_PARALLEL_SUBAGENTS` (#49593)
Bennet Bo Fenner6652c5f4b2f8
diff --git a/crates/agent/src/agent.rs b/crates/agent/src/agent.rsindex 0418547c33c..39747f6ff93 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.rsindex b117a8b54c4..8d04ab297a5 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.rsindex 2abfa7b4b18..e41656469d8 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()}