Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/openai/lib/_parsing/_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def parse_response(
) -> ParsedResponse[TextFormatT]:
output_list: List[ParsedResponseOutputItem[TextFormatT]] = []

for output in response.output:
for output in (response.output or []):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve streamed output when completed payload is null

When the streaming backend sends response.completed.response.output: null after already sending response.output_item.* and text/function deltas, this turns the completed response into output=[]. In ResponseStreamState.accumulate_event, the final response.completed event and get_final_response() are built from parse_response(event.response), not from the accumulated snapshot, so consumers no longer crash but silently lose all streamed output and parsed content in exactly the scenario this change is meant to handle. The null case should fall back to the accumulated snapshot/output rather than an empty list.

Useful? React with 👍 / 👎.

if output.type == "message":
content_list: List[ParsedContent[TextFormatT]] = []
for item in output.content:
Expand Down