@@ -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' ;
@@ -2019,21 +2019,23 @@ export class ChatWidget extends Disposable implements IChatWidget {
2019
2019
this . logService . debug ( `ChatWidget#_autoAttachInstructions: ${ PromptsConfig . KEY } : ${ promptsConfigEnabled } ` ) ;
2020
2020
2021
2021
if ( promptsConfigEnabled ) {
2022
- let readFileTool = this . toolsService . getToolByName ( 'readFile' ) ;
2023
- const enablementMap = this . input . selectedToolsModel . enablementMap . get ( ) ;
2024
- if ( readFileTool && Iterable . some ( enablementMap , ( [ tool , enabled ] ) => tool . id === readFileTool ! . id && enabled === false ) ) {
2025
- readFileTool = undefined ;
2026
- }
2027
-
2028
- const computer = this . instantiationService . createInstance ( ComputeAutomaticInstructions , readFileTool ) ;
2022
+ const computer = this . instantiationService . createInstance ( ComputeAutomaticInstructions , this . _getReadTool ( ) ) ;
2029
2023
await computer . collect ( attachedContext , CancellationToken . None ) ;
2030
2024
} else {
2031
2025
const computer = this . instantiationService . createInstance ( ComputeAutomaticInstructions , undefined ) ;
2032
2026
await computer . collectCopilotInstructionsOnly ( attachedContext , CancellationToken . None ) ;
2033
2027
}
2028
+ }
2034
2029
2035
- // add to attached list to make the instructions sticky
2036
- //this.inputPart.attachmentModel.addContext(...computer.autoAddedInstructions);
2030
+ private _getReadTool ( ) : IToolData | undefined {
2031
+ if ( this . input . currentModeKind !== ChatModeKind . Agent ) {
2032
+ return undefined ;
2033
+ }
2034
+ const readFileTool = this . toolsService . getToolByName ( 'readFile' ) ;
2035
+ if ( ! readFileTool || ! this . input . selectedToolsModel . enablementMap . get ( ) . get ( readFileTool ) ) {
2036
+ return undefined ;
2037
+ }
2038
+ return readFileTool ;
2037
2039
}
2038
2040
}
2039
2041
0 commit comments