From a43ee6b5f7d8153bb320e70d88866dad81b9e7cb Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 7 Apr 2026 21:14:36 -0600 Subject: [PATCH] Inherit parent thread settings when spawning subagents (#53328) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a subagent was spawned while the parent had runtime-modified settings (fast mode, thinking, etc.), the subagent would start with defaults from `AgentSettings` instead of inheriting the parent's current values. This adds `inherit_parent_settings` as a single place in `Thread::new_subagent` that copies all runtime-mutable settings from the parent: - `speed` - `thinking_enabled` - `thinking_effort` - `summarization_model` - `profile_id` These are the same properties that `set_*` methods already propagate to `running_subagents` — this fix ensures they're also inherited at creation time. cc @benbrandt Release Notes: - N/A --- crates/agent/src/thread.rs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/crates/agent/src/thread.rs b/crates/agent/src/thread.rs index ea342e8db4e4d97d5eccc849121cd0fd2e403017..220e9e6b30841da2e726cf5f53d0a6ea7d1624bb 100644 --- a/crates/agent/src/thread.rs +++ b/crates/agent/src/thread.rs @@ -999,6 +999,7 @@ impl Thread { parent_thread_id: parent_thread.read(cx).id().clone(), depth: parent_thread.read(cx).depth() + 1, }); + thread.inherit_parent_settings(parent_thread, cx); thread } @@ -1085,6 +1086,19 @@ impl Thread { } } + /// Copies runtime-mutable settings from the parent thread so that + /// subagents start with the same configuration the user selected. + /// Every property that `set_*` propagates to `running_subagents` + /// should be inherited here as well. + fn inherit_parent_settings(&mut self, parent_thread: &Entity, cx: &mut Context) { + let parent = parent_thread.read(cx); + self.speed = parent.speed; + self.thinking_enabled = parent.thinking_enabled; + self.thinking_effort = parent.thinking_effort.clone(); + self.summarization_model = parent.summarization_model.clone(); + self.profile_id = parent.profile_id.clone(); + } + pub fn id(&self) -> &acp::SessionId { &self.id } @@ -4267,6 +4281,30 @@ mod tests { }); } + #[gpui::test] + async fn test_subagent_inherits_settings_at_creation(cx: &mut TestAppContext) { + let (parent, _event_stream) = setup_thread_for_test(cx).await; + + cx.update(|cx| { + parent.update(cx, |thread, cx| { + thread.set_speed(Speed::Fast, cx); + thread.set_thinking_enabled(true, cx); + thread.set_thinking_effort(Some("high".to_string()), cx); + thread.set_profile(AgentProfileId("custom-profile".into()), cx); + }); + }); + + let subagents = setup_parent_with_subagents(cx, &parent, 1); + + cx.update(|cx| { + let sub = subagents[0].read(cx); + assert_eq!(sub.speed(), Some(Speed::Fast)); + assert!(sub.thinking_enabled()); + assert_eq!(sub.thinking_effort().map(|s| s.as_str()), Some("high")); + assert_eq!(sub.profile(), &AgentProfileId("custom-profile".into())); + }); + } + #[gpui::test] async fn test_set_speed_propagates_to_subagents(cx: &mut TestAppContext) { let (parent, _event_stream) = setup_thread_for_test(cx).await;