Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

IndexError in accumulate_event during Responses API streaming

未关闭
#2,852 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@Krishnachaitanyakc 已经在做这个了。

开始于 2026年3月25日。

  • #1 来自 @bodapatisaikrishna —— 未关闭
  • #2942 来自 @MaxwellCalkin —— 已关闭,未合并
  • #3010 来自 @Krishnachaitanyakc —— 未关闭

评估

难度
3/5
预计耗时
1-2 天
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
python
领域
api

调研方向

首先阅读 openai/lib/streaming/responses/_responses.py,尤其是第 344 行的 accumulate_event 及其调用方 handle_event 和 stream。使用所述的 Responses API 上下文,通过 AsyncOpenAI().responses.stream() 重现间歇性故障,然后验证流式传输和使用 starting_after 恢复都能在不发生 IndexError 的情况下完成。

由索引模型根据 Issue 内容生成。

描述

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).

主要语言
Python
星标
31.8k
派生
7.3k
平均合并
1 天 3 小时
30 天内合并 PR
131

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

openai/openai-python 的其他 Issue

查看 openai/openai-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。