@@ -24,28 +24,19 @@ export function convertAnthropicContentToGemini(content: string | Anthropic.Cont
2424 } ,
2525 }
2626 case "tool_result" : {
27- // Skip empty tool results
2827 if ( ! block . content ) {
2928 return [ ]
3029 }
3130
3231 // Extract tool name from tool_use_id (e.g., "calculator-123" -> "calculator")
3332 const toolName = block . tool_use_id . split ( "-" ) [ 0 ]
3433
35- // Handle string content
3634 if ( typeof block . content === "string" ) {
3735 return {
38- functionResponse : {
39- name : toolName ,
40- response : {
41- name : toolName ,
42- content : block . content ,
43- } ,
44- } ,
36+ functionResponse : { name : toolName , response : { name : toolName , content : block . content } } ,
4537 }
4638 }
4739
48- // Handle array content
4940 if ( Array . isArray ( block . content ) ) {
5041 const textParts : string [ ] = [ ]
5142 const imageParts : Part [ ] = [ ]
@@ -56,33 +47,19 @@ export function convertAnthropicContentToGemini(content: string | Anthropic.Cont
5647 } else if ( item . type === "image" ) {
5748 if ( item . source . type === "base64" ) {
5849 imageParts . push ( {
59- inlineData : {
60- data : item . source . data ,
61- mimeType : item . source . media_type ,
62- } ,
50+ inlineData : { data : item . source . data , mimeType : item . source . media_type } ,
6351 } )
6452 }
6553 }
6654 } )
6755
6856 // Create content text with a note about images if present
6957 const contentText =
70- textParts . join ( "\n\n" ) +
71- ( imageParts . length > 0
72- ? ( textParts . length > 0 ? "\n\n" : "\n\n" ) + "(See next part for image)"
73- : "" )
58+ textParts . join ( "\n\n" ) + ( imageParts . length > 0 ? "\n\n(See next part for image)" : "" )
7459
7560 // Return function response followed by any images
7661 return [
77- {
78- functionResponse : {
79- name : toolName ,
80- response : {
81- name : toolName ,
82- content : contentText ,
83- } ,
84- } ,
85- } ,
62+ { functionResponse : { name : toolName , response : { name : toolName , content : contentText } } } ,
8663 ...imageParts ,
8764 ]
8865 }
0 commit comments