66import json
77from collections .abc import Mapping , Sequence
88from dataclasses import dataclass , field
9- from typing import TYPE_CHECKING , Any , Generic , cast
9+ from typing import TYPE_CHECKING , Any , Generic , Optional , cast
1010
1111from openai .types .responses import (
1212 ResponseComputerToolCall ,
@@ -741,7 +741,7 @@ def _serialize_item(self, item: RunItem) -> dict[str, Any]:
741741 def _convert_output_item_to_protocol (self , raw_item_dict : dict [str , Any ]) -> dict [str , Any ]:
742742 """Convert API-format tool output items to protocol format."""
743743 converted = dict (raw_item_dict )
744- call_id = cast (str | None , converted .get ("call_id" ) or converted .get ("callId" ))
744+ call_id = cast (Optional [ str ] , converted .get ("call_id" ) or converted .get ("callId" ))
745745
746746 converted ["type" ] = "function_call_result"
747747
@@ -761,13 +761,13 @@ def _lookup_function_name(self, call_id: str) -> str:
761761 def _extract_name (raw : Any ) -> str | None :
762762 candidate_call_id : str | None = None
763763 if isinstance (raw , dict ):
764- candidate_call_id = cast (str | None , raw .get ("call_id" ) or raw .get ("callId" ))
764+ candidate_call_id = cast (Optional [ str ] , raw .get ("call_id" ) or raw .get ("callId" ))
765765 if candidate_call_id == call_id :
766766 name_value = raw .get ("name" , "" )
767767 return str (name_value ) if name_value else ""
768768 else :
769769 candidate_call_id = cast (
770- str | None ,
770+ Optional [ str ] ,
771771 getattr (raw , "call_id" , None ) or getattr (raw , "callId" , None ),
772772 )
773773 if candidate_call_id == call_id :
@@ -800,7 +800,7 @@ def _extract_name(raw: Any) -> str | None:
800800 if input_item .get ("type" ) != "function_call" :
801801 continue
802802 item_call_id = cast (
803- str | None , input_item .get ("call_id" ) or input_item .get ("callId" )
803+ Optional [ str ] , input_item .get ("call_id" ) or input_item .get ("callId" )
804804 )
805805 if item_call_id == call_id :
806806 name_value = input_item .get ("name" , "" )
0 commit comments