Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

agent: Fix an issue with messages containing trailing whitespace (#33643)

Bennet Bo Fennerca0bd53bede2
diff --git a/crates/agent/src/thread.rs b/crates/agent/src/thread.rs
index 32c376ca67f..2f965e232af 100644
--- a/crates/agent/src/thread.rs
+++ b/crates/agent/src/thread.rs
@@ -1343,6 +1343,7 @@ impl Thread {
for segment in &message.segments {
match segment {
MessageSegment::Text(text) => {
+ let text = text.trim_end();
if !text.is_empty() {
request_message
.content
diff --git a/crates/language_models/src/provider/anthropic.rs b/crates/language_models/src/provider/anthropic.rs
index 48bea47fec0..aa500f4b4dd 100644
--- a/crates/language_models/src/provider/anthropic.rs
+++ b/crates/language_models/src/provider/anthropic.rs
@@ -528,6 +528,11 @@ pub fn into_anthropic(
.into_iter()
.filter_map(|content| match content {
MessageContent::Text(text) => {
+ let text = if text.chars().last().map_or(false, |c| c.is_whitespace()) {
+ text.trim_end().to_string()
+ } else {
+ text
+ };
if !text.is_empty() {
Some(anthropic::RequestContent::Text {
text,