From fb5fd347673baa76c3857acedf53bfb19f84da1e 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 3b2b129e309..a9dcfb12bd0 100644 --- a/litellm/litellm_core_utils/prompt_templates/factory.py +++ b/litellm/litellm_core_utils/prompt_templates/factory.py @@ -1314,12 +1314,7 @@ def get_thought_signature_from_tool(tool: Mapping[str, object]) -> str | None: signature_from_model_fields: Final = typed_function_provider_fields.get("thought_signature") if signature_from_model_fields: return cast(str, signature_from_model_fields) # cast-ok: untyped provider response field - # 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 = cast( # cast-ok: tool IDs come from model responses str, tool.get("id") ) diff --git a/tests/unit/llms/vertex_ai/gemini/test_thought_signature_in_tool_call_id.py b/tests/unit/llms/vertex_ai/gemini/test_thought_signature_in_tool_call_id.py index f7ebf89bc1d..fd7825ac0b0 100644 --- a/tests/unit/llms/vertex_ai/gemini/test_thought_signature_in_tool_call_id.py +++ b/tests/unit/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