@@ -364,6 +364,7 @@ def _step_stream(self, memory_step: ActionStep) -> Generator[Any]:
364364 # Execute
365365 self .logger .log_code (title = "Executing parsed code:" ,
366366 content = code_action , level = LogLevel .INFO )
367+ exec_start = time .time ()
367368 try :
368369 monitoring_manager = get_monitoring_manager ()
369370 with monitoring_manager .trace_tool_call (
@@ -396,6 +397,7 @@ def _step_stream(self, memory_step: ActionStep) -> Generator[Any]:
396397 ]
397398 observation = "Execution logs:\n " + code_output .logs
398399 except Exception as e :
400+ exec_duration_ms = (time .time () - exec_start ) * 1000
399401 if hasattr (self .python_executor , "state" ) and "_print_outputs" in self .python_executor .state :
400402 execution_logs = str (
401403 self .python_executor .state ["_print_outputs" ])
@@ -410,8 +412,18 @@ def _step_stream(self, memory_step: ActionStep) -> Generator[Any]:
410412 self .logger .log (
411413 Group (* execution_outputs_console ), level = LogLevel .INFO )
412414 error_msg = str (e )
415+ self .logger .log (
416+ f"[Code Execution] step={ memory_step .step_number } failed after { exec_duration_ms :.1f} ms: { error_msg } " ,
417+ level = LogLevel .WARNING ,
418+ )
413419 raise AgentExecutionError (error_msg , self .logger )
414420
421+ exec_duration_ms = (time .time () - exec_start ) * 1000
422+ self .logger .log (
423+ f"[Code Execution] step={ memory_step .step_number } completed in { exec_duration_ms :.1f} ms" ,
424+ level = LogLevel .INFO ,
425+ )
426+
415427 truncated_output = None
416428 if code_output is not None and code_output .output is not None :
417429 truncated_output = truncate_content (str (code_output .output ))
0 commit comments