From 6120ddf7865a459f60ae92f169fcfc57eb9a6e2c Mon Sep 17 00:00:00 2001 From: "devin-ai-integration[bot]" <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 21 Oct 2026 00:22:32 +0000 Subject: [PATCH] fix(litellm_proxy): forward tool_config cache_control_injection_points to the downstream proxy (#47570) Backport of #47570 to stable/1.103.x Cherry-picked from 04e9ed4c52505b5a50840843bc8b367aa32d09eb (main) --- litellm/utils.py | 3 ++- tests/test_litellm/test_utils.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/litellm/utils.py b/litellm/utils.py index a60de34ebe4..6dd711d1290 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -4916,8 +4916,9 @@ def add_provider_specific_params_to_optional_params( # for openai, azure we should pass the extra/passed params within `extra_body` https://github.com/openai/openai-python/blob/ac33853ba10d13ac149b1fa3ca6dba7d613065c9/src/openai/resources/models.py#L46 if _should_drop_param(k="extra_body", additional_drop_params=additional_drop_params) is False: extra_body: Final = dict(passed_params.pop("extra_body", None) or {}) + withheld_params: Final = frozenset[str]() if custom_llm_provider == "litellm_proxy" else LITELLM_ONLY_PARAMS for k in passed_params: - if k not in openai_params and k not in LITELLM_ONLY_PARAMS and passed_params[k] is not None: + if k not in openai_params and k not in withheld_params and passed_params[k] is not None: extra_body[k] = passed_params[k] if not isinstance(optional_params.get("extra_body"), dict): optional_params["extra_body"] = {} diff --git a/tests/test_litellm/test_utils.py b/tests/test_litellm/test_utils.py index aaa10f59562..88d37eb4a05 100644 --- a/tests/test_litellm/test_utils.py +++ b/tests/test_litellm/test_utils.py @@ -5881,3 +5881,18 @@ def test_get_optional_params_keeps_a_tool_config_cache_point_out_of_the_openai_e assert optional_params["extra_body"] == {"kept": True} assert "cache_control_injection_points" not in optional_params + + +def test_get_optional_params_forwards_a_tool_config_cache_point_to_a_downstream_litellm_proxy(): + """A litellm_proxy deployment calls the downstream proxy through the OpenAI SDK, and that proxy + applies cache_control_injection_points itself, so the point must ride along in extra_body.""" + point: Final = {"location": "tool_config", "control": {"type": "ephemeral"}} + optional_params: Final[dict[str, object]] = litellm.utils.get_optional_params( + model="claude-sonnet-4-5", + custom_llm_provider="litellm_proxy", + tools=[{"type": "function", "function": {"name": "get_weather", "parameters": {"type": "object"}}}], + cache_control_injection_points=[point], + extra_body={"kept": True}, + ) + + assert optional_params["extra_body"] == {"kept": True, "cache_control_injection_points": [point]}