@@ -1402,6 +1402,12 @@ static void test_template_output_parsers() {
14021402 " Hello, world!\n What's up?" ,
14031403 /* is_partial= */ false ,
14041404 {COMMON_CHAT_FORMAT_GRANITE}));
1405+ assert_msg_equals (
1406+ message_assist,
1407+ common_chat_parse (
1408+ " Hello, world!\n What's up?" ,
1409+ /* is_partial= */ true ,
1410+ {COMMON_CHAT_FORMAT_GRANITE}));
14051411
14061412 // Test parsing content with thinking
14071413 assert_msg_equals (message_assist_thoughts,
@@ -1412,13 +1418,98 @@ static void test_template_output_parsers() {
14121418 /* .format = */ COMMON_CHAT_FORMAT_GRANITE,
14131419 /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
14141420 }));
1421+ assert_msg_equals (message_assist_thoughts_unparsed_deepseek,
1422+ common_chat_parse (
1423+ " <think>I'm\n thinking</think>Hello, world!\n What's up?" ,
1424+ /* is_partial= */ false ,
1425+ {COMMON_CHAT_FORMAT_GRANITE}));
1426+ assert_msg_equals (message_assist_thoughts,
1427+ common_chat_parse (
1428+ " <think>I'm\n thinking</think><response>Hello, world!\n What's up?" ,
1429+ /* is_partial= */ true ,
1430+ {
1431+ /* .format = */ COMMON_CHAT_FORMAT_GRANITE,
1432+ /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
1433+ }));
1434+ assert_msg_equals (message_assist_thoughts,
1435+ common_chat_parse (
1436+ " <think>I'm\n thinking</think><response>Hello, world!\n What's up?</response>" ,
1437+ /* is_partial= */ false ,
1438+ {
1439+ /* .format = */ COMMON_CHAT_FORMAT_GRANITE,
1440+ /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
1441+ }));
1442+ assert_msg_equals (simple_assist_msg (" <think>I'm\n thinking</think><response>Hello, world!\n What's up?</response>" ),
1443+ common_chat_parse (
1444+ " <think>I'm\n thinking</think><response>Hello, world!\n What's up?</response>" ,
1445+ /* is_partial= */ false ,
1446+ {COMMON_CHAT_FORMAT_GRANITE}));
1447+ assert_msg_equals (message_assist_empty,
1448+ common_chat_parse (
1449+ " <think" ,
1450+ /* is_partial= */ true ,
1451+ {
1452+ /* .format = */ COMMON_CHAT_FORMAT_GRANITE,
1453+ /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
1454+ }));
1455+ assert_msg_equals (message_assist_empty,
1456+ common_chat_parse (
1457+ " <think" ,
1458+ /* is_partial= */ true ,
1459+ {COMMON_CHAT_FORMAT_GRANITE}));
1460+ assert_msg_equals (message_assist_thoughts_no_content,
1461+ common_chat_parse (
1462+ " <think>I'm\n thinking" ,
1463+ /* is_partial= */ true ,
1464+ {
1465+ /* .format = */ COMMON_CHAT_FORMAT_GRANITE,
1466+ /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
1467+ }));
1468+ assert_msg_equals (
1469+ message_assist_empty,
1470+ common_chat_parse (
1471+ " <think>I'm\n thinking</think><response" ,
1472+ /* is_partial= */ true ,
1473+ {COMMON_CHAT_FORMAT_GRANITE}));
14151474
14161475 // Test parsing tool calls
14171476 assert_msg_equals (message_assist_call,
14181477 common_chat_parse (
14191478 " <|tool_call|>[{\" name\" : \" special_function\" , \" arguments\" : {\" arg1\" : 1}}]" ,
14201479 /* is_partial= */ false ,
14211480 {COMMON_CHAT_FORMAT_GRANITE}));
1481+ assert_msg_equals (
1482+ message_assist_call_empty_args,
1483+ common_chat_parse (
1484+ " <|tool_call|>[{\" name\" : \" special_function\" " ,
1485+ /* is_partial= */ true ,
1486+ {COMMON_CHAT_FORMAT_GRANITE}));
1487+ assert_msg_equals (
1488+ message_assist_call_cutoff_args,
1489+ common_chat_parse (
1490+ " <|tool_call|>[{\" name\" : \" special_function\" , \" arguments\" : {\" arg" ,
1491+ /* is_partial= */ true ,
1492+ {COMMON_CHAT_FORMAT_GRANITE}));
1493+ assert_msg_equals (
1494+ message_assist_call_cutoff_args,
1495+ common_chat_parse (
1496+ " <|tool_call|>[{\" name\" : \" special_function\" , \" arguments\" : {\" arg" ,
1497+ /* is_partial= */ true ,
1498+ {
1499+ /* .format = */ COMMON_CHAT_FORMAT_GRANITE,
1500+ /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
1501+ }));
1502+
1503+ // Test parsing tool calls with thinking
1504+ assert_msg_equals (
1505+ message_assist_call_thoughts,
1506+ common_chat_parse (
1507+ " <think>I'm\n thinking</think><|tool_call|>[{\" name\" : \" special_function\" , \" arguments\" : {\" arg1\" : 1}, {" ,
1508+ /* is_partial= */ true ,
1509+ {
1510+ /* .format = */ COMMON_CHAT_FORMAT_GRANITE,
1511+ /* .reasoning_format = */ COMMON_REASONING_FORMAT_DEEPSEEK,
1512+ }));
14221513
14231514 // Test template generation for regular content
14241515 test_templates (tmpls.get (), end_tokens, message_assist, tools,
0 commit comments