litellm/tests/test_litellm/llms
mubashir1osmani 13285671f2
fix(realtime): stop second Gemini Live setup, retry hung handshake, close guardrail bypass (#31519)
* fix(realtime): stop sending a second Gemini Live setup on follow-up session.update

Gemini Live (BidiGenerateContent) accepts setup as the first-and-only client
message; a second setup closes the socket with 1007 Request contains an invalid
argument. The AI Studio Gemini path forwarded every client session.update after
the first as a follow-up setup, and GA clients (pipecat) send several while
configuring the session, so the second one tore the session down before the
first turn. Callers saw silence after the first response, exponential per-turn
latency from reconnect/retry churn, and intermittent 1011 errors.

Drop subsequent session.updates instead of resending setup, matching what the
Vertex subclass already does. Tools and instructions must ride on the first
session.update before any conversation content.

Adds regression tests covering the plain follow-up, a follow-up that adds tools
(the case the previous identical-only dedup still forwarded), and the guardrail
create_response=False warning path.

* fix(realtime): retry the backend open handshake instead of failing with 1011

The upstream Live API open handshake (e.g. Gemini Live) intermittently hangs;
waiting longer never recovers a hung attempt, but a fresh attempt almost always
connects in ~1s. The proxy opened the backend websocket once with the default
open_timeout and no retry, so a single slow handshake surfaced to the caller as
a fatal 1011 internal error and dropped the call.

Bound each open attempt with a short open_timeout and retry; a bounded attempt
that already timed out spaces out the next try, so no backoff is needed.
Deterministic handshake-status rejections (auth/4xx) are not retried, and the
retry only ever wraps the open, never a live session.

Adds tests for retry-then-succeed, raise-after-max-attempts, and
no-retry-on-auth-failure.

* fix(realtime): close guardrail bypass + surface handshake status; drop obsolete tests

Three review fixes on the Gemini Live realtime path.

Transcription-guardrail bypass: Gemini Live rejects a second setup (1007), so once
the initial setup is sent the guardrail's automaticActivityDetection.disabled=true
can no longer be delivered as a follow-up session.update. With that follow-up now
dropped, the model's auto-response stayed enabled and a realtime_input_transcription
guardrail was bypassed (the model answered before the proxy could gate the turn).
Fold the disable into the one-and-only setup instead: the handler injects it into
the auto-sent setup (gemini_live_defer_setup false) and _send_to_backend injects it
into the deferred first setup. OpenAI sessions accept follow-up updates and are left
untouched.

Backend handshake status: the open-retry treated only InvalidStatusCode as
deterministic; websockets>=15 raises InvalidStatus for a rejected client handshake,
so a 401/403 fell into the broad WebSocketException branch and was retried before
the caller closed the client with 1011 instead of the upstream status. Treat both as
non-retryable.

Obsolete tests: the four tests asserting a follow-up session.update is merged and
re-sent as a second setup asserted behavior that crashes Gemini Live with 1007
(verified directly against the API). Removed; the drop is covered by new regression
tests.

* style(realtime): reformat changed files to ruff line-length 120

Post-merge with litellm_internal_staging, which unified ruff format width to 120
(#31518). The realtime change set was formatted at 88, so the changed lines
tripped the whole-file ruff format check. Reformat with ruff 0.15.3 at the repo's
120 width; no logic changes.

(cherry picked from commit ef5d05f137)
2026-06-30 18:37:14 -07:00
..
amazon_nova/chat style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
anthropic chore: litellm oss staging (#30745) 2026-06-18 13:55:35 -07:00
apiserpent Litellm oss staging (#29492) 2026-06-02 08:48:10 -07:00
azure feat: litellm oss 110626 (#30202) 2026-06-11 22:30:26 -07:00
azure_ai feat(azure_ai): add MAI-Image-2.5 image generation support (#29688) 2026-06-08 18:27:04 -07:00
base_llm chore(oss): litellm oss staging 150626 (#30463) 2026-06-16 12:06:41 -07:00
baseten/chat style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
bedrock chore: litellm oss staging (#30745) 2026-06-18 13:55:35 -07:00
bedrock_mantle chore: litellm oss staging (#30745) 2026-06-18 13:55:35 -07:00
black_forest_labs Litellm OSS Staging 010626 (#29422) 2026-06-01 21:42:51 -07:00
bytez/chat fix: preserve safe provider model path segments 2026-04-29 22:09:54 -07:00
chat chore(oss): litellm oss staging 120626 (#30292) 2026-06-12 09:49:25 -07:00
chatgpt Litellm oss staging 04 21 2026 2 (#26569) 2026-05-20 21:25:19 -07:00
cloudflare fix: preserve safe provider model path segments 2026-04-29 22:09:54 -07:00
cohere Litellm oss staging 050626 (#29774) 2026-06-05 13:51:51 -07:00
cometapi/chat style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
compactifai style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
crusoe fix(crusoe): remove trailing slashes from API base URLs and fix list indentation 2026-05-01 17:27:52 +05:30
custom_httpx fix(realtime): stop second Gemini Live setup, retry hung handshake, close guardrail bypass (#31519) 2026-06-30 18:37:14 -07:00
dashscope Litellm oss staging (#28161) 2026-05-18 16:27:44 -07:00
databricks [internal copy of #28007] Fix/gcp model garden streaming (#28363) 2026-06-10 12:31:00 -07:00
datarobot style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
deepgram style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
deepinfra style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
deepseek fix(deepseek): use native /anthropic/v1/messages endpoint and sanitize tools (#28200) 2026-05-18 18:14:13 -07:00
docker_model_runner style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
elevenlabs test: avoid provider test module name collision 2026-04-29 22:36:57 -07:00
fal_ai/image_generation feat(fal_ai): add Nano Banana / Gemini 2.5 Flash Image generation support (#29798) 2026-06-06 11:16:44 -07:00
fastcrw/search chore(oss): litellm oss staging 150626 (#30463) 2026-06-16 12:06:41 -07:00
featherless_ai/chat style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
fireworks_ai chore: litellm oss 170626 (#30637) 2026-06-17 21:11:12 -07:00
gemini fix(realtime): stop second Gemini Live setup, retry hung handshake, close guardrail bypass (#31519) 2026-06-30 18:37:14 -07:00
github_copilot feat: litellm oss 110626 (#30202) 2026-06-11 22:30:26 -07:00
heroku style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
hosted_vllm chore: litellm oss staging160626 (#30527) 2026-06-16 18:23:13 -07:00
huggingface Litellm oss staging 040626 (#29671) 2026-06-04 11:07:20 -07:00
inception Litellm oss staging 030626 (#29578) 2026-06-03 11:01:51 -07:00
jina_ai/embedding feat(JinaAI): support multimodal embedding models (#13181) 2025-08-05 19:21:56 -07:00
langflow feat(agents): add LangFlow agent provider with A2A session bridging (#28963) 2026-06-02 14:45:56 -07:00
lemonade Litellm OSS Staging (#29161) 2026-06-01 21:22:35 -07:00
litellm_proxy chore: simplify ownership tracking — drop thin stores, in-memory fallback, hand-rolled cache 2026-05-05 00:23:32 +00:00
llamafile/chat style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
lm_studio style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
manus fix: encode upstream URL path identifiers 2026-04-29 22:02:39 -07:00
meta_llama fix: add missing OpenAI chat completion params to OPENAI_CHAT_COMPLETION_PARAMS (#21360) 2026-02-16 20:31:21 -08:00
minimax style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
mistral Merge pull request #25256 from BerriAI/litellm_ishaan_april6 2026-04-17 16:26:45 -07:00
modelscope chore(oss): litellm oss staging 150626 (#30463) 2026-06-16 12:06:41 -07:00
moonshot Litellm oss staging 050626 (#29774) 2026-06-05 13:51:51 -07:00
nebius test: fixes 2025-05-31 12:42:56 -07:00
neosantara Litellm oss staging 050626 (#29774) 2026-06-05 13:51:51 -07:00
novita/chat Litellm fix GitHub action testing (#11163) 2025-05-26 14:41:42 -07:00
nscale/chat Litellm fix GitHub action testing (#11163) 2025-05-26 14:41:42 -07:00
nvidia_riva feat(audio_transcription): add NVIDIA Riva STT provider (#27185) 2026-05-05 17:17:51 -07:00
oci feat: litellm oss 110626 (#30202) 2026-06-11 22:30:26 -07:00
ocr Add OCR guardrail_translation handler and support (#22145) 2026-02-28 17:39:36 -08:00
ollama Litellm OSS Staging (#29161) 2026-06-01 21:22:35 -07:00
openai chore: litellm oss 170626 (#30637) 2026-06-17 21:11:12 -07:00
openai_like chore: litellm oss staging (#30745) 2026-06-18 13:55:35 -07:00
openrouter chore: litellm oss staging160626 (#30527) 2026-06-16 18:23:13 -07:00
ovhcloud fix(ovhcloud): remove dead transform_response override 2026-04-28 23:09:17 +05:30
parallel_ai feat: litellm oss 110626 (#30202) 2026-06-11 22:30:26 -07:00
parasail Litellm oss staging 080626 (#29932) 2026-06-08 13:49:52 -07:00
pass_through feat(proxy): enforce key/team guardrails on bedrock passthrough routes (#30194) 2026-06-12 07:23:29 -07:00
perplexity chore: litellm oss 170626 (#30637) 2026-06-17 21:11:12 -07:00
pg_vector/vector_stores fix: encode upstream URL path identifiers 2026-04-29 22:02:39 -07:00
publicai style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
ragflow/chat fix: encode upstream URL path identifiers 2026-04-29 22:02:39 -07:00
recraft style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
reducto Litellm oss staging 04 21 2026 2 (#26569) 2026-05-20 21:25:19 -07:00
runwayml fix: encode upstream URL path identifiers 2026-04-29 22:02:39 -07:00
s3_vectors Fix extra body error 2026-04-29 08:34:31 +05:30
sagemaker fix(sagemaker): send native Cohere embed payload to Cohere SageMaker endpoints (#28613) 2026-05-22 12:00:42 -07:00
sambanova Feat/sambanova embeddings (#13308) 2025-08-12 17:15:26 -07:00
sap style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
scaleway Feature/add audio support for scaleway (#26110) 2026-04-20 14:49:41 -07:00
snowflake chore(oss): litellm oss staging 120626 (#30292) 2026-06-12 09:49:25 -07:00
soniox chore: litellm oss staging (#30745) 2026-06-18 13:55:35 -07:00
stability style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
tinyfish feat(search): add TinyFish as search provider (#30634) 2026-06-18 09:17:53 -07:00
vercel_ai_gateway style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
vertex_ai fix(vertex_ai/files): single media upload for batch files to fix 499s on large uploads (#31653) 2026-06-29 18:10:47 -07:00
volcengine fix: encode upstream URL path identifiers 2026-04-29 22:02:39 -07:00
voyage chore(oss): litellm oss staging 120626 (#30292) 2026-06-12 09:49:25 -07:00
wandb (feat): Add W&B Inference to LiteLLM 2025-09-11 00:07:30 +05:30
watsonx fix(watsonx): wrap string embedding input in array for WatsonX API (#30897) 2026-06-20 15:50:44 -07:00
xai Litellm oss 090626 (#30021) 2026-06-10 10:34:07 -07:00
you_com Litellm oss staging 050626 (#29774) 2026-06-05 13:51:51 -07:00
zai style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_cache_control_and_reasoning.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_file_content_block.py Litellm oss staging (#28161) 2026-05-18 16:27:44 -07:00
test_file_search_responses.py fix(tests): use canonical litellm_enterprise import path (#27699) 2026-05-12 12:32:57 -07:00
test_lifecycle_fix.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_oom_fixes.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_polling_url_origin_match.py chore(security): close two unaddressed SSRF cases 2026-05-01 18:43:47 +00:00
test_predibase_transformation.py refactor(predibase): migrate transform_request and transform_response… (#25249) 2026-04-27 08:58:22 +05:30