diff --git a/litellm/llms/anthropic/common_utils.py b/litellm/llms/anthropic/common_utils.py index 74f40b52f39..9a58d85238a 100644 --- a/litellm/llms/anthropic/common_utils.py +++ b/litellm/llms/anthropic/common_utils.py @@ -1792,7 +1792,7 @@ def encode_thought_signature_for_anthropic_tool_id(signature: str) -> str: def decode_thought_signature_from_anthropic_tool_id(encoded: str) -> str: """Inverse of ``encode_thought_signature_for_anthropic_tool_id``.""" - pad = (-len(encoded)) % 4 + pad: Final = (-len(encoded)) % 4 return base64.urlsafe_b64decode(encoded + ("=" * pad)).decode("utf-8") @@ -1806,7 +1806,7 @@ def format_anthropic_tool_use_id_with_signature(raw_id: str, thought_signature: signature after ``__thought__`` lets those clients round-trip the real signature the same way OpenAI-compatible clients do via ``tool_calls[].id``. """ - base_id = normalize_anthropic_tool_use_id(raw_id) + base_id: Final = normalize_anthropic_tool_use_id(raw_id) if not thought_signature: return base_id return f"{base_id}{THOUGHT_SIGNATURE_SEPARATOR}{encode_thought_signature_for_anthropic_tool_id(thought_signature)}" diff --git a/litellm/llms/anthropic/pass_through/adapters/transformation.py b/litellm/llms/anthropic/pass_through/adapters/transformation.py index c0fbea3414b..459469cda5c 100644 --- a/litellm/llms/anthropic/pass_through/adapters/transformation.py +++ b/litellm/llms/anthropic/pass_through/adapters/transformation.py @@ -367,19 +367,19 @@ class LiteLLMAnthropicMessagesAdapter: """ fields: Final = _optional_attr(tool_call, "provider_specific_fields") if fields: - signature = _thought_signature(fields) + signature: Final = _thought_signature(fields) if signature: return signature function_fields: Final = _optional_attr(_optional_attr(tool_call, "function"), "provider_specific_fields") if function_fields: - signature = _thought_signature(function_fields) - if signature: - return signature + function_signature: Final = _thought_signature(function_fields) + if function_signature: + return function_signature raw_id: Final = _optional_attr(tool_call, "id") if isinstance(raw_id, str) and THOUGHT_SIGNATURE_SEPARATOR in raw_id: - parts = raw_id.split(THOUGHT_SIGNATURE_SEPARATOR, 1) + parts: Final = raw_id.split(THOUGHT_SIGNATURE_SEPARATOR, 1) if len(parts) == 2 and parts[1]: return parts[1]