Skip to content

Commit a72325b

Browse files
authored
fix(example): avoid duplicate streamed response deltas (#2285)
1 parent 8e470ac commit a72325b

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

examples/server/server.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8695,15 +8695,15 @@ def _ensure_reasoning_stream_item(
86958695
state,
86968696
"response.output_item.added",
86978697
output_index=item_state.output_index,
8698-
item=item,
8698+
item=copy.deepcopy(item),
86998699
),
87008700
self._response_event(
87018701
state,
87028702
"response.content_part.added",
87038703
item_id=cast(str, item["id"]),
87048704
output_index=item_state.output_index,
87058705
content_index=0,
8706-
part=part,
8706+
part=copy.deepcopy(part),
87078707
),
87088708
], item_state
87098709

@@ -8727,15 +8727,15 @@ def _ensure_message_stream_item(
87278727
state,
87288728
"response.output_item.added",
87298729
output_index=item_state.output_index,
8730-
item=item,
8730+
item=copy.deepcopy(item),
87318731
),
87328732
self._response_event(
87338733
state,
87348734
"response.content_part.added",
87358735
item_id=cast(str, item["id"]),
87368736
output_index=item_state.output_index,
87378737
content_index=0,
8738-
part=part,
8738+
part=copy.deepcopy(part),
87398739
),
87408740
], item_state
87418741

@@ -8777,7 +8777,7 @@ def _ensure_tool_stream_item(
87778777
state,
87788778
"response.output_item.added",
87798779
output_index=item_state.output_index,
8780-
item=item,
8780+
item=copy.deepcopy(item),
87818781
)
87828782
], item_state
87838783

0 commit comments

Comments
 (0)