Skip to content

fix(responses): initialize null streaming output before accumulating items - #3881

Open
Chirag-Bhardwaj wants to merge 1 commit into
openai:mainfrom
Chirag-Bhardwaj:fix/responses-empty-initial-output
Open

Chirag-Bhardwaj wants to merge 1 commit into
openai:mainfrom
Chirag-Bhardwaj:fix/responses-empty-initial-output

Conversation

@Chirag-Bhardwaj

Copy link
Copy Markdown
  • I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

Normalize null or omitted response.created.response.output to an empty list in the Responses stream's internal snapshot. The index map already tolerates these values, but the snapshot retains None, so the next response.output_item.added raises AttributeError: 'NoneType' object has no attribute 'append' in both sync and async streams.

This extends the existing null-output handling from #3345 to stream initialization. The change is confined to the handwritten streaming helper. Existing output lists and terminal-response precedence are preserved.

The existing public-client regression test now covers null, omitted, and empty initial output across sync/async streams, with and without items, and all four terminal-output variants. It verifies final structured text, function arguments, citations, refusals, status, and usage using synthetic SSE through httpx2.MockTransport; no live API calls or credentials are required. This is a locally reproduced SDK edge case, not a claim that the production API currently emits this payload.

Additional context & links

Validated on Python 3.10.16 against main b77076d23b6f3e34453b0fadd8cd2a001627e365:

  • Expanded regression matrix on unchanged main: 16 failed, 32 passed; with the fix: 48 passed.
  • Responses suite: 270 passed with each Pydantic version.
  • ./scripts/test -n 4: 13,209 passed / 162 skipped on Pydantic v2; 13,195 passed / 176 skipped on v1.
  • ./scripts/lint: Ruff, Pyright, Mypy, and import check passed.
  • ./scripts/build, changed-file formatting, and git diff --check passed.
  • Main's unchanged custom-code budget checker passed; no policy or generation metadata changes.

@Chirag-Bhardwaj
Chirag-Bhardwaj requested a review from a team as a code owner September 17, 2026 00:32
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.

1 participant