litellm/tests/llm_translation/realtime
Mateo Wang 06a97c83bd
test(realtime): assert guardrail block on backend wire traffic instead of model refusal wording (#32388)
test_text_message_blocked_by_guardrail_no_ai_response classified the
model's reply against a safe_markers keyword list to decide whether the
guardrail had blocked the message. gpt-realtime words its refusal of the
guardrail's "say exactly" voice prompt nondeterministically, so any new
phrasing outside the list turned CI red on unrelated PRs; the list had
already been extended in #28191, #28200 and #29477, and drifted again to
"Sorry, I can't comply with that request" (11 of the 13 failed
realtime_translation_testing runs since 2026-06-24, e.g. CircleCI job
2009316 on #32380).

Record every frame the proxy sends to the backend through a
RecordingBackendWebSocket wrapper and assert the invariant the product
actually guarantees: the blocked phrase never reaches OpenAI, only the
guardrail's own conversation.item.create and response.create are
forwarded (the client's reflexive response.create is dropped), and the
blocked phrase never appears in AI output. Replace the fixed
0.3s/3.0s sleeps with an event-driven wait for response.done; client
frames are processed sequentially so no inter-message sleep is needed.

Verified by mutation: disabling the response.create drop fails the
response.create count assertion, and disabling the guardrail fails the
guardrail_violation assertion.
2026-07-07 15:47:05 -07:00
..
__init__.py [Feat] Add xAI /realtime API Support - works with LiveKitSDK (#20381) 2026-02-03 19:58:28 -08:00
base_realtime_tests.py Litellm oss staging 04 21 2026 2 (#26569) 2026-05-20 21:25:19 -07:00
test_openai_realtime.py feat: litellm oss 110626 (#30202) 2026-06-11 22:30:26 -07:00
test_openai_realtime_simple.py fix(tests): migrate realtime + rerank tests off shut-down upstream models (#28191) 2026-05-18 15:41:51 -07:00
test_realtime_guardrails_openai.py test(realtime): assert guardrail block on backend wire traffic instead of model refusal wording (#32388) 2026-07-07 15:47:05 -07:00
test_xai_realtime.py Litellm oss staging 04 21 2026 2 (#26569) 2026-05-20 21:25:19 -07:00