MCPcopy
hub / github.com/continuedev/continue / handleToolCall

Method handleToolCall

core/core.ts:1150–1189  ·  view source on GitHub ↗
(toolCall: ToolCall)

Source from the content-addressed store, hash-verified

1148 }
1149
1150 private async handleToolCall(toolCall: ToolCall) {
1151 const { config } = await this.configHandler.loadConfig();
1152 if (!config) {
1153 throw new Error("Config not loaded");
1154 }
1155
1156 const tool = config.tools.find(
1157 (t) => t.function.name === toolCall.function.name,
1158 );
1159
1160 if (!tool) {
1161 throw new Error(`Tool ${toolCall.function.name} not found`);
1162 }
1163
1164 if (!config.selectedModelByRole.chat) {
1165 throw new Error("No chat model selected");
1166 }
1167
1168 // Define a callback for streaming output updates
1169 const onPartialOutput = (params: {
1170 toolCallId: string;
1171 contextItems: ContextItem[];
1172 }) => {
1173 this.messenger.send("toolCallPartialOutput", params);
1174 };
1175
1176 const result = await callTool(tool, toolCall, {
1177 config,
1178 ide: this.ide,
1179 llm: config.selectedModelByRole.chat,
1180 fetch: (url, init) =>
1181 fetchwithRequestOptions(url, init, config.requestOptions),
1182 tool,
1183 toolCallId: toolCall.id,
1184 onPartialOutput,
1185 codeBaseIndexer: this.codeBaseIndexer,
1186 });
1187
1188 return result;
1189 }
1190
1191 private async isItemTooBig(item: ContextItemWithId) {
1192 const { config } = await this.configHandler.loadConfig();

Callers 1

Calls 3

callToolFunction · 0.90
fetchwithRequestOptionsFunction · 0.90
loadConfigMethod · 0.45

Tested by

no test coverage detected