From f2a891f2b448b878a5dbf4b5b0a6166c807b3705 Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Mon, 29 Sep 2025 13:38:06 -0700 Subject: [PATCH] add update_response_metadata for caching handler --- litellm/caching/caching_handler.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/litellm/caching/caching_handler.py b/litellm/caching/caching_handler.py index 9526c4a2f39..92b7def345d 100644 --- a/litellm/caching/caching_handler.py +++ b/litellm/caching/caching_handler.py @@ -50,6 +50,7 @@ from litellm.types.utils import ( TranscriptionResponse, Usage, ) +from litellm.utils import update_response_metadata if TYPE_CHECKING: from litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLoggingObj @@ -716,6 +717,18 @@ class LLMCachingHandler: and isinstance(cached_result._hidden_params, dict) ): cached_result._hidden_params["cache_hit"] = True + + ######################################################### + # Add final timing metrics to the cached result + ######################################################### + update_response_metadata( + result=cached_result, + logging_obj=logging_obj, + model=model, + kwargs=kwargs, + start_time=self.start_time, + end_time=datetime.datetime.now(), + ) return cached_result def _convert_cached_stream_response(