@@ -51,7 +51,7 @@ import { ChatViewModel, IChatRequestViewModel, IChatResponseViewModel, isRequest
5151import { IChatInputState } from '../common/chatWidgetHistoryService.js' ;
5252import { CodeBlockModelCollection } from '../common/codeBlockModelCollection.js' ;
5353import { ChatAgentLocation , ChatConfiguration , ChatModeKind } from '../common/constants.js' ;
54- import { ILanguageModelToolsService , ToolSet } from '../common/languageModelToolsService.js' ;
54+ import { ILanguageModelToolsService , IToolData , ToolSet } from '../common/languageModelToolsService.js' ;
5555import { type TPromptMetadata } from '../common/promptSyntax/parsers/promptHeader/promptHeader.js' ;
5656import { IPromptParserResult , IPromptsService } from '../common/promptSyntax/service/promptsService.js' ;
5757import { handleModeSwitch } from './actions/chatActions.js' ;
@@ -1986,12 +1986,7 @@ export class ChatWidget extends Disposable implements IChatWidget {
19861986 this . logService . debug ( `ChatWidget#_autoAttachInstructions: ${ PromptsConfig . KEY } : ${ promptsConfigEnabled } ` ) ;
19871987
19881988 if ( promptsConfigEnabled ) {
1989- let readFileTool = this . toolsService . getToolByName ( 'readFile' ) ;
1990- if ( readFileTool && this . getUserSelectedTools ( ) ?. [ readFileTool . id ] === false ) {
1991- readFileTool = undefined ;
1992- }
1993-
1994- const computer = this . instantiationService . createInstance ( ComputeAutomaticInstructions , readFileTool ) ;
1989+ const computer = this . instantiationService . createInstance ( ComputeAutomaticInstructions , this . _getReadFileTool ( ) ) ;
19951990 await computer . collect ( attachedContext , CancellationToken . None ) ;
19961991 } else {
19971992 const computer = this . instantiationService . createInstance ( ComputeAutomaticInstructions , undefined ) ;
@@ -2000,6 +1995,19 @@ export class ChatWidget extends Disposable implements IChatWidget {
20001995
20011996 // add to attached list to make the instructions sticky
20021997 //this.inputPart.attachmentModel.addContext(...computer.autoAddedInstructions);
1998+
1999+ }
2000+
2001+ private _getReadFileTool ( ) : IToolData | undefined {
2002+ if ( this . input . currentModeKind !== ChatModeKind . Agent ) {
2003+ return undefined ;
2004+ }
2005+
2006+ const readFileTool = this . toolsService . getToolByName ( 'readFile' ) ;
2007+ if ( readFileTool && this . getUserSelectedTools ( ) ?. [ readFileTool . id ] === false ) {
2008+ return undefined ;
2009+ }
2010+ return readFileTool ;
20032011 }
20042012}
20052013
0 commit comments