Skip to content

Commit 81d7d9a

Browse files
committed
resolve typecheck test problems
1 parent 696b1b1 commit 81d7d9a

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/agents/run.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -913,12 +913,17 @@ async def _run_single_turn_streamed(
913913
output_item = event.item
914914

915915
if isinstance(output_item, _TOOL_CALL_TYPES):
916-
call_id = getattr(output_item, "call_id", getattr(output_item, "id", None))
916+
call_id: str | None = getattr(
917+
output_item, "call_id", getattr(output_item, "id", None)
918+
)
917919

918-
if call_id not in emitted_tool_call_ids:
920+
if call_id and call_id not in emitted_tool_call_ids:
919921
emitted_tool_call_ids.add(call_id)
920922

921-
tool_item = ToolCallItem(raw_item=output_item, agent=agent)
923+
tool_item = ToolCallItem(
924+
raw_item=cast(ToolCallItemTypes, output_item),
925+
agent=agent,
926+
)
922927
streamed_result._event_queue.put_nowait(
923928
RunItemStreamEvent(item=tool_item, name="tool_called")
924929
)
@@ -951,8 +956,12 @@ async def _run_single_turn_streamed(
951956
for item in single_step_result.new_step_items
952957
if not (
953958
isinstance(item, ToolCallItem)
954-
and getattr(item.raw_item, "call_id", getattr(item.raw_item, "id", None))
955-
in emitted_tool_call_ids
959+
and (
960+
call_id := getattr(
961+
item.raw_item, "call_id", getattr(item.raw_item, "id", None)
962+
)
963+
)
964+
and call_id in emitted_tool_call_ids
956965
)
957966
]
958967

0 commit comments

Comments
 (0)