@@ -197,7 +197,51 @@ static void test_deepseek_v3_1() {
197197 /* .thinking_forced_open = */ false ,
198198 /* .parse_tool_calls = */ true ,
199199 };
200- common_chat_msg_parser builder (" REASONING</think>ok" , /* is_partial= */ false , {});
200+ common_chat_msg_parser builder (" REASONING</think>ok" , /* is_partial= */ false , syntax);
201+ assert_equals (std::string (" REASONING" ), builder.result ().reasoning_content );
202+ assert_equals (std::string (" ok" ), builder.result ().content );
203+ }
204+
205+ // Test with whitespace around reasoning content
206+ {
207+ common_chat_syntax syntax = {
208+ /* .format = */ COMMON_CHAT_FORMAT_DEEPSEEK_V3_1,
209+ /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
210+ /* .reasoning_in_content = */ false ,
211+ /* .thinking_forced_open = */ false ,
212+ /* .parse_tool_calls = */ true ,
213+ };
214+ common_chat_msg_parser builder (" REASONING WITH SPACES </think>ok" , /* is_partial= */ false , syntax);
215+ assert_equals (std::string (" REASONING WITH SPACES" ), builder.result ().reasoning_content );
216+ assert_equals (std::string (" ok" ), builder.result ().content );
217+ }
218+
219+ // Test without thinking tag (should be all regular content)
220+ {
221+ common_chat_syntax syntax = {
222+ /* .format = */ COMMON_CHAT_FORMAT_DEEPSEEK_V3_1,
223+ /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
224+ /* .reasoning_in_content = */ false ,
225+ /* .thinking_forced_open = */ false ,
226+ /* .parse_tool_calls = */ true ,
227+ };
228+ common_chat_msg_parser builder (" just regular content" , /* is_partial= */ false , syntax);
229+ assert_equals (std::string (" " ), builder.result ().reasoning_content );
230+ assert_equals (std::string (" just regular content" ), builder.result ().content );
231+ }
232+
233+ // Test with empty reasoning content
234+ {
235+ common_chat_syntax syntax = {
236+ /* .format = */ COMMON_CHAT_FORMAT_DEEPSEEK_V3_1,
237+ /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
238+ /* .reasoning_in_content = */ false ,
239+ /* .thinking_forced_open = */ false ,
240+ /* .parse_tool_calls = */ true ,
241+ };
242+ common_chat_msg_parser builder (" </think>ok" , /* is_partial= */ false , syntax);
243+ assert_equals (std::string (" " ), builder.result ().reasoning_content );
244+ assert_equals (std::string (" ok" ), builder.result ().content );
201245 }
202246}
203247
@@ -362,6 +406,7 @@ int main() {
362406 test_json_with_dumped_args ();
363407 test_reasoning ();
364408 test_regex ();
409+ test_deepseek_v3_1 ();
365410 std::cout << " All tests passed!\n " ;
366411 return 0 ;
367412}
0 commit comments