Skip to content

fix(openai): include model in WebSocket URLs - #6403

Merged
toubatbrian merged 3 commits into
mainfrom
brian/openai-ws-model-query
Jul 14, 2026
Merged

fix(openai): include model in WebSocket URLs#6403
toubatbrian merged 3 commits into
mainfrom
brian/openai-ws-model-query

Conversation

@toubatbrian

@toubatbrian toubatbrian commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • include the selected model in realtime STT WebSocket upgrade URLs
  • include the selected model in Responses API WebSocket upgrade URLs while preserving existing query parameters
  • add hermetic regression tests for both upgrade paths

Test plan

  • uv run pytest tests/test_plugin_openai_websocket_urls.py --unit
  • uv 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.py
  • uv 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.py
  • make type-check

Let OpenAI-compatible gateways select an upstream during the WebSocket upgrade, before request frames provide the model.

Co-authored-by: Cursor <cursoragent@cursor.com>
@toubatbrian
toubatbrian requested a review from a team as a code owner July 13, 2026 16:51

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

βœ… Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

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

Copy link
Copy Markdown

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: 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

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 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>

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 1 additional finding in Devin Review.

Open in Devin Review

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

πŸ”΄ 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").
Open in Devin Review

Was this helpful? React with πŸ‘ or πŸ‘Ž to provide feedback.

@toubatbrian
toubatbrian merged commit 9c95a6f into main Jul 14, 2026
24 checks passed
@toubatbrian
toubatbrian deleted the brian/openai-ws-model-query branch July 14, 2026 16:05
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.

4 participants