From dc6161535a00ec2d08a5c563640afb147d272926 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Sat, 30 Aug 2025 11:06:02 -0700 Subject: [PATCH] fix for supports_reasoning check added in 68f48476598b4fa4aef51d95f1c708c51f150d73 --- .../gemini/vertex_and_google_ai_studio_gemini.py | 8 ++++++-- tests/llm_translation/test_gemini.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py b/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py index 6cdde8ea4b1..569a05d8ad8 100644 --- a/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py +++ b/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py @@ -465,7 +465,6 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig): params["includeThoughts"] = True if thinking_budget is not None and isinstance(thinking_budget, int): params["thinkingBudget"] = thinking_budget - return params def map_response_modalities(self, value: list) -> list: @@ -618,7 +617,12 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig): optional_params = self._add_tools_to_optional_params( optional_params, [_tools] ) - if supports_reasoning(model): + + ###################################################################################### + # If the model supports reasoning and `thinkingConfig` is not set as yet + # we should set it to includeThoughts + ###################################################################################### + if supports_reasoning(model) and "thinkingConfig" not in optional_params: optional_params["thinkingConfig"] = ( VertexGeminiConfig._map_reasoning_effort_to_thinking_budget( non_default_params.get("reasoning_effort") diff --git a/tests/llm_translation/test_gemini.py b/tests/llm_translation/test_gemini.py index 15ee7505edb..08caf5b6147 100644 --- a/tests/llm_translation/test_gemini.py +++ b/tests/llm_translation/test_gemini.py @@ -329,7 +329,7 @@ def test_gemini_thinking_budget_0(): "thinking": {"type": "enabled", "budget_tokens": 0}, }, ) - print(raw_request) + print(json.dumps(raw_request, indent=4, default=str)) assert "0" in json.dumps(raw_request["raw_request_body"])