Skip to content

Commit bf3fb94

Browse files
committed
fix: typing updates to pass make old_version_tests
1 parent 86f09e9 commit bf3fb94

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/agents/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1945,7 +1945,7 @@ def run_streamed(
19451945
else:
19461946
# input is already str | list[TResponseInputItem] when not RunState
19471947
# Reuse input_for_result variable from outer scope
1948-
input_for_result = cast(str | list[TResponseInputItem], input)
1948+
input_for_result = cast(Union[str, list[TResponseInputItem]], input)
19491949
context_wrapper = RunContextWrapper(context=context) # type: ignore
19501950
# input_for_state is the same as input_for_result here
19511951
input_for_state = input_for_result

src/agents/run_state.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import json
77
from collections.abc import Mapping, Sequence
88
from dataclasses import dataclass, field
9-
from typing import TYPE_CHECKING, Any, Generic, cast
9+
from typing import TYPE_CHECKING, Any, Generic, Optional, cast
1010

1111
from 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

Comments
 (0)