@@ -1224,19 +1224,17 @@ function M:handle_chat_content_received(params)
1224
1224
self :_handle_tool_call_prepare (content )
1225
1225
-- IMPORTANT: Return immediately - do NOT display anything for toolCallPrepare
1226
1226
return
1227
+ elseif content .type == " toolCallRunning" then
1228
+ -- Show the accumulated tool call
1229
+ self :_display_tool_call (content )
1227
1230
elseif content .type == " toolCalled" then
1228
- local tool_text = nil
1231
+ local tool_text = ( content . summary or " Tool call " )
1229
1232
1230
1233
-- Add diff to current tool call if present in toolCalled content
1231
1234
if self ._current_tool_call and content .details then
1232
1235
self ._current_tool_call .details = content .details
1233
1236
end
1234
1237
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
-
1240
1238
-- Show the tool result
1241
1239
local tool_log = string.format (" **Tool Result**: %s" , content .name or " unknown" )
1242
1240
if content .outputs and # content .outputs > 0 then
@@ -1254,9 +1252,10 @@ function M:handle_chat_content_received(params)
1254
1252
tool_text_completed = " ❌ "
1255
1253
end
1256
1254
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
1258
1257
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
1260
1259
self :_add_message (" assistant" , tool_text_completed )
1261
1260
end
1262
1261
@@ -1562,14 +1561,13 @@ function M:_handle_tool_call_prepare(content)
1562
1561
end
1563
1562
end
1564
1563
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
1568
1566
return nil
1569
1567
end
1570
1568
1571
1569
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" )
1573
1571
local tool_log = string.format (" **Tool Call**: %s" , self ._current_tool_call .name or " unknown" )
1574
1572
1575
1573
if self ._current_tool_call .arguments and self ._current_tool_call .arguments ~= " " then
@@ -1582,8 +1580,6 @@ function M:_display_tool_call()
1582
1580
1583
1581
Logger .debug (tool_log .. diff )
1584
1582
self :_add_message (" assistant" , tool_text .. diff )
1585
-
1586
- return tool_text
1587
1583
end
1588
1584
1589
1585
function M :_finalize_tool_call ()
0 commit comments