mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-27 06:13:07 +00:00
fix(litellm_proxy): forward tool_config cache_control_injection_points to the downstream proxy (#47570)
PR #47394 withheld cache_control_injection_points from the OpenAI SDK extra_body for every provider on that path, which also covers litellm_proxy. The downstream LiteLLM proxy applies the point itself, so litellm_proxy keeps forwarding it while OpenAI and the other OpenAI-compatible providers still never receive it Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
c38b86cc93
commit
04e9ed4c52
2 changed files with 17 additions and 1 deletions
|
|
@ -5552,8 +5552,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"] = {}
|
||||
|
|
|
|||
|
|
@ -10703,3 +10703,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]}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue