@@ -341,7 +341,23 @@ describe('buildTraceSpans', () => {
341341 expect ( toolCall . output ) . toEqual ( { analysis : 'completed' } )
342342 } )
343343
344- it . concurrent ( 'handles tool calls with errors in timeSegments' , ( ) => {
344+ it . concurrent . each ( [
345+ {
346+ toolResult : {
347+ error : true ,
348+ message : 'Tool execution failed' ,
349+ tool : 'custom_failing_tool' ,
350+ } ,
351+ expectedMessage : 'Tool execution failed' ,
352+ } ,
353+ {
354+ toolResult : {
355+ success : false ,
356+ error : 'MCP server connection failed' ,
357+ } ,
358+ expectedMessage : 'MCP server connection failed' ,
359+ } ,
360+ ] ) ( 'handles tool calls with errors in timeSegments' , ( { toolResult, expectedMessage } ) => {
345361 const mockExecutionResult : ExecutionResult = {
346362 success : true ,
347363 output : { content : 'Final output' } ,
@@ -392,11 +408,7 @@ describe('buildTraceSpans', () => {
392408 {
393409 name : 'failing_tool' ,
394410 arguments : { input : 'test' } ,
395- result : {
396- error : true ,
397- message : 'Tool execution failed' ,
398- tool : 'custom_failing_tool' ,
399- } ,
411+ result : toolResult ,
400412 duration : 1000 ,
401413 startTime : '2024-01-01T10:00:01.000Z' ,
402414 endTime : '2024-01-01T10:00:02.000Z' ,
@@ -425,13 +437,9 @@ describe('buildTraceSpans', () => {
425437 expect ( toolSegment . type ) . toBe ( 'tool' )
426438 expect ( toolSegment . status ) . toBe ( 'error' )
427439 expect ( toolSegment . errorHandled ) . toBe ( true )
428- expect ( toolSegment . errorMessage ) . toBe ( 'Tool execution failed' )
440+ expect ( toolSegment . errorMessage ) . toBe ( expectedMessage )
429441 expect ( toolSegment . input ) . toEqual ( { input : 'test' } )
430- expect ( toolSegment . output ) . toEqual ( {
431- error : true ,
432- message : 'Tool execution failed' ,
433- tool : 'custom_failing_tool' ,
434- } )
442+ expect ( toolSegment . output ) . toEqual ( toolResult )
435443 } )
436444
437445 it . concurrent ( 'handles blocks without tool calls' , ( ) => {
0 commit comments