@@ -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<Thread>, cx: &mut Context<Self>) {
+ 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;