MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / runRunnableToolCall

Function runRunnableToolCall

packages/agent-core/src/loop/tool-call.ts:452–486  ·  view source on GitHub ↗
(
  step: ToolCallStepContext,
  call: RunnableToolCall,
  effectiveArgs: unknown,
  metadata: unknown,
  execution: RunnableToolExecution,
)

Source from the content-addressed store, hash-verified

450}
451
452async function runRunnableToolCall(
453 step: ToolCallStepContext,
454 call: RunnableToolCall,
455 effectiveArgs: unknown,
456 metadata: unknown,
457 execution: RunnableToolExecution,
458): Promise<PendingToolResult> {
459 const { signal } = step;
460 const { toolCall, toolName } = call;
461
462 if (signal.aborted) {
463 return makeErrorToolResult(call, effectiveArgs, abortedToolOutput(toolName, signal));
464 }
465
466 let toolResult: ExecutableToolResult;
467 try {
468 const raw = await executeTool(step, execution, toolCall, toolName, metadata);
469 toolResult = coerceToolResult(raw, toolName);
470 } catch (error) {
471 const aborted = isAbortError(error) || signal.aborted;
472 if (!aborted) {
473 step.log?.warn('tool execution failed', {
474 toolName,
475 toolCallId: toolCall.id,
476 error,
477 });
478 }
479 const output = aborted
480 ? abortedToolOutput(toolName, signal)
481 : `Tool "${toolName}" failed: ${errorMessage(error)}`;
482 return makeErrorToolResult(call, effectiveArgs, output);
483 }
484
485 return makeToolResult(call, effectiveArgs, toolResult);
486}
487
488async function finalizePendingToolResult(
489 step: ToolCallBatchContext,

Callers 1

prepareToolCallFunction · 0.85

Calls 8

isAbortErrorFunction · 0.90
errorMessageFunction · 0.90
makeErrorToolResultFunction · 0.85
abortedToolOutputFunction · 0.85
coerceToolResultFunction · 0.85
makeToolResultFunction · 0.85
executeToolFunction · 0.70
warnMethod · 0.65

Tested by

no test coverage detected