@@ -641,7 +641,6 @@ async def process_function_tools( # noqa C901
641
641
run_context = build_run_context (ctx )
642
642
643
643
calls_to_run : list [tuple [Tool [DepsT ], _messages .ToolCallPart ]] = []
644
- call_index_to_event_id : dict [int , str ] = {}
645
644
for call in tool_calls :
646
645
if (
647
646
call .tool_name == output_tool_name
@@ -668,7 +667,6 @@ async def process_function_tools( # noqa C901
668
667
else :
669
668
event = _messages .FunctionToolCallEvent (call )
670
669
yield event
671
- call_index_to_event_id [len (calls_to_run )] = event .call_id
672
670
calls_to_run .append ((tool , call ))
673
671
elif mcp_tool := await _tool_from_mcp_server (call .tool_name , ctx ):
674
672
if stub_function_tools :
@@ -683,7 +681,6 @@ async def process_function_tools( # noqa C901
683
681
else :
684
682
event = _messages .FunctionToolCallEvent (call )
685
683
yield event
686
- call_index_to_event_id [len (calls_to_run )] = event .call_id
687
684
calls_to_run .append ((mcp_tool , call ))
688
685
elif call .tool_name in output_schema .tools :
689
686
# if tool_name is in output_schema, it means we found a output tool but an error occurred in
@@ -700,13 +697,13 @@ async def process_function_tools( # noqa C901
700
697
content = content ,
701
698
tool_call_id = call .tool_call_id ,
702
699
)
703
- yield _messages .FunctionToolResultEvent (part , tool_call_id = call . tool_call_id )
700
+ yield _messages .FunctionToolResultEvent (part )
704
701
output_parts .append (part )
705
702
else :
706
703
yield _messages .FunctionToolCallEvent (call )
707
704
708
705
part = _unknown_tool (call .tool_name , call .tool_call_id , ctx )
709
- yield _messages .FunctionToolResultEvent (part , tool_call_id = call . tool_call_id )
706
+ yield _messages .FunctionToolResultEvent (part )
710
707
output_parts .append (part )
711
708
712
709
if not calls_to_run :
@@ -738,7 +735,7 @@ async def process_function_tools( # noqa C901
738
735
for task in done :
739
736
index = tasks .index (task )
740
737
result = task .result ()
741
- yield _messages .FunctionToolResultEvent (result , tool_call_id = call_index_to_event_id [ index ] )
738
+ yield _messages .FunctionToolResultEvent (result )
742
739
743
740
if isinstance (result , _messages .RetryPromptPart ):
744
741
results_by_index [index ] = result
0 commit comments