@@ -1642,22 +1642,16 @@ static void test_template_output_peg_parsers(bool detailed_debug) {
16421642 // Qwen3.5 (basically same as Nemotron, but keeping separate tests just in case)
16431643 auto tst = peg_tester (" models/templates/Qwen3.5-4B.jinja" , detailed_debug);
16441644
1645- tst.test (" I'm\n thinking</think>Hello , world!\n What's up?" )
1645+ tst.test (" I'm\n thinking\n </think>\n\n Hello , world!\n What's up?" )
16461646 .reasoning_format (COMMON_REASONING_FORMAT_AUTO)
16471647 .enable_thinking (true )
16481648 .expect (message_assist_thoughts)
16491649 .run ();
16501650
1651- tst.test (" I'm\n thinking\n </think>\n Hello, world!\n What's up?" )
1651+ tst.test (" I'm\n thinking\n </think>\n \n Hello, world!\n What's up?" )
16521652 .enable_thinking (true )
16531653 .reasoning_format (COMMON_REASONING_FORMAT_NONE)
1654- .expect_content (" <think>\n I'm\n thinking\n </think>\n Hello, world!\n What's up?" )
1655- .run ();
1656-
1657- tst.test (" I'm\n thinking\n </think>\n Hello, world!\n What's up?" )
1658- .enable_thinking (true )
1659- .reasoning_format (COMMON_REASONING_FORMAT_AUTO)
1660- .expect (message_assist_thoughts)
1654+ .expect_content (" <think>\n I'm\n thinking\n </think>\n\n Hello, world!\n What's up?" )
16611655 .run ();
16621656
16631657 tst.test (
@@ -1673,7 +1667,7 @@ static void test_template_output_peg_parsers(bool detailed_debug) {
16731667 .run ();
16741668
16751669 tst.test (
1676- " I'm\n thinking\n </think>\n "
1670+ " I'm\n thinking\n </think>\n\n "
16771671 " <tool_call>\n "
16781672 " <function=special_function>\n "
16791673 " <parameter=arg1>\n 1\n </parameter>\n "
@@ -1731,7 +1725,7 @@ static void test_template_output_peg_parsers(bool detailed_debug) {
17311725
17321726 tst.test (
17331727 " I need to output the invoice details in JSON\n "
1734- " </think>\n "
1728+ " </think>\n\n "
17351729 R"( {"amount": 123.45, "date": "2025-12-03"})" )
17361730 .reasoning_format (COMMON_REASONING_FORMAT_AUTO)
17371731 .enable_thinking (true )
@@ -1751,7 +1745,7 @@ static void test_template_output_peg_parsers(bool detailed_debug) {
17511745 " hello()\n "
17521746 " </parameter>\n "
17531747 " </function>\n "
1754- " </tool_call></think>\n "
1748+ " </tool_call>\n </think>\n \n"
17551749 " <tool_call>\n "
17561750 " <function=python>\n "
17571751 " <parameter=code>\n "
@@ -1994,7 +1988,7 @@ static void test_template_output_peg_parsers(bool detailed_debug) {
19941988 " hello()\n "
19951989 " </parameter>\n "
19961990 " </function>\n "
1997- " </tool_call></think>\n "
1991+ " </tool_call>\n </think>\n "
19981992 " <tool_call>\n "
19991993 " <function=python>\n "
20001994 " <parameter=code>\n "
@@ -3463,7 +3457,7 @@ static void test_template_output_peg_parsers(bool detailed_debug) {
34633457 .run ();
34643458
34653459 // Tool call with reasoning (enable_thinking=true)
3466- tst.test (" I'm\n thinking</think><tool_call>\n {\" name\" : \" special_function\" , \" arguments\" : {\" arg1\" : 1}}</tool_call>" )
3460+ tst.test (" I'm\n thinking\n </think>\n\n <tool_call>\n {\" name\" : \" special_function\" , \" arguments\" : {\" arg1\" : 1}}</tool_call>" )
34673461 .enable_thinking (true )
34683462 .reasoning_format (COMMON_REASONING_FORMAT_AUTO)
34693463 .tools ({ special_function_tool })
@@ -3487,7 +3481,7 @@ static void test_template_output_peg_parsers(bool detailed_debug) {
34873481 .run ();
34883482
34893483 // Tool call with reasoning and content
3490- tst.test (" I need to call a function</think>"
3484+ tst.test (" I need to call a function\n </think>\n\n "
34913485 " Let me check the time.<tool_call>\n {\" name\" : \" get_time\" , \" arguments\" : {\" city\" : \" XYZCITY\" }}</tool_call>" )
34923486 .enable_thinking (true )
34933487 .reasoning_format (COMMON_REASONING_FORMAT_AUTO)
@@ -3514,7 +3508,7 @@ static void test_template_output_peg_parsers(bool detailed_debug) {
35143508
35153509 // fake tool call marker in reasoning
35163510 tst.test (
3517- " Let me think about <tool_call>\n {\" name\" : \" special_function\" , \" arguments\" : {\" arg1\" : 2}}</tool_call> hmm</think>"
3511+ " Let me think about <tool_call>\n {\" name\" : \" special_function\" , \" arguments\" : {\" arg1\" : 2}}</tool_call> hmm\n </think>\n\n "
35183512 " <tool_call>\n {\" name\" : \" special_function\" , \" arguments\" : {\" arg1\" : 1}}</tool_call>" )
35193513 .enable_thinking (true )
35203514 .reasoning_format (COMMON_REASONING_FORMAT_AUTO)
@@ -3542,19 +3536,19 @@ static void test_template_output_peg_parsers(bool detailed_debug) {
35423536 // Format: <minimax:tool_call><invoke name="func"><parameter name="key">value</parameter></invoke></minimax:tool_call>
35433537 {
35443538 auto tst = peg_tester (" models/templates/MiniMax-M2.jinja" , detailed_debug);
3545- tst.test (" </think>Hello , world!\n What's up?" ).enable_thinking (true ).reasoning_format (COMMON_REASONING_FORMAT_AUTO).expect (message_assist).run ();
3539+ tst.test (" \n </think>\n\n Hello , world!\n What's up?" ).enable_thinking (true ).reasoning_format (COMMON_REASONING_FORMAT_AUTO).expect (message_assist).run ();
35463540
3547- tst.test (" I'm\n thinking</think>Hello , world!\n What's up?" ).enable_thinking (true ).reasoning_format (COMMON_REASONING_FORMAT_AUTO).expect (message_assist_thoughts).run ();
3541+ tst.test (" I'm\n thinking\n </think>\n\n Hello , world!\n What's up?" ).enable_thinking (true ).reasoning_format (COMMON_REASONING_FORMAT_AUTO).expect (message_assist_thoughts).run ();
35483542
3549- tst.test (" Let's call a tool:</think><minimax:tool_call>\n <invoke name=\" empty_args\" >\n </invoke>\n </minimax:tool_call>" ).
3543+ tst.test (" Let's call a tool:\n </think>\n\n <minimax:tool_call>\n <invoke name=\" empty_args\" >\n </invoke>\n </minimax:tool_call>" ).
35503544 enable_thinking (true ).
35513545 reasoning_format (COMMON_REASONING_FORMAT_AUTO).
35523546 tools ({ empty_args_tool }).
35533547 expect (message_with_reasoning_and_tool_call (" Let's call a tool:" , " empty_args" , " {}" )).
35543548 run ();
35553549
35563550 tst.test (
3557- " </think><minimax:tool_call>\n <invoke name=\" special_function\" >\n <parameter "
3551+ " \n </think>\n\n <minimax:tool_call>\n <invoke name=\" special_function\" >\n <parameter "
35583552 " name=\" arg1\" >1</parameter>\n </invoke>\n </minimax:tool_call>" )
35593553 .tools ({ special_function_tool })
35603554 .expect (message_assist_call)
@@ -3714,7 +3708,7 @@ static void test_template_output_peg_parsers(bool detailed_debug) {
37143708 .enable_thinking (false )
37153709 .expect (message_assist)
37163710 .run ();
3717- tst.test (" I'm\n thinking</think>\n\n Hello, world!\n What's up?" )
3711+ tst.test (" I'm\n thinking\n </think>\n\n Hello, world!\n What's up?" )
37183712 .enable_thinking (true )
37193713 .reasoning_format (COMMON_REASONING_FORMAT_DEEPSEEK)
37203714 .expect (message_assist_thoughts)
@@ -3729,7 +3723,7 @@ static void test_template_output_peg_parsers(bool detailed_debug) {
37293723 .tools ({ special_function_tool })
37303724 .expect (message_assist_call_content)
37313725 .run ();
3732- tst.test (" I'm\n thinking</think>\n\n <tool_call>\n {\" name\" : \" special_function\" , \" arguments\" : {\" arg1\" : 1}}\n </tool_call>" )
3726+ tst.test (" I'm\n thinking\n </think>\n\n <tool_call>\n {\" name\" : \" special_function\" , \" arguments\" : {\" arg1\" : 1}}\n </tool_call>" )
37333727 .enable_thinking (true )
37343728 .reasoning_format (COMMON_REASONING_FORMAT_DEEPSEEK)
37353729 .tools ({ special_function_tool })
@@ -4006,7 +4000,8 @@ static void test_template_output_peg_parsers(bool detailed_debug) {
40064000
40074001 {
40084002 auto tst = peg_tester (" models/templates/StepFun3.5-Flash.jinja" , detailed_debug);
4009- tst.test (" I was thinking</think>\n Now I'm not." ).
4003+
4004+ tst.test (" I was thinking\n </think>\n Now I'm not." ).
40104005 enable_thinking (true ).
40114006 reasoning_format (COMMON_REASONING_FORMAT_DEEPSEEK).
40124007 expect_reasoning (" I was thinking" ).
0 commit comments