Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

litellm_fix(router): use safe_deep_copy in _get_silent_experiment_kwargs (#20170)

shin-bot-litellm244c80a7defa
diff --git a/litellm/router.py b/litellm/router.py
index a3c3afa9326..fb9b19582c0 100644
--- a/litellm/router.py
+++ b/litellm/router.py
@@ -1328,8 +1328,10 @@ class Router:
"""
Prepare kwargs for a silent experiment by ensuring isolation from the primary call.
"""
- # Copy kwargs to ensure isolation
- silent_kwargs = copy.deepcopy(kwargs)
+ # Copy kwargs to ensure isolation (use safe_deep_copy to handle non-serializable objects like OTEL spans)
+ from litellm.litellm_core_utils.core_helpers import safe_deep_copy
+
+ silent_kwargs = safe_deep_copy(kwargs)
if "metadata" not in silent_kwargs:
silent_kwargs["metadata"] = {}