( step: ToolCallStepContext, call: RunnableToolCall, effectiveArgs: unknown, metadata: unknown, execution: RunnableToolExecution, )
| 450 | } |
| 451 | |
| 452 | async 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 | |
| 488 | async function finalizePendingToolResult( |
| 489 | step: ToolCallBatchContext, |
no test coverage detected