25
25
from openai .types .responses .response_input_param import ComputerCallOutput
26
26
from openai .types .responses .response_reasoning_item import ResponseReasoningItem
27
27
28
- from . import _utils
29
28
from .agent import Agent
30
29
from .agent_output import AgentOutputSchema
31
30
from .computer import AsyncComputer , Computer
59
58
handoff_span ,
60
59
trace ,
61
60
)
61
+ from .util import _coro , _error_tracing
62
62
63
63
if TYPE_CHECKING :
64
64
from .run import RunConfig
@@ -293,7 +293,7 @@ def process_model_response(
293
293
elif isinstance (output , ResponseComputerToolCall ):
294
294
items .append (ToolCallItem (raw_item = output , agent = agent ))
295
295
if not computer_tool :
296
- _utils .attach_error_to_current_span (
296
+ _error_tracing .attach_error_to_current_span (
297
297
SpanError (
298
298
message = "Computer tool not found" ,
299
299
data = {},
@@ -324,7 +324,7 @@ def process_model_response(
324
324
# Regular function tool call
325
325
else :
326
326
if output .name not in function_map :
327
- _utils .attach_error_to_current_span (
327
+ _error_tracing .attach_error_to_current_span (
328
328
SpanError (
329
329
message = "Tool not found" ,
330
330
data = {"tool_name" : output .name },
@@ -368,7 +368,7 @@ async def run_single_tool(
368
368
(
369
369
agent .hooks .on_tool_start (context_wrapper , agent , func_tool )
370
370
if agent .hooks
371
- else _utils .noop_coroutine ()
371
+ else _coro .noop_coroutine ()
372
372
),
373
373
func_tool .on_invoke_tool (context_wrapper , tool_call .arguments ),
374
374
)
@@ -378,11 +378,11 @@ async def run_single_tool(
378
378
(
379
379
agent .hooks .on_tool_end (context_wrapper , agent , func_tool , result )
380
380
if agent .hooks
381
- else _utils .noop_coroutine ()
381
+ else _coro .noop_coroutine ()
382
382
),
383
383
)
384
384
except Exception as e :
385
- _utils .attach_error_to_current_span (
385
+ _error_tracing .attach_error_to_current_span (
386
386
SpanError (
387
387
message = "Error running tool" ,
388
388
data = {"tool_name" : func_tool .name , "error" : str (e )},
@@ -502,7 +502,7 @@ async def execute_handoffs(
502
502
source = agent ,
503
503
)
504
504
if agent .hooks
505
- else _utils .noop_coroutine ()
505
+ else _coro .noop_coroutine ()
506
506
),
507
507
)
508
508
@@ -520,7 +520,7 @@ async def execute_handoffs(
520
520
new_items = tuple (new_step_items ),
521
521
)
522
522
if not callable (input_filter ):
523
- _utils .attach_error_to_span (
523
+ _error_tracing .attach_error_to_span (
524
524
span_handoff ,
525
525
SpanError (
526
526
message = "Invalid input filter" ,
@@ -530,7 +530,7 @@ async def execute_handoffs(
530
530
raise UserError (f"Invalid input filter: { input_filter } " )
531
531
filtered = input_filter (handoff_input_data )
532
532
if not isinstance (filtered , HandoffInputData ):
533
- _utils .attach_error_to_span (
533
+ _error_tracing .attach_error_to_span (
534
534
span_handoff ,
535
535
SpanError (
536
536
message = "Invalid input filter result" ,
@@ -591,7 +591,7 @@ async def run_final_output_hooks(
591
591
hooks .on_agent_end (context_wrapper , agent , final_output ),
592
592
agent .hooks .on_end (context_wrapper , agent , final_output )
593
593
if agent .hooks
594
- else _utils .noop_coroutine (),
594
+ else _coro .noop_coroutine (),
595
595
)
596
596
597
597
@classmethod
@@ -706,7 +706,7 @@ async def execute(
706
706
(
707
707
agent .hooks .on_tool_start (context_wrapper , agent , action .computer_tool )
708
708
if agent .hooks
709
- else _utils .noop_coroutine ()
709
+ else _coro .noop_coroutine ()
710
710
),
711
711
output_func ,
712
712
)
@@ -716,7 +716,7 @@ async def execute(
716
716
(
717
717
agent .hooks .on_tool_end (context_wrapper , agent , action .computer_tool , output )
718
718
if agent .hooks
719
- else _utils .noop_coroutine ()
719
+ else _coro .noop_coroutine ()
720
720
),
721
721
)
722
722
0 commit comments