Skip to content

fix: ignore empty stream output items#3399

Open
he-yufeng wants to merge 1 commit into
openai:mainfrom
he-yufeng:fix/stream-output-item-none
Open

fix: ignore empty stream output items#3399
he-yufeng wants to merge 1 commit into
openai:mainfrom
he-yufeng:fix/stream-output-item-none

Conversation

@he-yufeng

Copy link
Copy Markdown

Fixes #3125.

Summary

  • Guard the Responses stream accumulator when a malformed response.output_item.added event has no item.
  • Leave the current response snapshot unchanged instead of crashing before user code can handle the stream.
  • Add a regression test for the malformed event shape.

To verify

  • $env:PYTHONPATH=(Resolve-Path .\src).Path; python -m pytest tests\lib\responses\test_responses.py -q
  • $env:PYTHONPATH=(Resolve-Path .\src).Path; python -m ruff check src\openai\lib\streaming\responses\_responses.py tests\lib\responses\test_responses.py
  • $env:PYTHONPATH=(Resolve-Path .\src).Path; python -m py_compile src\openai\lib\streaming\responses\_responses.py tests\lib\responses\test_responses.py
  • git diff --check

@he-yufeng he-yufeng requested a review from a team as a code owner June 13, 2026 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Responses stream accumulator crashes when response.output_item.added has item=None

1 participant