MCPcopy Create free account
hub / github.com/CommandCodeAI/BaseAI / runTools

Method runTools

packages/core/src/pipes/pipes.ts:129–152  ·  view source on GitHub ↗
(toolCalls: ToolCallResult[])

Source from the content-addressed store, hash-verified

127 }
128
129 private async runTools(toolCalls: ToolCallResult[]): Promise<Message[]> {
130 const toolPromises = toolCalls.map(async (toolCall: ToolCallResult) => {
131 const toolName = toolCall.function.name;
132 const toolParameters = JSON.parse(toolCall.function.arguments);
133 const toolFunction = this.tools[toolName];
134
135 if (!toolFunction) {
136 throw new Error(
137 `Tool ${toolName} not found. If this is intentional, please set runTools to false to disable tool execution by default.`,
138 );
139 }
140
141 const toolResponse = await toolFunction(toolParameters);
142
143 return {
144 tool_call_id: toolCall.id,
145 role: 'tool' as MessageRole,
146 name: toolName,
147 content: JSON.stringify(toolResponse),
148 };
149 });
150
151 return Promise.all(toolPromises);
152 }
153
154 private hasNoToolCalls(message: Message): boolean {
155 return !message.tool_calls || message.tool_calls.length === 0;

Callers 2

handleStreamResponseMethod · 0.95
runMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected