Skip to content

fix: handle null output_text content#3113

Open
nightcityblade wants to merge 1 commit intoopenai:mainfrom
nightcityblade:fix/issue-3063
Open

fix: handle null output_text content#3113
nightcityblade wants to merge 1 commit intoopenai:mainfrom
nightcityblade:fix/issue-3063

Conversation

@nightcityblade
Copy link
Copy Markdown

Fixes #3063

Summary

  • allow ResponseOutputText.text to be null in typed models
  • skip null text entries when aggregating response.output_text
  • treat null text as unparsable in response parsing instead of raising

Testing

  • python -m pytest -o addopts="" tests/lib/responses/test_responses.py -q

@nightcityblade nightcityblade requested a review from a team as a code owner April 23, 2026 03:16
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3518e6a86d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".


text: str
"""The text output from the model."""
text: Optional[str] = None
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Guard streamed text concatenation after making text nullable

Changing ResponseOutputText.text to nullable allows response.content_part.added events to carry text: null, but ResponseStreamState.accumulate_event still does content.text += event.delta (src/openai/lib/streaming/responses/_responses.py:349-355). In streams where a content part starts with null and later receives response.output_text.delta, this will raise a TypeError and terminate the stream; initializing null text to "" (or branching before concatenation) avoids the crash.

Useful? React with 👍 / 👎.

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.

Response.output_text and responses.parse fail when an output_text item has text: null

1 participant