@@ -282,6 +282,23 @@ static void test_deepseek_v3_1_tool_calls() {
282282 assert_equals (variant, std::string (" REASONING<|tool▁calls▁begin|><|tool▁call▁begin|>get_time2<|tool▁sep|>{\" city\" : \" Tokyo2\" }<|tool▁call▁end|><|tool▁calls▁end|>REASONING" ), m.reasoning_content );
283283 }
284284
285+ // variant: thinking forced open + tool call in reasoning content + no closing think
286+ {
287+ common_chat_syntax syntax = {
288+ /* .format = */ COMMON_CHAT_FORMAT_DEEPSEEK_V3_1,
289+ /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
290+ /* .reasoning_in_content = */ false ,
291+ /* .thinking_forced_open = */ true ,
292+ /* .parse_tool_calls = */ true ,
293+ };
294+ const char * variant = " thinking_forced_open_tool_call_in_reasoning_no_closing_think" ;
295+ const std::string in = " REASONING<|tool▁calls▁begin|><|tool▁call▁begin|>get_time2<|tool▁sep|>{\" city\" : \" Tokyo2\" }<|tool▁call▁end|><|tool▁calls▁end|>REASONING" ;
296+ auto m = common_chat_parse (in, false , syntax);
297+ assert_equals<std::size_t >(variant, 0 , m.tool_calls .size ());
298+ assert_equals (variant, std::string (" " ), m.content );
299+ assert_equals (variant, std::string (" REASONING<|tool▁calls▁begin|><|tool▁call▁begin|>get_time2<|tool▁sep|>{\" city\" : \" Tokyo2\" }<|tool▁call▁end|><|tool▁calls▁end|>REASONING" ), m.reasoning_content );
300+ }
301+
285302 // variant: thinking not forced open + missing reasoning + no tool calls
286303 {
287304 common_chat_syntax syntax = {
0 commit comments