Skip to content

Commit 857a249

Browse files
authored
Normalize tools in execute_prompt loop (#1179)
Fix microsoft/vscode-copilot-issues#284
1 parent f8efcd8 commit 857a249

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/extension/prompt/node/executePromptToolCalling.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { ToolName } from '../../tools/common/toolNames';
2121
import { ChatVariablesCollection } from '../common/chatVariablesCollection';
2222
import { IBuildPromptContext } from '../common/intents';
2323
import { IBuildPromptResult } from './intents';
24+
import { normalizeToolSchema } from '../../tools/common/toolSchemaNormalizer';
2425

2526
export interface IExecutePromptToolCallingLoopOptions extends IToolCallingLoopOptions {
2627
request: ChatRequest;
@@ -93,23 +94,28 @@ export class ExecutePromptToolCallingLoop extends ToolCallingLoop<IExecutePrompt
9394

9495
protected async fetch({ messages, finishedCb, requestOptions }: ToolCallingLoopFetchOptions, token: CancellationToken): Promise<ChatResponse> {
9596
const endpoint = await this.getEndpoint(this.options.request);
96-
return endpoint.makeChatRequest(
97-
ExecutePromptToolCallingLoop.ID,
97+
return endpoint.makeChatRequest2({
98+
debugName: ExecutePromptToolCallingLoop.ID,
9899
messages,
99100
finishedCb,
100-
token,
101-
this.options.location,
102-
undefined,
103-
{
104-
...requestOptions,
105-
temperature: 0
101+
location: this.options.location,
102+
requestOptions: {
103+
...(requestOptions ?? {}),
104+
temperature: 0,
105+
tools: normalizeToolSchema(
106+
endpoint.family,
107+
requestOptions?.tools,
108+
(tool, rule) => {
109+
this._logService.warn(`Tool ${tool} failed validation: ${rule}`);
110+
},
111+
),
106112
},
107113
// This loop is inside a tool called from another request, so never user initiated
108-
false,
109-
{
114+
userInitiatedRequest: false,
115+
telemetryProperties: {
110116
messageId: randomUUID(),
111117
messageSource: ExecutePromptToolCallingLoop.ID
112118
},
113-
);
119+
}, token);
114120
}
115121
}

0 commit comments

Comments
 (0)