fix(caching): bound warning registry to prevent unbounded growth

This commit is contained in:
Amr Mohammed 2026-09-28 10:02:16 +03:00
parent c1f79fdf86
commit 3cf31e0c4d

View file

@ -393,13 +393,18 @@ class Cache:
continue # ignore None params
param_value = kwargs[param]
cache_key += f"{param}: {param_value}"
elif kwargs[param] is not None and param not in _warned_dropped_cache_params:
elif (
kwargs[param] is not None
and param not in _warned_dropped_cache_params
and len(_warned_dropped_cache_params) < 100
):
_warned_dropped_cache_params.add(param)
verbose_logger.warning(
"litellm.cache: provider-specific param '%s' is excluded from the cache key by default, "
"so requests differing only in '%s' will return the same cached response. "
"Set litellm.enable_caching_on_provider_specific_optional_params=True to include it in the key.",
param, param,
param,
param,
)
if is_semantic_cache: