Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

IndexError in accumulate_event during Responses API streaming

Đang mở
#2,852 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@Krishnachaitanyakc đang làm issue này rồi.

Từ ngày 25/3/2026.

  • #1 của @bodapatisaikrishna — đang mở
  • #2942 của @MaxwellCalkin — đã đóng, không merge
  • #3010 của @Krishnachaitanyakc — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
55/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
api

Hướng nghiên cứu

Bắt đầu bằng cách đọc openai/lib/streaming/responses/_responses.py, đặc biệt là accumulate_event ở dòng 344 cùng các hàm gọi nó là handle_event và stream. Tái hiện lỗi xảy ra không liên tục bằng AsyncOpenAI().responses.stream() với ngữ cảnh Responses API đã mô tả, sau đó xác minh rằng việc streaming và tiếp tục với starting_after hoàn tất mà không có IndexError.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Bug Report

Description

IndexError: list index out of range occurs inside the OpenAI SDK during streaming of Responses API events. The error originates in openai/lib/streaming/responses/_responses.py line 344 in accumulate_event, called from handle_event (line 248) and __stream__ (line 156).

This is not caused by application code — it happens internally within the SDK's stream accumulator.

Stack Trace
File "/app/.venv/lib/python3.13/site-packages/openai/lib/streaming/responses/_responses.py", line 151, in __aiter__
File "/app/.venv/lib/python3.13/site-packages/openai/lib/streaming/responses/_responses.py", line 156, in __stream__
File "/app/.venv/lib/python3.13/site-packages/openai/lib/streaming/responses/_responses.py", line 248, in handle_event
File "/app/.venv/lib/python3.13/site-packages/openai/lib/streaming/responses/_responses.py", line 344, in accumulate_event
    IndexError: list index out of range
Reproduction Context
  • SDK version: openai==2.16.0
  • Python version: 3.13
  • API: Responses API with streaming (stream=True)
  • Model: gpt-5-nano
  • Features used: tools=[{"type": "web_search"}], structured output with text_format (Pydantic model)
  • Streaming method: AsyncOpenAI().responses.stream() and resume via responses.stream() with starting_after
Code Pattern
async with client.responses.stream(...) as stream:
    async for event in stream:  # IndexError thrown here intermittently
        ...

The error occurs intermittently — most streams complete fine, but occasionally the accumulator hits an index that doesn't exist in its internal list.

Workaround

Wrapping the stream iteration in a try/except IndexError to catch and log the error, since the stream has typically delivered the important data by the time this occurs.

Notes

A similar class of bug exists in the Assistants API streaming path (_assistants.py in accumulate_event) — see #1736 and #1882. This issue is for the newer Responses API streaming path (responses/_responses.py).

Ngôn ngữ chính
Python
Star
31.8k
Fork
7.3k
Merge trung bình
1 ngày 3 giờ
Pull request đã merge (30 ngày)
131

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của openai/openai-python

Tất cả issue của openai/openai-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.