@@ -170,7 +170,7 @@ describe("assistant.message with toolRequests", () => {
170170 data : {
171171 toolRequests : [
172172 { toolCallId : "tc1" , name : "bash" , arguments : { command : "ls" } } ,
173- { toolCallId : "tc2" , name : "read_file " , arguments : { path : "/tmp/x " } } ,
173+ { toolCallId : "tc2" , name : "glob " , arguments : { pattern : "**/*.ts " } } ,
174174 ] ,
175175 } ,
176176 } as SessionEvent ;
@@ -196,7 +196,7 @@ describe("assistant.message with toolRequests", () => {
196196 } [ ] ;
197197 const toolStart = events . find ( ( e ) => e . type === "block.start" && e . block ?. type === "tool_use" ) ;
198198 expect ( toolStart ?. block ?. id ) . toBe ( "tc1" ) ;
199- expect ( toolStart ?. block ?. name ) . toBe ( "bash " ) ;
199+ expect ( toolStart ?. block ?. name ) . toBe ( "Bash " ) ;
200200 expect ( toolStart ?. block ?. input ) . toEqual ( { command : "ls" } ) ;
201201 } ) ;
202202
@@ -324,7 +324,7 @@ describe("tool.execution_complete failure", () => {
324324// ---------------------------------------------------------------------------
325325
326326describe ( "tool.execution_complete with no matching pending tool_use" , ( ) => {
327- it ( "emits only block.done with type tool_result when no pending tool_use exists " , ( ) => {
327+ it ( "emits no events when toolCallId has no matching pending tool_use" , ( ) => {
328328 const state = makeState ( ) ;
329329 const event = {
330330 type : "tool.execution_complete" ,
@@ -334,9 +334,7 @@ describe("tool.execution_complete with no matching pending tool_use", () => {
334334 type : string ;
335335 block ?: { type : string ; tool_use_id : string ; output : string ; error ?: boolean } ;
336336 } [ ] ;
337- expect ( events ) . toHaveLength ( 1 ) ;
338- expect ( events [ 0 ] . type ) . toBe ( "block.done" ) ;
339- expect ( events [ 0 ] . block ?. type ) . toBe ( "tool_result" ) ;
337+ expect ( events ) . toHaveLength ( 0 ) ;
340338 } ) ;
341339
342340 it ( "does not emit block.done for tool_use when toolCallId does not match any pending entry" , ( ) => {
@@ -350,8 +348,7 @@ describe("tool.execution_complete with no matching pending tool_use", () => {
350348 type : string ;
351349 block ?: { type : string } ;
352350 } [ ] ;
353- expect ( events ) . toHaveLength ( 1 ) ;
354- expect ( events [ 0 ] . block ?. type ) . toBe ( "tool_result" ) ;
351+ expect ( events ) . toHaveLength ( 0 ) ;
355352 } ) ;
356353} ) ;
357354
@@ -559,6 +556,59 @@ describe("session.error", () => {
559556 } ) ;
560557} ) ;
561558
559+ // ---------------------------------------------------------------------------
560+ // internal tool skipping
561+ // ---------------------------------------------------------------------------
562+
563+ describe ( "internal tool skipping" , ( ) => {
564+ it ( "emits no block.start events when all tool requests are internal tools" , ( ) => {
565+ const state = makeState ( { turnOpen : true } ) ;
566+ const event = {
567+ type : "assistant.message" ,
568+ data : {
569+ toolRequests : [ { toolCallId : "tc-skip" , name : "report_intent" , arguments : { } } ] ,
570+ } ,
571+ } as SessionEvent ;
572+ const events = collect ( mapCopilotEvent ( event , state ) ) as {
573+ type : string ;
574+ block ?: { type : string } ;
575+ } [ ] ;
576+ const blockStarts = events . filter ( ( e ) => e . type === "block.start" ) ;
577+ expect ( blockStarts ) . toHaveLength ( 0 ) ;
578+ } ) ;
579+
580+ it ( "emits no events for tool.execution_complete when toolCallId has no matching pending entry" , ( ) => {
581+ const state = makeState ( ) ;
582+ // No pending tool_use registered — simulates a skipped tool whose tc-skip was never stored
583+ const event = {
584+ type : "tool.execution_complete" ,
585+ data : { toolCallId : "tc-skip" , result : { content : "ok" } , success : true } ,
586+ } as SessionEvent ;
587+ const events = collect ( mapCopilotEvent ( event , state ) ) ;
588+ expect ( events ) . toHaveLength ( 0 ) ;
589+ } ) ;
590+
591+ it ( "emits exactly one block.start for bash and skips report_intent in a mixed toolRequests list" , ( ) => {
592+ const state = makeState ( { turnOpen : true } ) ;
593+ const event = {
594+ type : "assistant.message" ,
595+ data : {
596+ toolRequests : [
597+ { toolCallId : "tc-bash" , name : "bash" , arguments : { command : "ls" } } ,
598+ { toolCallId : "tc-skip" , name : "report_intent" , arguments : { } } ,
599+ ] ,
600+ } ,
601+ } as SessionEvent ;
602+ const events = collect ( mapCopilotEvent ( event , state ) ) as {
603+ type : string ;
604+ block ?: { type : string ; name : string } ;
605+ } [ ] ;
606+ const blockStarts = events . filter ( ( e ) => e . type === "block.start" && e . block ?. type === "tool_use" ) ;
607+ expect ( blockStarts ) . toHaveLength ( 1 ) ;
608+ expect ( blockStarts [ 0 ] . block ?. name ) . toBe ( "Bash" ) ;
609+ } ) ;
610+ } ) ;
611+
562612// ---------------------------------------------------------------------------
563613// Unknown event type
564614// ---------------------------------------------------------------------------
0 commit comments