chat : allow Gemma4 tool call during thought (#32232)

The thought channel is normally closed with <channel|>, but the model
may open it and go straight to a tool call without closing it. Stop the
reasoning at <channel|> OR <|tool_call>, so an unclosed thought does
not swallow the following tool call.

Fixes: #32231

Assisted-by: Qwen 3.8 27b
This commit is contained in:
Cristian Adam authored and GitHub committed 2026-11-14 23:32:19 +01:00
1 parent a956a852c9
commit 1c2adc75f6
2 files changed
+16 -3

No files matched your search

+11
View File
@@ -3178,6 +3178,17 @@ static void test_template_output_peg_parsers(bool detailed_debug) {
})
.run();
// Tool call after reasoning, the model did not close the thought channel (#32231)
tst.test(
"<|channel>thought\nI'm\nthinking<|tool_call>call:get_time{city:<|\"|>Paris<|\"|>}<tool_call|>")
.reasoning_format(COMMON_REASONING_FORMAT_AUTO)
.tools({ get_time_tool })
.expect_reasoning("I'm\nthinking")
.expect_tool_calls({
{ "get_time", R"({"city": "Paris"})", {} },
})
.run();
// Parallel tool calls
tst.test(
"<|tool_call>call:get_time{city:<|\"|>London<|\"|>}<tool_call|>"