2525from openai .types .responses .response_input_param import ComputerCallOutput
2626from openai .types .responses .response_reasoning_item import ResponseReasoningItem
2727
28- from . import _utils
2928from .agent import Agent
3029from .agent_output import AgentOutputSchema
3130from .computer import AsyncComputer , Computer
5958 handoff_span ,
6059 trace ,
6160)
61+ from .util import _coro , _error_tracing
6262
6363if TYPE_CHECKING :
6464 from .run import RunConfig
@@ -293,7 +293,7 @@ def process_model_response(
293293 elif isinstance (output , ResponseComputerToolCall ):
294294 items .append (ToolCallItem (raw_item = output , agent = agent ))
295295 if not computer_tool :
296- _utils .attach_error_to_current_span (
296+ _error_tracing .attach_error_to_current_span (
297297 SpanError (
298298 message = "Computer tool not found" ,
299299 data = {},
@@ -324,7 +324,7 @@ def process_model_response(
324324 # Regular function tool call
325325 else :
326326 if output .name not in function_map :
327- _utils .attach_error_to_current_span (
327+ _error_tracing .attach_error_to_current_span (
328328 SpanError (
329329 message = "Tool not found" ,
330330 data = {"tool_name" : output .name },
@@ -368,7 +368,7 @@ async def run_single_tool(
368368 (
369369 agent .hooks .on_tool_start (context_wrapper , agent , func_tool )
370370 if agent .hooks
371- else _utils .noop_coroutine ()
371+ else _coro .noop_coroutine ()
372372 ),
373373 func_tool .on_invoke_tool (context_wrapper , tool_call .arguments ),
374374 )
@@ -378,11 +378,11 @@ async def run_single_tool(
378378 (
379379 agent .hooks .on_tool_end (context_wrapper , agent , func_tool , result )
380380 if agent .hooks
381- else _utils .noop_coroutine ()
381+ else _coro .noop_coroutine ()
382382 ),
383383 )
384384 except Exception as e :
385- _utils .attach_error_to_current_span (
385+ _error_tracing .attach_error_to_current_span (
386386 SpanError (
387387 message = "Error running tool" ,
388388 data = {"tool_name" : func_tool .name , "error" : str (e )},
@@ -502,7 +502,7 @@ async def execute_handoffs(
502502 source = agent ,
503503 )
504504 if agent .hooks
505- else _utils .noop_coroutine ()
505+ else _coro .noop_coroutine ()
506506 ),
507507 )
508508
@@ -520,7 +520,7 @@ async def execute_handoffs(
520520 new_items = tuple (new_step_items ),
521521 )
522522 if not callable (input_filter ):
523- _utils .attach_error_to_span (
523+ _error_tracing .attach_error_to_span (
524524 span_handoff ,
525525 SpanError (
526526 message = "Invalid input filter" ,
@@ -530,7 +530,7 @@ async def execute_handoffs(
530530 raise UserError (f"Invalid input filter: { input_filter } " )
531531 filtered = input_filter (handoff_input_data )
532532 if not isinstance (filtered , HandoffInputData ):
533- _utils .attach_error_to_span (
533+ _error_tracing .attach_error_to_span (
534534 span_handoff ,
535535 SpanError (
536536 message = "Invalid input filter result" ,
@@ -591,7 +591,7 @@ async def run_final_output_hooks(
591591 hooks .on_agent_end (context_wrapper , agent , final_output ),
592592 agent .hooks .on_end (context_wrapper , agent , final_output )
593593 if agent .hooks
594- else _utils .noop_coroutine (),
594+ else _coro .noop_coroutine (),
595595 )
596596
597597 @classmethod
@@ -706,7 +706,7 @@ async def execute(
706706 (
707707 agent .hooks .on_tool_start (context_wrapper , agent , action .computer_tool )
708708 if agent .hooks
709- else _utils .noop_coroutine ()
709+ else _coro .noop_coroutine ()
710710 ),
711711 output_func ,
712712 )
@@ -716,7 +716,7 @@ async def execute(
716716 (
717717 agent .hooks .on_tool_end (context_wrapper , agent , action .computer_tool , output )
718718 if agent .hooks
719- else _utils .noop_coroutine ()
719+ else _coro .noop_coroutine ()
720720 ),
721721 )
722722
0 commit comments