Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

docs(vertex_ai): cite Google's thought signature rules for parallel calls

ljogeiger579291774b0a
diff --git a/litellm/litellm_core_utils/prompt_templates/factory.py b/litellm/litellm_core_utils/prompt_templates/factory.py
index 0a9d7c427b4..b676077ab0e 100644
--- a/litellm/litellm_core_utils/prompt_templates/factory.py
+++ b/litellm/litellm_core_utils/prompt_templates/factory.py
@@ -1245,10 +1245,14 @@ def _get_dummy_thought_signature() -> str:
This is used when transferring conversation history from older models
(like gemini-2.5-flash) to gemini-3, which requires thought_signature
- for strict validation.
+ for strict validation. Google documents it as a last resort that "will
+ negatively impact model performance", so callers must only fall back to it
+ when no real signature is available.
+
+ See:
+ https://ai.google.dev/gemini-api/docs/thought-signatures#faqs
+ https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/thinking/thought-signatures
"""
- # Return a base64-encoded dummy signature string
- # Below dummy signature is recommended by google - https://ai.google.dev/gemini-api/docs/thought-signatures#faqs
dummy_data: Final = b"skip_thought_signature_validator"
return base64.b64encode(dummy_data).decode("utf-8")
@@ -1318,6 +1322,9 @@ def convert_to_gemini_tool_call_invoke(
if gemini_function_call is not None:
part_dict: VertexPartType = {"function_call": gemini_function_call}
thought_signature = _get_thought_signature_from_tool(dict(tool))
+ # Gemini signs only the first functionCall part of a parallel batch, so scope the
+ # placeholder fallback to that part instead of fabricating one per sibling call:
+ # https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/thinking/thought-signatures#parallel_function_calling_example
is_first_function_call = len(_parts_list) == 0
if not thought_signature and is_first_function_call and needs_dummy_signature:
thought_signature = _get_dummy_thought_signature()