File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -925,7 +925,7 @@ async def _content_to_message_param(
925925 ):
926926 reasoning_texts .append (_decode_inline_text_data (part .inline_data .data ))
927927
928- reasoning_content = _NEW_LINE .join (text for text in reasoning_texts if text )
928+ reasoning_content = "" .join (text for text in reasoning_texts if text )
929929 return ChatCompletionAssistantMessage (
930930 role = role ,
931931 content = final_content ,
Original file line number Diff line number Diff line change @@ -4898,6 +4898,23 @@ async def test_content_to_message_param_non_anthropic_uses_reasoning_content():
48984898 assert "thinking_blocks" not in result
48994899
49004900
4901+ @pytest .mark .asyncio
4902+ async def test_content_to_message_param_preserves_reasoning_fragments ():
4903+ content = types .Content (
4904+ role = "model" ,
4905+ parts = [
4906+ types .Part (text = "Step 1: " , thought = True ),
4907+ types .Part (text = "inspect" , thought = True ),
4908+ types .Part (text = "." , thought = True ),
4909+ types .Part (text = "Done" ),
4910+ ],
4911+ )
4912+
4913+ result = await _content_to_message_param (content , model = "openai/gpt-4o" )
4914+
4915+ assert result .get ("reasoning_content" ) == "Step 1: inspect."
4916+
4917+
49014918@pytest .mark .asyncio
49024919async def test_anthropic_thinking_blocks_round_trip ():
49034920 """End-to-end: thinking_blocks in response → Part → thinking_blocks out."""
You can’t perform that action at this time.
0 commit comments