File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
packages/opencode/src/tool Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -78,15 +78,23 @@ export const BatchTool = Tool.define("batch", async () => {
7878 const successfulCalls = results . filter ( ( r ) => r . success ) . length
7979 const failedCalls = toolCalls . length - successfulCalls
8080
81+ const outputParts = results . map ( ( r ) => {
82+ if ( r . success ) {
83+ return `<tool_result name="${ r . tool } ">\n${ r . result . output } \n</tool_result>`
84+ }
85+ const errorMessage = r . error instanceof Error ? r . error . message : String ( r . error )
86+ return `<tool_result name="${ r . tool } ">\nError: ${ errorMessage } \n</tool_result>`
87+ } )
88+
8189 const outputMessage =
8290 failedCalls > 0
83- ? `Executed ${ successfulCalls } /${ toolCalls . length } tools successfully. ${ failedCalls } failed.`
84- : `All ${ successfulCalls } tools executed successfully.\n\nKeep using the batch tool for optimal performance in your next response!`
91+ ? `Executed ${ successfulCalls } /${ toolCalls . length } tools successfully. ${ failedCalls } failed.\n\n ${ outputParts . join ( "\n\n" ) } `
92+ : `All ${ successfulCalls } tools executed successfully.\n\n ${ outputParts . join ( "\n\n" ) } \n\ nKeep using the batch tool for optimal performance in your next response!`
8593
8694 return {
8795 title : `Batch execution (${ successfulCalls } /${ toolCalls . length } successful)` ,
8896 output : outputMessage ,
89- attachments : results . filter ( ( result ) => result . success ) . flatMap ( ( r ) => r . result . attachments ) ,
97+ attachments : results . filter ( ( result ) => result . success ) . flatMap ( ( r ) => r . result . attachments ?? [ ] ) ,
9098 metadata : {
9199 totalCalls : toolCalls . length ,
92100 successful : successfulCalls ,
You can’t perform that action at this time.
0 commit comments