@@ -332,6 +332,7 @@ def _handle_output_item_done(self, chunk: Dict[str, Any]):
332332 return
333333
334334 # Tool call field mappings: (name_field, server_label_field, args_field, output_field)
335+ # Note: web_search_call uses None for output_field because results aren't exposed in API
335336 tool_map = {
336337 "mcp_call" : ("name" , "server_label" , "arguments" , "output" ),
337338 "function_call" : ("name" , "server_label" , "arguments" , "output" ),
@@ -341,7 +342,7 @@ def _handle_output_item_done(self, chunk: Dict[str, Any]):
341342 "queries" ,
342343 "results" ,
343344 ),
344- "web_search_call" : ("web_search" , "llamastack" , "query" , "results" ),
345+ "web_search_call" : ("web_search" , "llamastack" , "query" , None ),
345346 }
346347
347348 name_field , server_field , args_field , output_field = tool_map [item_type ]
@@ -359,15 +360,27 @@ def _handle_output_item_done(self, chunk: Dict[str, Any]):
359360 # Set final result
360361 is_standard = item_type in ("mcp_call" , "function_call" )
361362 args_val = item .get (args_field )
362- output_val = item .get (output_field )
363+
364+ # Get output value (None if output_field is None)
365+ output_val = item .get (output_field ) if output_field else None
366+
367+ # Format output based on tool type
368+ if output_field is None :
369+ # For tools like web_search that don't expose results
370+ status = item .get ("status" , "completed" )
371+ output = f"Tool execution { status } "
372+ elif output_val is not None :
373+ # For tools that return results
374+ if item_type == "file_search_call" and isinstance (output_val , list ):
375+ output = str (output_val ) if output_val else "No results found"
376+ else :
377+ output = str (output_val )
378+ else :
379+ output = "No results found" if not is_standard else None
363380
364381 tool_call .set_result (
365382 arguments = str (args_val ) if args_val and not is_standard else args_val ,
366- output = (
367- str (output_val )
368- if output_val
369- else ("No results found" if not is_standard else None )
370- ),
383+ output = output ,
371384 error = item .get ("error" ),
372385 )
373386
0 commit comments