@@ -28,6 +28,7 @@ import { ChatAgentLocation } from '../../contrib/chat/common/constants.js';
2828import { checkProposedApiEnabled , isProposedApiEnabled } from '../../services/extensions/common/extensions.js' ;
2929import { Dto } from '../../services/extensions/common/proxyIdentifier.js' ;
3030import { ExtHostChatAgentsShape2 , IChatAgentCompletionItem , IChatAgentHistoryEntryDto , IChatAgentProgressShape , IChatProgressDto , IChatSessionContextDto , IExtensionChatAgentMetadata , IMainContext , MainContext , MainThreadChatAgentsShape2 } from './extHost.protocol.js' ;
31+ import { onUnexpectedError } from '../../../base/common/errors.js' ;
3132import { CommandsConverter , ExtHostCommands } from './extHostCommands.js' ;
3233import { ExtHostDiagnostics } from './extHostDiagnostics.js' ;
3334import { ExtHostDocuments } from './extHostDocuments.js' ;
@@ -772,18 +773,24 @@ export class ExtHostChatAgents2 extends Disposable implements ExtHostChatAgentsS
772773 const convertedHistory = await this . prepareHistoryTurns ( agent . extension , agent . id , context ) ;
773774
774775 const ehResult = typeConvert . ChatAgentResult . to ( result ) ;
775- return ( await agent . provideFollowups ( ehResult , { history : convertedHistory } , token ) )
776- . filter ( f => {
777- // The followup must refer to a participant that exists from the same extension
778- const isValid = ! f . participant || Iterable . some (
779- this . _agents . values ( ) ,
780- a => a . id === f . participant && ExtensionIdentifier . equals ( a . extension . identifier , agent . extension . identifier ) ) ;
781- if ( ! isValid ) {
782- this . _logService . warn ( `[@${ agent . id } ] ChatFollowup refers to an unknown participant: ${ f . participant } ` ) ;
783- }
784- return isValid ;
785- } )
786- . map ( f => typeConvert . ChatFollowup . from ( f , request ) ) ;
776+ try {
777+ const followups = await agent . provideFollowups ( ehResult , { history : convertedHistory } , token ) ;
778+ return ( followups ?? [ ] )
779+ . filter ( f => {
780+ // The followup must refer to a participant that exists from the same extension
781+ const isValid = ! f . participant || Iterable . some (
782+ this . _agents . values ( ) ,
783+ a => a . id === f . participant && ExtensionIdentifier . equals ( a . extension . identifier , agent . extension . identifier ) ) ;
784+ if ( ! isValid ) {
785+ this . _logService . warn ( `[@${ agent . id } ] ChatFollowup refers to an unknown participant: ${ f . participant } ` ) ;
786+ }
787+ return isValid ;
788+ } )
789+ . map ( f => typeConvert . ChatFollowup . from ( f , request ) ) ;
790+ } catch ( err ) {
791+ onUnexpectedError ( err ) ;
792+ return [ ] ;
793+ }
787794 }
788795
789796 $acceptFeedback ( handle : number , result : IChatAgentResult , voteAction : IChatVoteAction ) : void {
@@ -854,7 +861,12 @@ export class ExtHostChatAgents2 extends Disposable implements ExtHostChatAgentsS
854861 }
855862
856863 const history = await this . prepareHistoryTurns ( agent . extension , agent . id , { history : context } ) ;
857- return await agent . provideTitle ( { history } , token ) ;
864+ try {
865+ return await agent . provideTitle ( { history } , token ) ?? undefined ;
866+ } catch ( err ) {
867+ onUnexpectedError ( err ) ;
868+ return undefined ;
869+ }
858870 }
859871
860872 async $provideChatSummary ( handle : number , context : IChatAgentHistoryEntryDto [ ] , token : CancellationToken ) : Promise < string | undefined > {
@@ -864,7 +876,12 @@ export class ExtHostChatAgents2 extends Disposable implements ExtHostChatAgentsS
864876 }
865877
866878 const history = await this . prepareHistoryTurns ( agent . extension , agent . id , { history : context } ) ;
867- return await agent . provideSummary ( { history } , token ) ;
879+ try {
880+ return await agent . provideSummary ( { history } , token ) ?? undefined ;
881+ } catch ( err ) {
882+ onUnexpectedError ( err ) ;
883+ return undefined ;
884+ }
868885 }
869886}
870887
@@ -930,31 +947,46 @@ class ExtHostChatAgent {
930947 return [ ] ;
931948 }
932949
933- const followups = await this . _followupProvider . provideFollowups ( result , context , token ) ;
934- if ( ! followups ) {
950+ try {
951+ const followups = await this . _followupProvider . provideFollowups ( result , context , token ) ;
952+ if ( ! followups ) {
953+ return [ ] ;
954+ }
955+ return followups
956+ // Filter out "command followups" from older providers
957+ . filter ( f => ! ( f && 'commandId' in f ) )
958+ // Filter out followups from older providers before 'message' changed to 'prompt'
959+ . filter ( f => ! ( f && 'message' in f ) ) ;
960+ } catch ( err ) {
961+ onUnexpectedError ( err ) ;
935962 return [ ] ;
936963 }
937- return followups
938- // Filter out "command followups" from older providers
939- . filter ( f => ! ( f && 'commandId' in f ) )
940- // Filter out followups from older providers before 'message' changed to 'prompt'
941- . filter ( f => ! ( f && 'message' in f ) ) ;
942964 }
943965
944966 async provideTitle ( context : vscode . ChatContext , token : CancellationToken ) : Promise < string | undefined > {
945967 if ( ! this . _titleProvider ) {
946968 return ;
947969 }
948970
949- return await this . _titleProvider . provideChatTitle ( context , token ) ?? undefined ;
971+ try {
972+ return await this . _titleProvider . provideChatTitle ( context , token ) ?? undefined ;
973+ } catch ( err ) {
974+ onUnexpectedError ( err ) ;
975+ return undefined ;
976+ }
950977 }
951978
952979 async provideSummary ( context : vscode . ChatContext , token : CancellationToken ) : Promise < string | undefined > {
953980 if ( ! this . _summarizer ) {
954981 return ;
955982 }
956983
957- return await this . _summarizer . provideChatSummary ( context , token ) ?? undefined ;
984+ try {
985+ return await this . _summarizer . provideChatSummary ( context , token ) ?? undefined ;
986+ } catch ( err ) {
987+ onUnexpectedError ( err ) ;
988+ return undefined ;
989+ }
958990 }
959991
960992 get apiAgent ( ) : vscode . ChatParticipant {
0 commit comments