@@ -2127,6 +2127,38 @@ async def test_content_to_message_param_assistant_thought_and_content_message():
21272127 assert message ["reasoning_content" ] == "internal reasoning"
21282128
21292129
2130+ @pytest .mark .asyncio
2131+ async def test_content_to_message_param_preserves_chunked_reasoning_deltas ():
2132+ thought_part_1 = types .Part .from_text (text = "Hel" )
2133+ thought_part_1 .thought = True
2134+ thought_part_2 = types .Part .from_text (text = "lo" )
2135+ thought_part_2 .thought = True
2136+ content = types .Content (
2137+ role = "assistant" , parts = [thought_part_1 , thought_part_2 ]
2138+ )
2139+
2140+ message = await _content_to_message_param (content )
2141+
2142+ assert message ["role" ] == "assistant"
2143+ assert message ["content" ] is None
2144+ assert message ["reasoning_content" ] == "Hello"
2145+
2146+
2147+ @pytest .mark .asyncio
2148+ async def test_content_to_message_param_preserves_reasoning_newlines ():
2149+ thought_part_1 = types .Part .from_text (text = "line 1\n " )
2150+ thought_part_1 .thought = True
2151+ thought_part_2 = types .Part .from_text (text = "line 2" )
2152+ thought_part_2 .thought = True
2153+ content = types .Content (
2154+ role = "assistant" , parts = [thought_part_1 , thought_part_2 ]
2155+ )
2156+
2157+ message = await _content_to_message_param (content )
2158+
2159+ assert message ["reasoning_content" ] == "line 1\n line 2"
2160+
2161+
21302162@pytest .mark .asyncio
21312163async def test_content_to_message_param_function_call ():
21322164 content = types .Content (
0 commit comments