Skip to content

Commit 4d63b40

Browse files
authored
loading instructions on demand needs agent mode (microsoft#256669)
1 parent 62129d0 commit 4d63b40

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

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

Lines changed: 12 additions & 10 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';
@@ -2019,21 +2019,23 @@ export class ChatWidget extends Disposable implements IChatWidget {
20192019
this.logService.debug(`ChatWidget#_autoAttachInstructions: ${PromptsConfig.KEY}: ${promptsConfigEnabled}`);
20202020

20212021
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());
20292023
await computer.collect(attachedContext, CancellationToken.None);
20302024
} else {
20312025
const computer = this.instantiationService.createInstance(ComputeAutomaticInstructions, undefined);
20322026
await computer.collectCopilotInstructionsOnly(attachedContext, CancellationToken.None);
20332027
}
2028+
}
20342029

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;
20372039
}
20382040
}
20392041

0 commit comments

Comments
 (0)