fix(openai): include model in WebSocket URLs - #6403
Conversation
Let OpenAI-compatible gateways select an upstream during the WebSocket upgrade, before request frames provide the model. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
π‘ Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4032efde79
βΉοΈ About Codex in GitHub
Your team has set up Codex to 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 π.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| class _ResponsesWebsocket: | ||
| def __init__( | ||
| self, api_key: str | None, timeout: float | None, base_url: str | None = None | ||
| self, api_key: str | None, timeout: float | None, model: str, base_url: str | None = None |
There was a problem hiding this comment.
Restore compatibility for direct websocket construction
Existing code still constructs _ResponsesWebsocket(api_key="test-key", timeout=1.0) in tests/test_plugin_openai_responses.py::_capture_sent_payload; making model a required positional argument here causes the OpenAI plugin regression test to raise TypeError before it can exercise the WebSocket serialization path. Please either give this constructor a default model or update all existing direct call sites.
Useful? React with πΒ / π.
OpenAI rejects the model query parameter for transcription WebSocket sessions, while compatible gateways need it to route the upgrade. Co-authored-by: Cursor <cursoragent@cursor.com>
| class _ResponsesWebsocket: | ||
| def __init__( | ||
| self, api_key: str | None, timeout: float | None, base_url: str | None = None | ||
| self, api_key: str | None, timeout: float | None, model: str, base_url: str | None = None |
There was a problem hiding this comment.
π΄ Existing test breaks because a required constructor argument was added without updating all callers
A new required model parameter was added to the internal websocket constructor (_ResponsesWebsocket.__init__ at livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/responses/llm.py:57), but an existing test helper still calls the old signature without it, so the plugin test suite will crash with a TypeError.
Impact: The --plugin openai test suite fails; the test_reasoning_object_serialized_without_null_fields test cannot run.
Broken caller and trigger details
The caller at tests/test_plugin_openai_responses.py:59 constructs _ResponsesWebsocket(api_key="test-key", timeout=1.0) β missing the now-required model positional argument that was inserted between timeout and base_url. Running pytest --plugin openai will raise:
TypeError: _ResponsesWebsocket.__init__() missing 1 required positional argument: 'model'
The fix is to pass a model string (e.g. model="gpt-4.1") in that test helper call.
Prompt for agents
The _ResponsesWebsocket constructor at livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/responses/llm.py:57 now requires a model parameter, but the existing test helper _capture_sent_payload in tests/test_plugin_openai_responses.py:59 still calls _ResponsesWebsocket(api_key="test-key", timeout=1.0) without passing model. Update line 59 of tests/test_plugin_openai_responses.py to pass a model argument, e.g.: _ResponsesWebsocket(api_key="test-key", timeout=1.0, model="gpt-4.1").
Was this helpful? React with π or π to provide feedback.
Summary
Test plan
uv run pytest tests/test_plugin_openai_websocket_urls.py --unituv run ruff check livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/stt.py livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/responses/llm.py tests/test_plugin_openai_websocket_urls.pyuv run ruff format --check livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/stt.py livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/responses/llm.py tests/test_plugin_openai_websocket_urls.pymake type-check