@@ -259,7 +259,10 @@ def _to_anthropic_messages(messages: list[dict]) -> list[dict]:
259259 # assistant with tool calls → Anthropic tool_use blocks
260260 blocks : list [dict ] = []
261261 if content :
262- blocks .append ({"type" : "text" , "text" : content })
262+ if isinstance (content , list ):
263+ blocks .extend (block for block in content if block .get ("type" ) == "text" )
264+ else :
265+ blocks .append ({"type" : "text" , "text" : content })
263266 for tc in m ["tool_calls" ]:
264267 blocks .append (
265268 {
@@ -422,7 +425,7 @@ def _to_openai_messages(
422425
423426 Strict default OpenAI-compatible requests do not receive provider-specific
424427 reasoning fields. llama.cpp compatibility replays text reasoning as
425- reasoning_content. Other non-standard fields (fc_id in tool_calls) are
428+ reasoning_content. Other non-standard fields (fc_id in tool_calls) are
426429 stripped.
427430 """
428431 result = []
@@ -461,6 +464,7 @@ def _to_openai_messages(
461464 else :
462465 out = dict (m )
463466 out .pop ("reasoning_items" , None )
467+ out ["content" ] = content
464468 if out .get ("tool_calls" ):
465469 out ["tool_calls" ] = [
466470 {k : v for k , v in tc .items () if k != "fc_id" } for tc in out ["tool_calls" ]
@@ -726,6 +730,24 @@ def _to_responses_input(
726730 m .get ("reasoning_items" ), provider_type = provider_type
727731 ):
728732 items .append (ri )
733+ content = m .get ("content" , "" )
734+ if isinstance (content , list ):
735+ text = "" .join (
736+ block .get ("text" ) or ""
737+ for block in content
738+ if isinstance (block , dict )
739+ and block .get ("type" ) in ("text" , "output_text" , "input_text" )
740+ )
741+ else :
742+ text = content
743+ if isinstance (text , str ) and text .strip ():
744+ items .append (
745+ {
746+ "type" : "message" ,
747+ "role" : "assistant" ,
748+ "content" : [{"type" : "output_text" , "text" : text }],
749+ }
750+ )
729751 for tc in m ["tool_calls" ]:
730752 call_id = tc .get ("id" , "" )
731753 # Skip function_calls that have no matching tool result
0 commit comments