@@ -605,6 +605,19 @@ type ResolvedToolCallOutcome =
605605 | { kind : "resolved" ; tool ?: AgentTool }
606606 | { kind : "error" ; error : unknown } ;
607607
608+ function hidesToolCallFromChannelProgress (
609+ context : AgentContext ,
610+ toolCall : AgentToolCall ,
611+ resolvedToolCalls : Map < AgentToolCall , ResolvedToolCallOutcome > ,
612+ ) : boolean {
613+ const resolution = resolvedToolCalls . get ( toolCall ) ;
614+ const tool =
615+ resolution ?. kind === "resolved"
616+ ? resolution . tool
617+ : context . tools ?. find ( ( candidate ) => candidate . name === toolCall . name ) ;
618+ return tool ?. hideFromChannelProgress === true ;
619+ }
620+
608621async function executeToolCallsSequential (
609622 currentContext : AgentContext ,
610623 assistantMessage : AssistantMessage ,
@@ -618,11 +631,17 @@ async function executeToolCallsSequential(
618631 const messages : ToolResultMessage [ ] = [ ] ;
619632
620633 for ( const toolCall of toolCalls ) {
634+ const hideFromChannelProgress = hidesToolCallFromChannelProgress (
635+ currentContext ,
636+ toolCall ,
637+ resolvedToolCalls ,
638+ ) ;
621639 await emit ( {
622640 type : "tool_execution_start" ,
623641 toolCallId : toolCall . id ,
624642 toolName : toolCall . name ,
625643 args : toolCall . arguments ,
644+ ...( hideFromChannelProgress ? { hideFromChannelProgress : true } : { } ) ,
626645 } ) ;
627646
628647 const preparation = await prepareToolCall (
@@ -640,6 +659,7 @@ async function executeToolCallsSequential(
640659 result : preparation . result ,
641660 isError : preparation . isError ,
642661 executionStarted : false ,
662+ ...( hideFromChannelProgress ? { hideFromChannelProgress : true } : { } ) ,
643663 } ;
644664 } else {
645665 const executed = await executePreparedToolCall ( preparation , signal , emit ) ;
@@ -682,11 +702,17 @@ async function executeToolCallsParallel(
682702 const finalizedCalls : FinalizedToolCallEntry [ ] = [ ] ;
683703
684704 for ( const toolCall of toolCalls ) {
705+ const hideFromChannelProgress = hidesToolCallFromChannelProgress (
706+ currentContext ,
707+ toolCall ,
708+ resolvedToolCalls ,
709+ ) ;
685710 await emit ( {
686711 type : "tool_execution_start" ,
687712 toolCallId : toolCall . id ,
688713 toolName : toolCall . name ,
689714 args : toolCall . arguments ,
715+ ...( hideFromChannelProgress ? { hideFromChannelProgress : true } : { } ) ,
690716 } ) ;
691717
692718 const preparation = await prepareToolCall (
@@ -703,6 +729,7 @@ async function executeToolCallsParallel(
703729 result : preparation . result ,
704730 isError : preparation . isError ,
705731 executionStarted : false ,
732+ ...( hideFromChannelProgress ? { hideFromChannelProgress : true } : { } ) ,
706733 } satisfies FinalizedToolCallOutcome ;
707734 await emitToolExecutionEnd ( finalized , emit ) ;
708735 finalizedCalls . push ( finalized ) ;
@@ -769,6 +796,7 @@ type FinalizedToolCallOutcome = {
769796 result : AgentToolResult < unknown > ;
770797 isError : boolean ;
771798 executionStarted : boolean ;
799+ hideFromChannelProgress ?: boolean ;
772800} ;
773801
774802type FinalizedToolCallEntry = FinalizedToolCallOutcome | ( ( ) => Promise < FinalizedToolCallOutcome > ) ;
@@ -947,6 +975,9 @@ async function executePreparedToolCall(
947975 toolName : prepared . toolCall . name ,
948976 args : prepared . toolCall . arguments ,
949977 partialResult,
978+ ...( prepared . tool . hideFromChannelProgress === true
979+ ? { hideFromChannelProgress : true }
980+ : { } ) ,
950981 } ) ,
951982 ) ,
952983 ) ;
@@ -1006,6 +1037,7 @@ async function finalizeExecutedToolCall(
10061037 result,
10071038 isError,
10081039 executionStarted : true ,
1040+ ...( prepared . tool . hideFromChannelProgress === true ? { hideFromChannelProgress : true } : { } ) ,
10091041 } ;
10101042}
10111043
@@ -1027,6 +1059,7 @@ async function emitToolExecutionEnd(
10271059 result : finalized . result ,
10281060 isError : finalized . isError ,
10291061 executionStarted : finalized . executionStarted ,
1062+ ...( finalized . hideFromChannelProgress === true ? { hideFromChannelProgress : true } : { } ) ,
10301063 } ) ;
10311064}
10321065
0 commit comments