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

**Regression introduced in:** PR #19544 (feat: add feature to make silent calls)

Fixes check_code_and_doc_quality CI failure.

Line 1332 used copy.deepcopy(kwargs) which violates ban_copy_deepcopy_kwargs
check. kwargs can contain non-serializable objects like OTEL spans.

Changed to safe_deep_copy(kwargs) which handles these correctly.
This commit is contained in:
shin-bot-litellm 2026-01-31 10:38:47 -08:00 • committed by GitHub
parent df042f7545
commit 244c80a7de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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"] = {}