From 862f0de839b589e4c3ccbe9eddb65415eca5a859 Mon Sep 17 00:00:00 2001 From: ryan-crabbe <128659760+ryan-crabbe@users.noreply.github.com> Date: Sat, 7 Feb 2026 10:54:07 -0800 Subject: [PATCH] perf: guard debug f-string in update_environment_variables to avoid evaluation when disabled (#20360) --- litellm/litellm_core_utils/litellm_logging.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.py index d70798060c..7ae62718af 100644 --- a/litellm/litellm_core_utils/litellm_logging.py +++ b/litellm/litellm_core_utils/litellm_logging.py @@ -526,7 +526,8 @@ class Logging(LiteLLMLoggingBaseClass): } self.litellm_request_debug = litellm_params.get("litellm_request_debug", False) self.logger_fn = litellm_params.get("logger_fn", None) - verbose_logger.debug(f"self.optional_params: {self.optional_params}") + if _is_debugging_on() or self.litellm_request_debug: + verbose_logger.debug(f"self.optional_params: {self.optional_params}") self.model_call_details.update( {