(state: EventHandlerState, event: PrintModeToolCall)
| 329 | } |
| 330 | |
| 331 | const handleToolCall = (state: EventHandlerState, event: PrintModeToolCall) => { |
| 332 | // Close any open native reasoning blocks when a tool call happens |
| 333 | // (agent may go directly from thinking to tool calls without emitting text) |
| 334 | // This must happen BEFORE any early returns (spawn_agents, hidden tools) |
| 335 | if (event.parentAgentId && event.agentId) { |
| 336 | // For agent tool calls, close reasoning in that specific agent |
| 337 | state.message.updater.updateAiMessageBlocks((blocks) => |
| 338 | closeNativeReasoningInAgent(blocks, event.agentId as string), |
| 339 | ) |
| 340 | } else if (!event.parentAgentId) { |
| 341 | // For root tool calls, close reasoning at root level |
| 342 | state.message.updater.updateAiMessageBlocks(closeNativeReasoningBlock) |
| 343 | } |
| 344 | |
| 345 | if (event.toolName === 'spawn_agents' && event.input?.agents) { |
| 346 | handleSpawnAgentsToolCall(state, event) |
| 347 | return |
| 348 | } |
| 349 | |
| 350 | if (isHiddenToolName(event.toolName)) { |
| 351 | return |
| 352 | } |
| 353 | |
| 354 | handleRegularToolCall(state, event) |
| 355 | updateStreamingAgents(state, { add: event.toolCallId }) |
| 356 | } |
| 357 | |
| 358 | /** |
| 359 | * Recursively finds and updates agent blocks that match a spawn_agents tool call. |
no test coverage detected