@@ -51,7 +51,7 @@ import { ChatViewModel, IChatRequestViewModel, IChatResponseViewModel, isRequest
51
51
import { IChatInputState } from '../common/chatWidgetHistoryService.js' ;
52
52
import { CodeBlockModelCollection } from '../common/codeBlockModelCollection.js' ;
53
53
import { ChatAgentLocation , ChatConfiguration , ChatModeKind } from '../common/constants.js' ;
54
- import { ILanguageModelToolsService , ToolSet } from '../common/languageModelToolsService.js' ;
54
+ import { ILanguageModelToolsService , IToolData , ToolSet } from '../common/languageModelToolsService.js' ;
55
55
import { type TPromptMetadata } from '../common/promptSyntax/parsers/promptHeader/promptHeader.js' ;
56
56
import { IPromptParserResult , IPromptsService } from '../common/promptSyntax/service/promptsService.js' ;
57
57
import { handleModeSwitch } from './actions/chatActions.js' ;
@@ -1986,12 +1986,7 @@ export class ChatWidget extends Disposable implements IChatWidget {
1986
1986
this . logService . debug ( `ChatWidget#_autoAttachInstructions: ${ PromptsConfig . KEY } : ${ promptsConfigEnabled } ` ) ;
1987
1987
1988
1988
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 ( ) ) ;
1995
1990
await computer . collect ( attachedContext , CancellationToken . None ) ;
1996
1991
} else {
1997
1992
const computer = this . instantiationService . createInstance ( ComputeAutomaticInstructions , undefined ) ;
@@ -2000,6 +1995,19 @@ export class ChatWidget extends Disposable implements IChatWidget {
2000
1995
2001
1996
// add to attached list to make the instructions sticky
2002
1997
//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 ;
2003
2011
}
2004
2012
}
2005
2013
0 commit comments