From 71866d6314674819a0e42df53a4c39f050639720 Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Fri, 28 Feb 2025 16:02:03 -0500 Subject: [PATCH] assistant2: Include some text in the tool result messages (#25825) This PR makes it so we include some textual content in the user messages that as used to send up tool results. I observed that when sending up the tool results with no text, it would lead the model to start replying with no text, which would then result in an error when attaching later tool results. I think there's a deeper issue at play here, but for now we just include some text to keep the model on track. Release Notes: - N/A --- crates/assistant2/src/active_thread.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/crates/assistant2/src/active_thread.rs b/crates/assistant2/src/active_thread.rs index 9963f8913bfea49436371c2a0d41a000222d6d3e..e420aa9c558535bb53dda5e9133775ba1e73e5d7 100644 --- a/crates/assistant2/src/active_thread.rs +++ b/crates/assistant2/src/active_thread.rs @@ -270,8 +270,15 @@ impl ActiveThread { let model_registry = LanguageModelRegistry::read_global(cx); if let Some(model) = model_registry.active_model() { self.thread.update(cx, |thread, cx| { - // Insert an empty user message to contain the tool results. - thread.insert_user_message("", Vec::new(), cx); + // Insert a user message to contain the tool results. + thread.insert_user_message( + // TODO: Sending up a user message without any content results in the model sending back + // responses that also don't have any content. We currently don't handle this case well, + // so for now we provide some text to keep the model on track. + "Here are the tool results.", + Vec::new(), + cx, + ); thread.send_to_model(model, RequestKind::Chat, true, cx); }); } @@ -295,10 +302,7 @@ impl ActiveThread { let colors = cx.theme().colors(); // Don't render user messages that are just there for returning tool results. - if message.role == Role::User - && message.text.is_empty() - && self.thread.read(cx).message_has_tool_results(message_id) - { + if message.role == Role::User && self.thread.read(cx).message_has_tool_results(message_id) { return Empty.into_any(); }