@@ -2252,6 +2252,9 @@ def _add_conversation_item_event( # pylint: disable=too-many-branches
22522252 # Create event body - format depends on item type
22532253 event_body : Dict [str , Any ] = {}
22542254
2255+ # Declare tool_call variable with type for use across branches
2256+ tool_call : Dict [str , Any ]
2257+
22552258 # Handle different item types
22562259 if item_type == "function_call_output" :
22572260 # Function tool output - use tool_call_outputs format
@@ -2286,7 +2289,7 @@ def _add_conversation_item_event( # pylint: disable=too-many-branches
22862289 # Function tool call - use tool_calls format
22872290 role = "assistant" # Override role for function calls
22882291 if _trace_responses_content :
2289- tool_call : Dict [ str , Any ] = {
2292+ tool_call = {
22902293 "type" : "function" ,
22912294 }
22922295
@@ -2322,7 +2325,7 @@ def _add_conversation_item_event( # pylint: disable=too-many-branches
23222325 # File search tool call
23232326 role = "assistant" # Override role for file search calls
23242327 if _trace_responses_content :
2325- tool_call : Dict [ str , Any ] = {
2328+ tool_call = {
23262329 "type" : "file_search" ,
23272330 }
23282331
@@ -2362,7 +2365,7 @@ def _add_conversation_item_event( # pylint: disable=too-many-branches
23622365 # Code interpreter tool call
23632366 role = "assistant" # Override role for code interpreter calls
23642367 if _trace_responses_content :
2365- tool_call : Dict [ str , Any ] = {
2368+ tool_call = {
23662369 "type" : "code_interpreter" ,
23672370 }
23682371
@@ -2408,7 +2411,7 @@ def _add_conversation_item_event( # pylint: disable=too-many-branches
24082411 # Web search tool call
24092412 role = "assistant" # Override role for web search calls
24102413 if _trace_responses_content :
2411- tool_call : Dict [ str , Any ] = {
2414+ tool_call = {
24122415 "type" : "web_search" ,
24132416 }
24142417
0 commit comments