diff --git a/src/agent/context.rs b/src/agent/context.rs index 62beff9..4aef3e8 100644 --- a/src/agent/context.rs +++ b/src/agent/context.rs @@ -527,8 +527,8 @@ impl ResponseParser { self.think_buf.push_str(&self.buf[..end]); self.buf = self.buf[end + 8..].to_string(); self.in_think = false; - let text = std::mem::take(&mut self.think_buf); - if !text.trim().is_empty() { + let text = std::mem::take(&mut self.think_buf).trim().to_string(); + if !text.is_empty() { self.push_child(ctx, AstNode::thinking(text)); } continue; @@ -623,7 +623,8 @@ impl ResponseParser { fn flush_content(&mut self, ctx: &mut ContextState) { if !self.content_parts.is_empty() { let text: String = self.content_parts.drain(..).collect(); - if !text.trim().is_empty() { + let text = text.trim().to_string(); + if !text.is_empty() { self.push_child(ctx, AstNode::content(text)); } }