Drop whitespace-only content nodes from parser output

Content between tags (e.g. newlines between </think> and <tool_call>)
was creating empty Content nodes. Now trimmed before creating the node.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
Kent Overstreet 2026-04-08 17:21:34 -04:00
parent 1b6664ee1c
commit 01bbc39a31

View file

@ -623,7 +623,7 @@ impl ResponseParser {
fn flush_content(&mut self, ctx: &mut ContextState) { fn flush_content(&mut self, ctx: &mut ContextState) {
if !self.content_parts.is_empty() { if !self.content_parts.is_empty() {
let text: String = self.content_parts.drain(..).collect(); let text: String = self.content_parts.drain(..).collect();
if !text.is_empty() { if !text.trim().is_empty() {
self.push_child(ctx, AstNode::content(text)); self.push_child(ctx, AstNode::content(text));
} }
} }