(List<LlmClient.ToolCall> toolCalls, int iteration)
| 592 | } |
| 593 | |
| 594 | private List<ToolExecutionResult> executeToolCalls(List<LlmClient.ToolCall> toolCalls, int iteration) { |
| 595 | List<ToolInvocation> invocations = new ArrayList<>(); |
| 596 | for (LlmClient.ToolCall toolCall : toolCalls) { |
| 597 | String toolName = toolCall.function().name(); |
| 598 | String toolArgs = toolCall.function().arguments(); |
| 599 | log.info("Scheduling tool: {} (iteration={})", toolName, iteration); |
| 600 | log.debug("Tool args [{}]: {}", toolName, toolArgs); |
| 601 | invocations.add(new ToolInvocation(toolCall.id(), toolName, toolArgs)); |
| 602 | } |
| 603 | |
| 604 | if (invocations.size() > 1) { |
| 605 | log.info("Executing {} tool calls in parallel (iteration={})", invocations.size(), iteration); |
| 606 | } |
| 607 | List<ToolExecutionResult> results = toolRegistry.executeTools(invocations); |
| 608 | for (ToolExecutionResult result : results) { |
| 609 | log.debug("Tool result preview [{}]: {}", result.name(), preview(result.result(), 300)); |
| 610 | emitToolResultSummary(result); |
| 611 | } |
| 612 | return results; |
| 613 | } |
| 614 | |
| 615 | private void emitToolResultSummary(ToolExecutionResult result) { |
| 616 | if (result == null || result.name() == null) { |
no test coverage detected