From 244c80a7defa0fd826e91ed5f112467dc6911198 Mon Sep 17 00:00:00 2001 From: shin-bot-litellm Date: Sat, 31 Jan 2026 10:38:47 -0800 Subject: [PATCH] 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. --- litellm/router.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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"] = {}