@@ -2207,6 +2207,38 @@ async def test_content_to_message_param_assistant_thought_and_content_message():
22072207 assert message ["reasoning_content" ] == "internal reasoning"
22082208
22092209
2210+ @pytest .mark .asyncio
2211+ async def test_content_to_message_param_preserves_chunked_reasoning_deltas ():
2212+ thought_part_1 = types .Part .from_text (text = "Hel" )
2213+ thought_part_1 .thought = True
2214+ thought_part_2 = types .Part .from_text (text = "lo" )
2215+ thought_part_2 .thought = True
2216+ content = types .Content (
2217+ role = "assistant" , parts = [thought_part_1 , thought_part_2 ]
2218+ )
2219+
2220+ message = await _content_to_message_param (content )
2221+
2222+ assert message ["role" ] == "assistant"
2223+ assert message ["content" ] is None
2224+ assert message ["reasoning_content" ] == "Hello"
2225+
2226+
2227+ @pytest .mark .asyncio
2228+ async def test_content_to_message_param_preserves_reasoning_newlines ():
2229+ thought_part_1 = types .Part .from_text (text = "line 1\n " )
2230+ thought_part_1 .thought = True
2231+ thought_part_2 = types .Part .from_text (text = "line 2" )
2232+ thought_part_2 .thought = True
2233+ content = types .Content (
2234+ role = "assistant" , parts = [thought_part_1 , thought_part_2 ]
2235+ )
2236+
2237+ message = await _content_to_message_param (content )
2238+
2239+ assert message ["reasoning_content" ] == "line 1\n line 2"
2240+
2241+
22102242@pytest .mark .asyncio
22112243async def test_content_to_message_param_function_call ():
22122244 content = types .Content (
0 commit comments