7878 LocalShellTool ,
7979 MCPToolApprovalRequest ,
8080 Tool ,
81+ ToolRunFunction ,
82+ ToolRunComputerAction ,
8183)
8284from .tool_context import ToolContext
8385from .tracing import (
@@ -126,19 +128,6 @@ class ToolRunHandoff:
126128 handoff : Handoff
127129 tool_call : ResponseFunctionToolCall
128130
129-
130- @dataclass
131- class ToolRunFunction :
132- tool_call : ResponseFunctionToolCall
133- function_tool : FunctionTool
134-
135-
136- @dataclass
137- class ToolRunComputerAction :
138- tool_call : ResponseComputerToolCall
139- computer_tool : ComputerTool
140-
141-
142131@dataclass
143132class ToolRunMCPApprovalRequest :
144133 request_item : McpApprovalRequest
@@ -544,9 +533,9 @@ async def execute_function_tool_calls(
544533 context_wrapper : RunContextWrapper [TContext ],
545534 config : RunConfig ,
546535 ) -> list [FunctionToolResult ]:
547- async def run_single_tool (
548- func_tool : FunctionTool , tool_call : ResponseFunctionToolCall
549- ) -> Any :
536+ async def run_single_tool (action : ToolRunFunction ) -> Any :
537+ func_tool = action . function_tool
538+ tool_call = action . tool_call
550539 with function_span (func_tool .name ) as span_fn :
551540 tool_context = ToolContext .from_agent_context (
552541 context_wrapper ,
@@ -557,9 +546,9 @@ async def run_single_tool(
557546 span_fn .span_data .input = tool_call .arguments
558547 try :
559548 _ , _ , result = await asyncio .gather (
560- hooks .on_tool_start (tool_context , agent , func_tool ),
549+ hooks .on_tool_start (context_wrapper , agent , action ),
561550 (
562- agent .hooks .on_tool_start (tool_context , agent , func_tool )
551+ agent .hooks .on_tool_start (context_wrapper , agent , action )
563552 if agent .hooks
564553 else _coro .noop_coroutine ()
565554 ),
@@ -591,8 +580,7 @@ async def run_single_tool(
591580
592581 tasks = []
593582 for tool_run in tool_runs :
594- function_tool = tool_run .function_tool
595- tasks .append (run_single_tool (function_tool , tool_run .tool_call ))
583+ tasks .append (run_single_tool (tool_run ))
596584
597585 results = await asyncio .gather (* tasks )
598586
@@ -1039,9 +1027,9 @@ async def execute(
10391027 )
10401028
10411029 _ , _ , output = await asyncio .gather (
1042- hooks .on_tool_start (context_wrapper , agent , action . computer_tool ),
1030+ hooks .on_tool_start (context_wrapper , agent , action ),
10431031 (
1044- agent .hooks .on_tool_start (context_wrapper , agent , action . computer_tool )
1032+ agent .hooks .on_tool_start (context_wrapper , agent , action )
10451033 if agent .hooks
10461034 else _coro .noop_coroutine ()
10471035 ),
0 commit comments