MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / handleToolCall

Function handleToolCall

cli/src/utils/sdk-event-handlers.ts:331–356  ·  view source on GitHub ↗
(state: EventHandlerState, event: PrintModeToolCall)

Source from the content-addressed store, hash-verified

329}
330
331const 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.

Callers 1

createEventHandlerFunction · 0.70

Calls 5

isHiddenToolNameFunction · 0.85
handleRegularToolCallFunction · 0.85
updateStreamingAgentsFunction · 0.85

Tested by

no test coverage detected