@@ -913,6 +913,41 @@ describe("format translation", () => {
913913 assert . equal ( body . messages [ 2 ] . content [ 0 ] . tool_use_id , "call_1" ) ;
914914 } ) ;
915915
916+ it ( "groups parallel tool results and supplemental images into one Anthropic user message" , ( ) => {
917+ const body = claude . toAnthropicBody (
918+ {
919+ messages : [
920+ { role : "user" , content : "inspect both images" } ,
921+ {
922+ role : "assistant" ,
923+ content : null ,
924+ tool_calls : [
925+ { id : "call_a" , type : "function" , function : { name : "view_image" , arguments : '{"path":"a.png"}' } } ,
926+ { id : "call_b" , type : "function" , function : { name : "view_image" , arguments : '{"path":"b.png"}' } } ,
927+ { id : "call_c" , type : "function" , function : { name : "run_command" , arguments : '{"command":"echo ok"}' } } ,
928+ ] ,
929+ } ,
930+ { role : "tool" , tool_call_id : "call_a" , content : "viewed a" } ,
931+ { role : "user" , content : [ { type : "text" , text : "image a" } , { type : "image_url" , image_url : { url : "data:image/png;base64,YQ==" } } ] } ,
932+ { role : "tool" , tool_call_id : "call_b" , content : "viewed b" } ,
933+ { role : "user" , content : [ { type : "text" , text : "image b" } , { type : "image_url" , image_url : { url : "data:image/png;base64,Yg==" } } ] } ,
934+ { role : "tool" , tool_call_id : "call_c" , content : "ok" } ,
935+ ] ,
936+ max_tokens : 64 ,
937+ } ,
938+ "claude-opus-5-5" ,
939+ false
940+ ) ;
941+
942+ assert . deepEqual ( body . messages . map ( ( message ) => message . role ) , [ "user" , "assistant" , "user" ] ) ;
943+ assert . deepEqual (
944+ body . messages [ 2 ] . content . filter ( ( block ) => block . type === "tool_result" ) . map ( ( block ) => block . tool_use_id ) ,
945+ [ "call_a" , "call_b" , "call_c" ]
946+ ) ;
947+ assert . deepEqual ( body . messages [ 2 ] . content . slice ( 0 , 3 ) . map ( ( block ) => block . type ) , [ "tool_result" , "tool_result" , "tool_result" ] ) ;
948+ assert . equal ( body . messages [ 2 ] . content . filter ( ( block ) => block . type === "image" ) . length , 2 ) ;
949+ } ) ;
950+
916951 it ( "anthropic tool_use → openai tool_calls" , ( ) => {
917952 const out = claude . fromAnthropicJson (
918953 {
0 commit comments