From ae79d982509b8b12e9cb2afd77cacc13a4a2869b Mon Sep 17 00:00:00 2001 From: Baojiang Lee <101562714+libaojiang@users.noreply.github.com> Date: Mon, 31 Aug 2026 10:19:26 +0800 Subject: [PATCH] style(vertex_ai): remove redundant signature comments --- .../litellm_core_utils/prompt_templates/factory.py | 7 +------ .../gemini/test_thought_signature_in_tool_call_id.py | 12 ------------ 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/litellm/litellm_core_utils/prompt_templates/factory.py b/litellm/litellm_core_utils/prompt_templates/factory.py index 2714c0f29c5..5f3568c64c2 100644 --- a/litellm/litellm_core_utils/prompt_templates/factory.py +++ b/litellm/litellm_core_utils/prompt_templates/factory.py @@ -1212,12 +1212,7 @@ def _get_thought_signature_from_tool(tool: dict) -> str | None: signature = function.provider_specific_fields.get("thought_signature") if signature: return signature - # Check if thought signature is embedded in tool call ID. - # Any client that normalizes the id shortens/hashes it, so the segment - # after ``__thought__`` may no longer base64-decode. Reject those here so - # the caller can decide between "no signature" and the dummy fallback, - # instead of forwarding a corrupted value that would 400 on Vertex. See - # issue #37849. + # Check if thought signature is embedded in tool call ID tool_call_id: Final = tool.get("id") if tool_call_id and THOUGHT_SIGNATURE_SEPARATOR in tool_call_id: parts: Final = tool_call_id.split(THOUGHT_SIGNATURE_SEPARATOR, 1) diff --git a/tests/test_litellm/llms/vertex_ai/gemini/test_thought_signature_in_tool_call_id.py b/tests/test_litellm/llms/vertex_ai/gemini/test_thought_signature_in_tool_call_id.py index ef1002c8399..489564c3e0c 100644 --- a/tests/test_litellm/llms/vertex_ai/gemini/test_thought_signature_in_tool_call_id.py +++ b/tests/test_litellm/llms/vertex_ai/gemini/test_thought_signature_in_tool_call_id.py @@ -246,9 +246,6 @@ def test_openai_client_e2e_flow(enable_preview_features): @pytest.mark.parametrize("enable_preview_features", [True, False]) def test_parallel_tool_calls_with_signatures(enable_preview_features): """Test that parallel tool calls preserve signatures correctly""" - # Real Gemini signatures are standard-alphabet base64; using a valid - # placeholder keeps the parallel-tool-call path lit up under the - # base64-validated extraction added for issue #37849. signature1 = base64.b64encode(b"signature_for_first_call").decode("ascii") # Only first call has signature (Gemini behavior for parallel calls) @@ -294,18 +291,11 @@ REAL_SIGNATURE = ( ) -# Signature values a client-side id sanitizer produces after stripping the raw -# base64 down to id-shaped characters. Standard-alphabet base64 has no ``_`` or -# trailing hex fragment, so Vertex rejects these with either "Base64 decoding -# failed" or "Invalid thought signature". See issue #37849. @pytest.mark.parametrize( "mangled_signature", [ - # from the issue reproducer, /v1/responses turn 2 "AY89a1/_57b05e78dc", - # from the issue reproducer, /v1/chat/completions turn 2 "AY89a1/_ee781c9832", - # short SHA-suffix-only sanitization "AY89a1_S3YvIpUCcBTFSgDfesRLDnA_775ff49bcd", ], ) @@ -315,8 +305,6 @@ def test_is_valid_thought_signature_rejects_client_normalized_values(mangled_sig def test_is_valid_thought_signature_tolerates_missing_padding(): - # Gemini omits ``=`` on the wire; the strict decoder must still accept the - # value once we re-pad it. encoded = base64.b64encode(b"hello").decode("ascii").rstrip("=") assert "=" not in encoded assert _is_valid_thought_signature(encoded) is True