File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -778,7 +778,9 @@ fn js_content_block_to_rust(block: &ContentBlockObject) -> RustContentBlock {
778778 } ,
779779 "tool_result" => RustContentBlock :: ToolResult {
780780 tool_use_id : block. tool_use_id . clone ( ) . unwrap_or_default ( ) ,
781- content : block. result_content . clone ( ) . unwrap_or_default ( ) ,
781+ content : a3s_code_core:: llm:: ToolResultContentField :: Text (
782+ block. result_content . clone ( ) . unwrap_or_default ( ) ,
783+ ) ,
782784 is_error : block. is_error ,
783785 } ,
784786 _ => RustContentBlock :: Text {
@@ -820,9 +822,34 @@ fn rust_content_block_to_js(block: &RustContentBlock) -> ContentBlockObject {
820822 name : None ,
821823 input : None ,
822824 tool_use_id : Some ( tool_use_id. clone ( ) ) ,
823- result_content : Some ( content. clone ( ) ) ,
825+ result_content : Some ( match content {
826+ a3s_code_core:: llm:: ToolResultContentField :: Text ( s) => s. clone ( ) ,
827+ a3s_code_core:: llm:: ToolResultContentField :: Blocks ( blocks) => {
828+ blocks
829+ . iter ( )
830+ . filter_map ( |b| {
831+ if let a3s_code_core:: llm:: ToolResultContent :: Text { text } = b {
832+ Some ( text. as_str ( ) )
833+ } else {
834+ None
835+ }
836+ } )
837+ . collect :: < Vec < _ > > ( )
838+ . join ( "\n " )
839+ }
840+ } ) ,
824841 is_error : * is_error,
825842 } ,
843+ RustContentBlock :: Image { .. } => ContentBlockObject {
844+ block_type : "image" . to_string ( ) ,
845+ text : None ,
846+ id : None ,
847+ name : None ,
848+ input : None ,
849+ tool_use_id : None ,
850+ result_content : None ,
851+ is_error : None ,
852+ } ,
826853 }
827854}
828855
You can’t perform that action at this time.
0 commit comments