From 3e0d77b724fc8a3577f83ee19dc014c6aa84651e Mon Sep 17 00:00:00 2001 From: Ryan Crabbe Date: Mon, 26 Jan 2026 16:21:00 -0800 Subject: [PATCH] perf: remove redundant get_llm_provider call in function_setup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The get_llm_provider call was used to determine if the target model is a Gemini model for thought signature removal. This call is redundant because _is_gemini_model already has a fallback that checks if "gemini" is in the model name, which covers all cases where get_llm_provider would return "gemini" as the provider. Profiling shows this reduces function_setup time by ~37% (8.18s -> 5.19s across 6000 requests), saving ~500µs per request. --- litellm/utils.py | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/litellm/utils.py b/litellm/utils.py index 584ab8805a0..7968ffe02d3 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -973,28 +973,12 @@ def function_setup( # noqa: PLR0915 # signatures to ensure compatibility. if isinstance(messages, list) and len(messages) > 0: try: - from litellm.litellm_core_utils.get_llm_provider_logic import ( - get_llm_provider, - ) from litellm.litellm_core_utils.prompt_templates.factory import ( THOUGHT_SIGNATURE_SEPARATOR, ) - # Get custom_llm_provider to determine target provider custom_llm_provider = kwargs.get("custom_llm_provider") - # If custom_llm_provider not in kwargs, try to determine it from the model - if not custom_llm_provider and model: - try: - _, custom_llm_provider, _, _ = get_llm_provider( - model=model, - custom_llm_provider=custom_llm_provider, - ) - except Exception: - # If we can't determine the provider, skip this processing - pass - - # Only process if target is NOT a Gemini model if not _is_gemini_model(model, custom_llm_provider): verbose_logger.debug( "Removing thought signatures from tool call IDs for non-Gemini model"