* test: drop the cwd-relative sys.path.insert calls from the test suite
TQ003 stands at 1,077 across 1,058 files, and 1,015 of them are the same shape:
sys.path.insert(0, os.path.abspath("../..")) and its deeper siblings. The
argument resolves against the working directory rather than the file, so from
the repo root, where every job runs pytest, it inserts the directory two levels
above the checkout. It has never pointed at litellm. The package is installed
into the environment anyway, which is what actually makes the import work, and
what the rule's message has said all along.
Removing them leaves 1,634 imports of sys and os with no remaining reference,
and those go too, except where another test module imports the name back out of
the file. The rest of TQ003 is 62 call sites that resolve against __file__ or a
variable, which are a different question and are left alone.
Collection is identical either way: 45,871 tests and the same 51 pre-existing
collection errors before and after, and ruff reports no new undefined name.
* test: drop the duplicate imports the sys.path sweep exposed to F811
* test(pre-call-utils): restore the os import the new bedrock tests need
|
||
|---|---|---|
| .. | ||
| README.md | ||
| test_openai_realtime_handler.py | ||
| test_transcription_sessions.py | ||
OpenAI Realtime Handler Tests
Important Context: additional_headers vs extra_headers
Background
There was confusion about the correct parameter name for passing headers to websockets.connect(). This README documents the resolution for future maintainers.
Timeline of Changes
- Dec 5, 2025 - Changed
extra_headers→additional_headers(commit8db7f1b8e4) - Dec 18, 2025 - Changed
extra_headers→additional_headersagain (PR #17950, commit9f88d61d10) - Jan 15, 2026 - Upgraded
websocketsfrom 13.1.0 → 15.0.1 (commita3cf178e24, Issue #19089)
The Issue & Resolution
The websockets library changed its API between versions:
- websockets < 14.0: Used
extra_headersparameter ✅ - websockets >= 14.0: Uses
additional_headersparameter ✅
LiteLLM uses websockets 15.0.1 (per uv.lock), which requires additional_headers.
Verification
You can verify the correct parameter name:
uv run python -c "import websockets; import inspect; print(inspect.signature(websockets.connect))"
This shows: additional_headers: 'HeadersLike | None' = None for websockets 15.0.1.
Current Implementation (Correct)
# ✅ Correct for websockets 15.0.1+
await websockets.connect(url, additional_headers={
"Authorization": f"Bearer {api_key}",
"OpenAI-Beta": "realtime=v1"
})
Impact
This is NOT just a test fix - this was a critical bug that affected all realtime APIs:
- OpenAI realtime
- Azure realtime
- xAI realtime
- Any pass-through realtime connections
Using extra_headers with websockets 15.0.1 resulted in:
TypeError: connect() got an unexpected keyword argument 'extra_headers'
For Future Maintainers
If you see test failures related to header parameters:
-
Check installed websockets version:
uv run python -c "import websockets; print(websockets.__version__)" -
Check
uv.lockfor the pinned version -
Verify the correct parameter:
- websockets >= 14.0: use
additional_headers - websockets < 14.0: use
extra_headers
- websockets >= 14.0: use
-
Ensure consistency across all files:
litellm/llms/openai/realtime/handler.pylitellm/llms/azure/realtime/handler.pylitellm/llms/custom_httpx/llm_http_handler.pylitellm/realtime_api/main.pylitellm/proxy/pass_through_endpoints/pass_through_endpoints.py
Current Status (Feb 2026):
- ✅ websockets version: 15.0.1
- ✅ Correct parameter:
additional_headers - ✅ All handlers updated and working