@@ -304,6 +304,9 @@ async def test_streaming(client: OpenAI, model_name: str, background: bool):
304
304
background = background ,
305
305
)
306
306
307
+ current_item_id = ""
308
+ current_content_index = - 1
309
+
307
310
events = []
308
311
current_event_mode = None
309
312
resp_id = None
@@ -315,6 +318,26 @@ async def test_streaming(client: OpenAI, model_name: str, background: bool):
315
318
current_event_mode = event .type
316
319
print (f"\n [{ event .type } ] " , end = "" , flush = True )
317
320
321
+ # verify current_item_id is correct
322
+ if event .type == "response.output_item.added" :
323
+ assert event .item .id != current_item_id
324
+ current_item_id = event .item .id
325
+ elif event .type in [
326
+ "response.output_text.delta" ,
327
+ "response.reasoning_text.delta"
328
+ ]:
329
+ assert event .item_id == current_item_id
330
+
331
+ # verify content_index_id is correct
332
+ if event .type == "response.content_part.added" :
333
+ assert event .content_index != current_content_index
334
+ current_content_index = event .content_index
335
+ elif event .type in [
336
+ "response.output_text.delta" ,
337
+ "response.reasoning_text.delta"
338
+ ]:
339
+ assert event .content_index == current_content_index
340
+
318
341
if "text.delta" in event .type :
319
342
print (event .delta , end = "" , flush = True )
320
343
elif "reasoning_text.delta" in event .type :
0 commit comments