Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 099aec0

Browse files
committed
eating a space prior to tool calls
1 parent d2f8a92 commit 099aec0

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/completions/xml_tool_processor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def <<(text)
3030
if @in_tool
3131
@function_buffer = @buffer[index..-1]
3232
text_index = text.rindex("<function_calls>")
33-
result << text[0..text_index - 1].strip if text_index && text_index > 0
33+
result << text[0..text_index - 1].rstrip if text_index && text_index > 0
3434
end
3535
else
3636
add_to_function_buffer(text)

spec/lib/completions/xml_tool_processor_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,8 @@
8686
end
8787

8888
it "is usable for simple single message mode" do
89-
xml = (<<~XML).strip
90-
hello
91-
<function_calls>
89+
xml = (<<~XML)
90+
world <function_calls>
9291
<invoke>
9392
<tool_name>hello</tool_name>
9493
<parameters>
@@ -99,6 +98,7 @@
9998
XML
10099

101100
result = []
101+
result << (processor << "hello")
102102
result << (processor << xml)
103103
result << (processor.finish)
104104

@@ -111,7 +111,7 @@
111111
test: "value",
112112
},
113113
)
114-
expect(result).to eq([["hello"], [tool_call]])
114+
expect(result).to eq([["hello"], [" world"], [tool_call]])
115115
expect(processor.should_cancel?).to eq(false)
116116
end
117117

0 commit comments

Comments
 (0)