Fix client regressions for null responses and websocket env URLs#3340
Fix client regressions for null responses and websocket env URLs#3340redactdeveloper wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cd9105e077
ℹ️ 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".
| if output.type == "function_call": | ||
| output.arguments += event.delta | ||
| elif event.type == "response.completed": | ||
| response = snapshot if event.response.output is None else event.response |
There was a problem hiding this comment.
Preserve completed stream metadata when output is null
When a streamed response.completed event has output: null, this replaces the final event response with the earlier snapshot. That keeps accumulated output text, but it also drops final-only fields from the completed event such as status, usage, errors/incomplete details, etc., so consumers of response.completed.response can see an in_progress/metadata-less response even though the server sent completed metadata. In this null-output scenario, merge the snapshot output into event.response instead of discarding the completed response object.
Useful? React with 👍 / 👎.
cd9105e to
d425c9c
Compare
Summary
output: nullin response parsing,output_text, parsed output helpers, and streaming completion fallback by using the accumulated snapshot when availableNO_PROXY/no_proxyvalues while constructing default httpx clients, restoring the original environment after initializationapi_key, while keeping normal Azure API keys asapi-keyTests
.venv/bin/python -m pytest -o addopts="" tests/lib/responses/test_responses.py tests/lib/test_azure.py tests/test_websocket_urls.py.venv/bin/python -m pytest -o addopts="" tests/test_client.py -k "proxy_environment_variables".venv/bin/python -m ruff check src/openai/_base_client.py src/openai/lib/_parsing/_responses.py src/openai/lib/streaming/responses/_responses.py src/openai/lib/azure.py src/openai/resources/responses/responses.py src/openai/resources/realtime/realtime.py src/openai/resources/beta/realtime/realtime.py src/openai/types/responses/response.py src/openai/types/responses/parsed_response.py tests/lib/responses/test_responses.py tests/lib/test_azure.py tests/test_client.py tests/test_websocket_urls.py.venv/bin/python -m py_compile src/openai/_base_client.py src/openai/lib/_parsing/_responses.py src/openai/lib/streaming/responses/_responses.py src/openai/lib/azure.py src/openai/resources/responses/responses.py src/openai/resources/realtime/realtime.py src/openai/resources/beta/realtime/realtime.py src/openai/types/responses/response.py src/openai/types/responses/parsed_response.py tests/lib/responses/test_responses.py tests/lib/test_azure.py tests/test_client.py tests/test_websocket_urls.pygit diff --check