Skip to content

Commit ebd1bd7

Browse files
authored
Don't resolve variables a second time after intent detection (microsoft#232180)
Fix microsoft/vscode-copilot#9700
1 parent c228ff9 commit ebd1bd7

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

src/vs/workbench/contrib/chat/common/chatServiceImpl.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -609,24 +609,32 @@ export class ChatService extends Disposable implements IChatService {
609609
const initVariableData: IChatRequestVariableData = { variables: [] };
610610
request = chatRequest ?? model.addRequest(parsedRequest, initVariableData, attempt, agent, command, options?.confirmation, options?.locationData, options?.attachedContext, options?.workingSet);
611611

612-
// Variables may have changed if the agent and slash command changed, so resolve them again even if we already had a chatRequest
613-
const variableData = await this.chatVariablesService.resolveVariables(parsedRequest, request.attachedContext, model, progressCallback, token);
614-
for (const variable of variableData.variables) {
615-
if (request.workingSet && variable.isFile && URI.isUri(variable.value)) {
616-
request.workingSet.push(variable.value);
612+
let variableData: IChatRequestVariableData;
613+
let message: string;
614+
if (chatRequest) {
615+
variableData = chatRequest.variableData;
616+
message = getPromptText(request.message).message;
617+
} else {
618+
variableData = await this.chatVariablesService.resolveVariables(parsedRequest, request.attachedContext, model, progressCallback, token);
619+
for (const variable of variableData.variables) {
620+
if (request.workingSet && variable.isFile && URI.isUri(variable.value)) {
621+
request.workingSet.push(variable.value);
622+
}
617623
}
624+
model.updateRequest(request, variableData);
625+
626+
const promptTextResult = getPromptText(request.message);
627+
variableData = updateRanges(variableData, promptTextResult.diff); // TODO bit of a hack
628+
message = promptTextResult.message;
618629
}
619-
model.updateRequest(request, variableData);
620-
const promptTextResult = getPromptText(request.message);
621-
const updatedVariableData = updateRanges(variableData, promptTextResult.diff); // TODO bit of a hack
622630

623631
return {
624632
sessionId,
625633
requestId: request.id,
626634
agentId: agent.id,
627-
message: promptTextResult.message,
635+
message,
628636
command: command?.name,
629-
variables: updatedVariableData,
637+
variables: variableData,
630638
enableCommandDetection,
631639
isParticipantDetected,
632640
attempt,

0 commit comments

Comments
 (0)