fix: revert realtime endpoint change, replace fragile asserts with fallback

- Revert realtime_endpoints/endpoints.py to original Response return
  (preserves backwards-compatible API contract; accepts 1 known mypy error)
- Replace 'assert provider_config is not None' with proper if/else
  fallback that re-raises the original exception when provider_config
  is None, avoiding AssertionError in production and python -O issues

Co-authored-by: yuneng-jiang <yuneng-jiang@users.noreply.github.com>
This commit is contained in:
Cursor Agent 2026-03-13 00:57:18 +00:00
parent 2b2069893f
commit a5b86d3b2f
No known key found for this signature in database
2 changed files with 15 additions and 12 deletions

View file

@ -4871,11 +4871,12 @@ class BaseLLMHTTPHandler:
timeout=timeout,
)
except Exception as e:
assert provider_config is not None
raise self._handle_error(
e=e,
provider_config=provider_config,
)
if provider_config is not None:
raise self._handle_error(
e=e,
provider_config=provider_config,
)
raise
async def async_realtime_calls_handler(
self,
@ -4956,11 +4957,12 @@ class BaseLLMHTTPHandler:
timeout=timeout,
)
except Exception as e:
assert provider_config is not None
raise self._handle_error(
e=e,
provider_config=provider_config,
)
if provider_config is not None:
raise self._handle_error(
e=e,
provider_config=provider_config,
)
raise
async def async_responses_websocket(
self,

View file

@ -181,9 +181,10 @@ async def create_realtime_client_secret(
upstream_resp.status_code,
upstream_resp.text,
)
raise HTTPException(
return Response(
content=upstream_resp.content,
status_code=upstream_resp.status_code,
detail=upstream_resp.text,
media_type="application/json",
)
upstream_json: dict = upstream_resp.json()