diff --git a/crates/goose-local-inference/src/lib.rs b/crates/goose-local-inference/src/lib.rs
index 95f798c46..99aad9799 100644
--- a/crates/goose-local-inference/src/lib.rs
+++ b/crates/goose-local-inference/src/lib.rs
@@ -481,7 +481,7 @@ fn extract_text_content(msg: &Message) -> String {
for content in &msg.content {
match content {
MessageContent::Text(text) => {
- let text = strip_info_messages(&text.text);
+ let text = text.text.to_string();
if !text.trim().is_empty() {
parts.push(text);
}
@@ -534,24 +534,6 @@ fn extract_text_content(msg: &Message) -> String {
parts.join("\n")
}
-fn strip_info_messages(text: &str) -> String {
- let mut remaining = text;
- let mut output = String::new();
-
- while let Some((before, after_start)) = remaining.split_once("") {
- output.push_str(before);
- if let Some((_, after_end)) = after_start.split_once("") {
- remaining = after_end;
- } else {
- remaining = "";
- break;
- }
- }
-
- output.push_str(remaining);
- output.trim().to_string()
-}
-
/// Build a `ProviderUsage` and write the request log entry.
fn finalize_usage(
log: &mut Option>,
@@ -947,4 +929,32 @@ mod tests {
])
);
}
+
+ #[test]
+ fn preserves_balanced_info_tags_in_text_content() {
+ let message =
+ Message::user().with_text("before executed payload after");
+
+ assert_eq!(
+ extract_text_content(&message),
+ "before executed payload after"
+ );
+ }
+
+ #[test]
+ fn preserves_unterminated_info_tags_in_text_content() {
+ let message = Message::user().with_text("before executed payload");
+
+ assert_eq!(
+ extract_text_content(&message),
+ "before executed payload"
+ );
+ }
+
+ #[test]
+ fn preserves_legitimate_text_content() {
+ let message = Message::user().with_text("ordinary user content");
+
+ assert_eq!(extract_text_content(&message), "ordinary user content");
+ }
}