@@ -524,6 +524,7 @@ export class AgenticChatController implements ChatHandlers {
524524 let currentRequestInput = { ...initialRequestInput }
525525 let finalResult : Result < AgenticChatResultWithMetadata , string > | null = null
526526 let iterationCount = 0
527+ let shouldDisplayMessage = true
527528 metric . recordStart ( )
528529
529530 while ( iterationCount < maxAgentLoopIterations ) {
@@ -574,8 +575,10 @@ export class AgenticChatController implements ChatHandlers {
574575 userIntent : currentMessage . userInputMessage ?. userIntent ,
575576 origin : currentMessage . userInputMessage ?. origin ,
576577 userInputMessageContext : currentMessage . userInputMessage ?. userInputMessageContext ,
578+ shouldDisplayMessage : shouldDisplayMessage ,
577579 } )
578580 }
581+ shouldDisplayMessage = true
579582
580583 // Phase 4: Response Processing
581584 const result = await this . #processGenerateAssistantResponseResponseWithTimeout(
@@ -620,6 +623,7 @@ export class AgenticChatController implements ChatHandlers {
620623 name : result . data ! . toolUses [ k ] . name ,
621624 input : result . data ! . toolUses [ k ] . input ,
622625 } ) ) ,
626+ shouldDisplayMessage : shouldDisplayMessage ,
623627 } )
624628 } else {
625629 this . #features. logging . warn ( 'No ChatResult body in response, skipping adding to history' )
@@ -641,6 +645,7 @@ export class AgenticChatController implements ChatHandlers {
641645 toolResults = await this . #processToolUses( pendingToolUses , chatResultStream , session , tabId , token )
642646 if ( toolResults . some ( toolResult => this . #shouldSendBackErrorContent( toolResult ) ) ) {
643647 content = 'There was an error processing one or more tool uses. Try again, do not apologize.'
648+ shouldDisplayMessage = false
644649 }
645650 metric . setDimension ( 'cwsprChatConversationType' , 'AgenticChatWithToolUse' )
646651 } else {
@@ -653,6 +658,7 @@ export class AgenticChatController implements ChatHandlers {
653658 if ( result . error . startsWith ( 'ToolUse input is invalid JSON:' ) ) {
654659 content =
655660 'Your toolUse input is incomplete because it is too large. Break this task down into multiple tool uses with smaller input. Do not apologize.'
661+ shouldDisplayMessage = false
656662 }
657663 }
658664 currentRequestInput = this . #updateRequestInputWithToolResults( currentRequestInput , toolResults , content )
0 commit comments