@@ -545,6 +545,7 @@ export class ChatService extends Disposable implements IChatService {
545
545
const agentPart = 'kind' in parsedRequest ? undefined : parsedRequest . parts . find ( ( r ) : r is ChatRequestAgentPart => r instanceof ChatRequestAgentPart ) ;
546
546
const agentSlashCommandPart = 'kind' in parsedRequest ? undefined : parsedRequest . parts . find ( ( r ) : r is ChatRequestAgentSubcommandPart => r instanceof ChatRequestAgentSubcommandPart ) ;
547
547
const commandPart = 'kind' in parsedRequest ? undefined : parsedRequest . parts . find ( ( r ) : r is ChatRequestSlashCommandPart => r instanceof ChatRequestSlashCommandPart ) ;
548
+ const requests = [ ...model . getRequests ( ) ] ;
548
549
549
550
let gotProgress = false ;
550
551
const requestType = commandPart ? 'slashCommand' : 'string' ;
@@ -638,7 +639,7 @@ export class ChatService extends Disposable implements IChatService {
638
639
639
640
if ( this . configurationService . getValue ( 'chat.experimental.detectParticipant.enabled' ) !== false && this . chatAgentService . hasChatParticipantDetectionProviders ( ) && ! agentPart && ! commandPart && enableCommandDetection ) {
640
641
// We have no agent or command to scope history with, pass the full history to the participant detection provider
641
- const defaultAgentHistory = this . getHistoryEntriesFromModel ( model , location , defaultAgent . id ) ;
642
+ const defaultAgentHistory = this . getHistoryEntriesFromModel ( requests , model . sessionId , location , defaultAgent . id ) ;
642
643
643
644
// Prepare the request object that we will send to the participant detection provider
644
645
const chatAgentRequest = await prepareChatAgentRequest ( defaultAgent , agentSlashCommandPart ?. command , enableCommandDetection , undefined , false ) ;
@@ -657,7 +658,7 @@ export class ChatService extends Disposable implements IChatService {
657
658
await this . extensionService . activateByEvent ( `onChatParticipant:${ agent . id } ` ) ;
658
659
659
660
// Recompute history in case the agent or command changed
660
- const history = this . getHistoryEntriesFromModel ( model , location , agent . id ) ;
661
+ const history = this . getHistoryEntriesFromModel ( requests , model . sessionId , location , agent . id ) ;
661
662
const requestProps = await prepareChatAgentRequest ( agent , command , enableCommandDetection , request /* Reuse the request object if we already created it for participant detection */ , ! ! detectedAgent ) ;
662
663
const pendingRequest = this . _pendingRequests . get ( sessionId ) ;
663
664
if ( pendingRequest && ! pendingRequest . requestId ) {
@@ -667,7 +668,7 @@ export class ChatService extends Disposable implements IChatService {
667
668
const agentResult = await this . chatAgentService . invokeAgent ( agent . id , requestProps , progressCallback , history , token ) ;
668
669
rawResult = agentResult ;
669
670
agentOrCommandFollowups = this . chatAgentService . getFollowups ( agent . id , requestProps , agentResult , history , followupsCancelToken ) ;
670
- chatTitlePromise = model . getRequests ( ) . length === 1 && ! model . customTitle ? this . chatAgentService . getChatTitle ( defaultAgent . id , this . getHistoryEntriesFromModel ( model , location , agent . id ) , CancellationToken . None ) : undefined ;
671
+ chatTitlePromise = model . getRequests ( ) . length === 1 && ! model . customTitle ? this . chatAgentService . getChatTitle ( defaultAgent . id , this . getHistoryEntriesFromModel ( model . getRequests ( ) , model . sessionId , location , agent . id ) , CancellationToken . None ) : undefined ;
671
672
} else if ( commandPart && this . chatSlashCommandService . hasCommand ( commandPart . slashCommand . command ) ) {
672
673
request = model . addRequest ( parsedRequest , { variables : [ ] } , attempt ) ;
673
674
completeResponseCreated ( ) ;
@@ -774,9 +775,9 @@ export class ChatService extends Disposable implements IChatService {
774
775
} ;
775
776
}
776
777
777
- private getHistoryEntriesFromModel ( model : IChatModel , location : ChatAgentLocation , forAgentId : string ) : IChatAgentHistoryEntry [ ] {
778
+ private getHistoryEntriesFromModel ( requests : IChatRequestModel [ ] , sessionId : string , location : ChatAgentLocation , forAgentId : string ) : IChatAgentHistoryEntry [ ] {
778
779
const history : IChatAgentHistoryEntry [ ] = [ ] ;
779
- for ( const request of model . getRequests ( ) ) {
780
+ for ( const request of requests ) {
780
781
if ( ! request . response ) {
781
782
continue ;
782
783
}
@@ -790,7 +791,7 @@ export class ChatService extends Disposable implements IChatService {
790
791
791
792
const promptTextResult = getPromptText ( request . message ) ;
792
793
const historyRequest : IChatAgentRequest = {
793
- sessionId : model . sessionId ,
794
+ sessionId : sessionId ,
794
795
requestId : request . id ,
795
796
agentId : request . response . agent ?. id ?? '' ,
796
797
message : promptTextResult . message ,
0 commit comments