From 7329fa8e7adf35e00c23206b72e2ab8de461daf4 Mon Sep 17 00:00:00 2001 From: Sameer Kankute Date: Mon, 2 Feb 2026 18:50:58 +0530 Subject: [PATCH] fix: litellm_oss_staging_01_31_2026_3 failing tests --- docs/my-website/docs/proxy/config_settings.md | 1 + .../adapters/streaming_iterator.py | 28 +++++++++++++------ ...al_pass_through_adapters_transformation.py | 1 - 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/docs/my-website/docs/proxy/config_settings.md b/docs/my-website/docs/proxy/config_settings.md index bb2c7e01c8..264c7d765b 100644 --- a/docs/my-website/docs/proxy/config_settings.md +++ b/docs/my-website/docs/proxy/config_settings.md @@ -321,6 +321,7 @@ router_settings: | redis_host | string | The host address for the Redis server. **Only set this if you have multiple instances of LiteLLM Proxy and want current tpm/rpm tracking to be shared across them** | | redis_password | string | The password for the Redis server. **Only set this if you have multiple instances of LiteLLM Proxy and want current tpm/rpm tracking to be shared across them** | | redis_port | string | The port number for the Redis server. **Only set this if you have multiple instances of LiteLLM Proxy and want current tpm/rpm tracking to be shared across them**| +| redis_db | int | The database number for the Redis server. **Only set this if you have multiple instances of LiteLLM Proxy and want current tpm/rpm tracking to be shared across them**| | enable_pre_call_check | boolean | If true, checks if a call is within the model's context window before making the call. [More information here](reliability) | | content_policy_fallbacks | array of objects | Specifies fallback models for content policy violations. [More information here](reliability) | | fallbacks | array of objects | Specifies fallback models for all types of errors. [More information here](reliability) | diff --git a/litellm/llms/anthropic/experimental_pass_through/adapters/streaming_iterator.py b/litellm/llms/anthropic/experimental_pass_through/adapters/streaming_iterator.py index aa2f0cc08f..a86820f82e 100644 --- a/litellm/llms/anthropic/experimental_pass_through/adapters/streaming_iterator.py +++ b/litellm/llms/anthropic/experimental_pass_through/adapters/streaming_iterator.py @@ -409,10 +409,17 @@ class AnthropicStreamWrapper(AdapterCompletionStreamWrapper): ) # Restore original tool name if it was truncated for OpenAI's 64-char limit - if block_type == "tool_use" and content_block_start.get("name"): - truncated_name = content_block_start.get("name", "") - original_name = self.tool_name_mapping.get(truncated_name, truncated_name) - content_block_start["name"] = original_name + if block_type == "tool_use": + # Type narrowing: content_block_start is ToolUseBlock when block_type is "tool_use" + from typing import cast + from litellm.types.llms.anthropic import ToolUseBlock + + tool_block = cast(ToolUseBlock, content_block_start) + + if tool_block.get("name"): + truncated_name = tool_block["name"] + original_name = self.tool_name_mapping.get(truncated_name, truncated_name) + tool_block["name"] = original_name if block_type != self.current_content_block_type: self.current_content_block_type = block_type @@ -421,9 +428,14 @@ class AnthropicStreamWrapper(AdapterCompletionStreamWrapper): # For parallel tool calls, we'll necessarily have a new content block # if we get a function name since it signals a new tool call - if block_type == "tool_use" and content_block_start.get("name"): - self.current_content_block_type = block_type - self.current_content_block_start = content_block_start - return True + if block_type == "tool_use": + from typing import cast + from litellm.types.llms.anthropic import ToolUseBlock + + tool_block = cast(ToolUseBlock, content_block_start) + if tool_block.get("name"): + self.current_content_block_type = block_type + self.current_content_block_start = content_block_start + return True return False diff --git a/tests/test_litellm/llms/anthropic/experimental_pass_through/adapters/test_anthropic_experimental_pass_through_adapters_transformation.py b/tests/test_litellm/llms/anthropic/experimental_pass_through/adapters/test_anthropic_experimental_pass_through_adapters_transformation.py index bcb0059fd1..6a5c022ac7 100644 --- a/tests/test_litellm/llms/anthropic/experimental_pass_through/adapters/test_anthropic_experimental_pass_through_adapters_transformation.py +++ b/tests/test_litellm/llms/anthropic/experimental_pass_through/adapters/test_anthropic_experimental_pass_through_adapters_transformation.py @@ -1531,7 +1531,6 @@ def test_translate_openai_response_to_anthropic_with_reasoning_content_only(): assert cast(Any, anthropic_content[1]).text == "There are **3** \"r\"s in the word strawberry." assert anthropic_response.get("stop_reason") == "end_turn" - assert tool_name_mapping == {} # No truncation needed for short names # =====================================================================