From 5b7e11eaec7538b2becced142362f1f905ddbc6f Mon Sep 17 00:00:00 2001 From: Roy Vivat Date: Mon, 23 Mar 2026 16:43:30 -0700 Subject: [PATCH] Apply suggestions from code review Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --- .../gemini/vertex_and_google_ai_studio_gemini.py | 8 +++++++- .../gemini/test_vertex_gemini_unbound_local_error.py | 1 - 2 files changed, 7 insertions(+), 2 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 63955cec1bf..1c13af7b03c 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 @@ -3014,7 +3014,13 @@ class ModelResponseIterator: hasattr(choice, "finish_reason") and choice.finish_reason == "stop" and hasattr(choice, "delta") - and (choice.delta is None or not choice.delta.tool_calls) + and ( + choice.delta is None + or ( + not choice.delta.tool_calls + and choice.delta.content is None + ) + ) ): choice.finish_reason = "tool_calls" diff --git a/tests/test_litellm/llms/vertex_ai/gemini/test_vertex_gemini_unbound_local_error.py b/tests/test_litellm/llms/vertex_ai/gemini/test_vertex_gemini_unbound_local_error.py index 23e16871c96..8722942dab0 100644 --- a/tests/test_litellm/llms/vertex_ai/gemini/test_vertex_gemini_unbound_local_error.py +++ b/tests/test_litellm/llms/vertex_ai/gemini/test_vertex_gemini_unbound_local_error.py @@ -13,7 +13,6 @@ Ref: https://github.com/BerriAI/litellm/issues/24442 import pytest -import litellm from litellm import ModelResponse from litellm.llms.vertex_ai.gemini.vertex_and_google_ai_studio_gemini import ( VertexGeminiConfig,