@@ -1224,19 +1224,17 @@ function M:handle_chat_content_received(params)
12241224 self :_handle_tool_call_prepare (content )
12251225 -- IMPORTANT: Return immediately - do NOT display anything for toolCallPrepare
12261226 return
1227+ elseif content .type == " toolCallRunning" then
1228+ -- Show the accumulated tool call
1229+ self :_display_tool_call (content )
12271230 elseif content .type == " toolCalled" then
1228- local tool_text = nil
1231+ local tool_text = ( content . summary or " Tool call " )
12291232
12301233 -- Add diff to current tool call if present in toolCalled content
12311234 if self ._current_tool_call and content .details then
12321235 self ._current_tool_call .details = content .details
12331236 end
12341237
1235- -- Show the final accumulated tool call if we have one
1236- if self ._is_tool_call_streaming and self ._current_tool_call then
1237- tool_text = self :_display_tool_call ()
1238- end
1239-
12401238 -- Show the tool result
12411239 local tool_log = string.format (" **Tool Result**: %s" , content .name or " unknown" )
12421240 if content .outputs and # content .outputs > 0 then
@@ -1254,9 +1252,10 @@ function M:handle_chat_content_received(params)
12541252 tool_text_completed = " ❌ "
12551253 end
12561254
1257- tool_text_completed = tool_text_completed .. (content .summary or content .name or " Tool call completed" )
1255+ local tool_text_running = " 🔧 " .. tool_text
1256+ tool_text_completed = tool_text_completed .. tool_text
12581257
1259- if tool_text == nil or not self :_replace_text (tool_text or " " , tool_text_completed ) then
1258+ if tool_text == nil or not self :_replace_text (tool_text_running , tool_text_completed ) then
12601259 self :_add_message (" assistant" , tool_text_completed )
12611260 end
12621261
@@ -1562,14 +1561,13 @@ function M:_handle_tool_call_prepare(content)
15621561 end
15631562end
15641563
1565- --- @return string tool text
1566- function M :_display_tool_call ()
1567- if not self ._current_tool_call then
1564+ function M :_display_tool_call (content )
1565+ if not self ._is_tool_call_streaming or not self ._current_tool_call then
15681566 return nil
15691567 end
15701568
15711569 local diff = " "
1572- local tool_text = " 🔧 " .. (self ._current_tool_call .summary or " Tool call prepared " )
1570+ local tool_text = " 🔧 " .. (content . summary or self ._current_tool_call .summary or " Tool call" )
15731571 local tool_log = string.format (" **Tool Call**: %s" , self ._current_tool_call .name or " unknown" )
15741572
15751573 if self ._current_tool_call .arguments and self ._current_tool_call .arguments ~= " " then
@@ -1582,8 +1580,6 @@ function M:_display_tool_call()
15821580
15831581 Logger .debug (tool_log .. diff )
15841582 self :_add_message (" assistant" , tool_text .. diff )
1585-
1586- return tool_text
15871583end
15881584
15891585function M :_finalize_tool_call ()
0 commit comments