Skip to content

Commit c306e94

Browse files
authored
loading instructions on demand needs agent mode (#256675)
1 parent 4782577 commit c306e94

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/vs/workbench/contrib/chat/browser/chatWidget.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import { ChatViewModel, IChatRequestViewModel, IChatResponseViewModel, isRequest
5151
import { IChatInputState } from '../common/chatWidgetHistoryService.js';
5252
import { CodeBlockModelCollection } from '../common/codeBlockModelCollection.js';
5353
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';
5555
import { type TPromptMetadata } from '../common/promptSyntax/parsers/promptHeader/promptHeader.js';
5656
import { IPromptParserResult, IPromptsService } from '../common/promptSyntax/service/promptsService.js';
5757
import { 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

Comments
 (0)