fix(responses-ws): append ?model= to backend WebSocket URL#25437
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR fixes OpenAI's WebSocket responses endpoint handshake by appending Confidence Score: 5/5Safe to merge — the handler fix is correct and the tests genuinely verify URL construction. All prior P1 concerns (missing model param, existing query params being dropped) are addressed by the urllib.parse-based implementation. The only remaining finding is a P2 style issue (inline imports in test methods). No blocking issues remain. No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/llms/custom_httpx/llm_http_handler.py | Adds module-level urllib.parse imports and correctly appends ?model= to the WebSocket URL using parse_qs/urlunparse, preserving existing query params. |
| tests/test_litellm/responses/test_responses_websocket_all_providers.py | Adds TestNativeWebSocketUrlConstruction with two tests that mock websockets.connect to capture the actual URL; imports are inlined inside test methods contrary to project style guide. |
Sequence Diagram
sequenceDiagram
participant Client
participant LiteLLM as BaseLLMHTTPHandler
participant URLBuilder as urllib.parse
participant OpenAI as OpenAI WSS Backend
Client->>LiteLLM: async_responses_websocket(model="gpt-4o-mini", ...)
LiteLLM->>LiteLLM: get_complete_url() → "https://api.openai.com/v1/responses"
LiteLLM->>LiteLLM: replace https→wss
LiteLLM->>URLBuilder: urlparse(ws_url)
URLBuilder-->>LiteLLM: ParseResult (query="")
LiteLLM->>URLBuilder: parse_qs("") → {}
Note over LiteLLM: "model" not in qs → append it
LiteLLM->>URLBuilder: urlunparse(parsed._replace(query="model=gpt-4o-mini"))
URLBuilder-->>LiteLLM: "wss://api.openai.com/v1/responses?model=gpt-4o-mini"
LiteLLM->>OpenAI: websockets.connect("wss://...?model=gpt-4o-mini", headers=...)
OpenAI-->>LiteLLM: WebSocket connection established
LiteLLM->>Client: bidirectional_forward() stream
Reviews (2): Last reviewed commit: "fix(responses-ws): use urllib.parse to a..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Summary
wss://.../v1/responses?model=gpt-4o-mini), matching the Realtime API conventiontest_responses_websocket_proxy_basicandtest_responses_websocket_proxy_multi_turnine2e_openai_endpointsCITest plan
e2e_openai_endpointsCI passesTestNativeWebSocketUrlConstructionunit tests pass locally