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 final payload omits it

When the streaming response.completed event has event.response.output == None (the scenario described by this fix), this fallback makes parse_response() build a final ParsedResponse with output=[]. In the streaming path, ResponseStreamState.accumulate_event() calls parse_response(response=event.response) for response.completed instead of parsing the accumulated snapshot, so get_final_response() and the emitted completed event lose all output items/text/tool calls that arrived via earlier response.output_item.added and delta events. This avoids the crash but turns valid streamed responses into empty final responses; the fallback should preserve the accumulated snapshot or otherwise not replace missing final output with an empty list.

Useful? React with 👍 / 👎.

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