Skip to content

chore(release): v1.105.2 patch - #47519

Merged
yuneng-berri merged 12 commits into
stable/1.105.xfrom
patch_27570705
Oct 20, 2026
Merged

yuneng-berri merged 12 commits into
stable/1.105.xfrom
patch_27570705

Conversation

@yuneng-berri

@yuneng-berri yuneng-berri commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • stable/1.105.x is missing 7 fixes from main and the v1.104.4 token count patch
  • Upgrading from 1.104.4 or 1.103.5 to 1.105.1 loses them today

How it solves it:

  • One -x cherry-pick per main PR, in main merge order, plus 1 prerequisite
  • The three stable/1.104.x count_tokens merges replayed with -m 1, in their merge order
  • No pricing data sync, only the count_tokens merge's own pricing entries
  • Bumps litellm 1.105.1 -> 1.105.2

Backport

Added prerequisites

Adaptation notes

#46099

  • accumulate and chain come from itertools, which this line's transformation module did not import yet, so the import is added (main and stable/1.103.x already have it)
  • list_value is added to tests/integration/_support/client.py byte for byte as on main, since the PR's integration test calls it
  • The unit test file hit an empty-HEAD append conflict, so it was reset to the line's copy and only the PR's own test was appended
Interdiff against main 4b7b8ef
--- main 4b7b8efd4c
+++ line d442ef4cbb
@@ -1,6 +1,14 @@
 diff --git a/litellm/completion_extras/litellm_responses_transformation/transformation.py b/litellm/completion_extras/litellm_responses_transformation/transformation.py
 --- a/litellm/completion_extras/litellm_responses_transformation/transformation.py
 +++ b/litellm/completion_extras/litellm_responses_transformation/transformation.py
+@@ Handler for transforming /chat/completions api requests to litellm.responses req
+ import json
+ import os
+ from collections.abc import AsyncIterator, Callable, Iterable, Iterator, Mapping, Sequence
++from itertools import accumulate, chain
+ from types import MappingProxyType
+ from typing import TYPE_CHECKING, Any, Final, Literal, TypedDict, TypeVar, Union, cast
+ 
 @@ if TYPE_CHECKING:
          ChatCompletionToolReferenceObject,
          OpenAIMessageContentListBlock,
@@ -134,6 +142,21 @@
  
      @staticmethod
      def _build_empty_incomplete_choice(
+diff --git a/tests/integration/_support/client.py b/tests/integration/_support/client.py
+--- a/tests/integration/_support/client.py
++++ b/tests/integration/_support/client.py
+@@ def object_value(value: JsonValue) -> dict[str, JsonValue]:
+     return JSON_OBJECT.validate_python(value)
+ 
+ 
++def list_value(value: JsonValue) -> Sequence[JsonValue]:
++    assert isinstance(value, list), f"Expected a list, received {type(value).__name__}"
++    return value
++
++
+ def string_value(value: JsonValue) -> str:
+     assert isinstance(value, str), f"Expected a string, received {type(value).__name__}"
+     return value
 diff --git a/tests/integration/providers/test_responses_bridge_incomplete.py b/tests/integration/providers/test_responses_bridge_incomplete.py
 --- a/tests/integration/providers/test_responses_bridge_incomplete.py
 +++ b/tests/integration/providers/test_responses_bridge_incomplete.py
@@ -408,13 +431,10 @@
 diff --git a/tests/unit/completion_extras/litellm_responses_transformation/test_completion_extras_litellm_responses_transformation_transformation.py b/tests/unit/completion_extras/litellm_responses_transformation/test_completion_extras_litellm_responses_transformation_transformation.py
 --- a/tests/unit/completion_extras/litellm_responses_transformation/test_completion_extras_litellm_responses_transformation_transformation.py
 +++ b/tests/unit/completion_extras/litellm_responses_transformation/test_completion_extras_litellm_responses_transformation_transformation.py
-@@ def test_transform_request_drop_params_in_litellm_params_gates_the_prompt_cache_
-         litellm_logging_obj=Mock(),
-     )
- 
--    assert "prompt_cache_breakpoint" not in result["input"][0]["content"][0]
-\ No newline at end of file
-+    assert "prompt_cache_breakpoint" not in result["input"][0]["content"][0]
+@@ def test_every_bridged_chunk_after_response_created_carries_the_served_service_t
+     relayed = [iterator.chunk_parser(event).model_dump().get("service_tier") for event in events]
+ 
+     assert relayed == ["default"] * len(events), relayed
 +
 +
 +def test_convert_response_output_folds_two_messages_and_function_call_into_one_choice() -> None:

#46342

  • The incoming main-only tool_call_is_rebuilt_as_server_tool_use block was dropped, since that helper does not exist on this line and only its rename hunk belonged to the PR
  • The Bedrock Invoke thinking rebuild writes to optional_params on this line (main names it mapped_params)
  • Test imports were resolved to this line's import blocks, adding ChatCompletionAssistantMessage, Mapping and httpx that the PR's new tests use
  • This line is deliberately narrower than main in one place, and the narrowing is spread over the pick 05de300ed6 and the follow-up commit 9a4884cd12. Only the Anthropic, Azure AI and Bedrock Invoke configs themselves carry thinking.block_binding when they rebuild thinking, which covers the legacy thinking.type: enabled to adaptive rebuild and Bedrock Invoke's display: updates and clear_thinking rebuilds, and they carry no other caller key. Configs that subclass them for other providers (Bedrock Mantle, Claude Platform, OpenAI-compatible Anthropic endpoints) opt out, so they and every other Anthropic-format provider send the same thinking 1.105.1 sent, and no provider the PR does not name gets a new field. The PR's shared-helper test is replaced by tests that pin this per config on chat and /v1/messages
Interdiff against main f470e41
--- main f470e418ea
+++ line 05de300ed6
@@ -25,7 +25,7 @@
 +    return not (isinstance(signature, str) and len(signature) > 0)
  
  
- def native_redacted_thinking_data(data: str) -> str:
+ def strip_encrypted_reasoning_from_messages(
 diff --git a/litellm/litellm_core_utils/prompt_templates/factory.py b/litellm/litellm_core_utils/prompt_templates/factory.py
 --- a/litellm/litellm_core_utils/prompt_templates/factory.py
 +++ b/litellm/litellm_core_utils/prompt_templates/factory.py
@@ -57,6 +57,32 @@
      return part_type in _RENDERED_ASSISTANT_PART_TYPES or (
          isinstance(part_type, str) and part_type.endswith("_tool_result")
      )
+diff --git a/litellm/llms/anthropic/chat/transformation.py b/litellm/llms/anthropic/chat/transformation.py
+--- a/litellm/llms/anthropic/chat/transformation.py
++++ b/litellm/llms/anthropic/chat/transformation.py
+@@ class AnthropicConfig(AnthropicModelInfo, BaseConfig):
+     def _resolved_provider(self) -> str:
+         return self.custom_llm_provider or "anthropic"
+ 
++    @property
++    def _carries_thinking_block_binding(self) -> bool:
++        return self._resolved_provider in ("anthropic", "azure_ai")
++
+     @classmethod
+     def get_config(cls, *, model: str | None = None):
+         config: Final = super().get_config()
+@@ class AnthropicConfig(AnthropicModelInfo, BaseConfig):
+                 else:
+                     optional_params["thinking"] = value
+                     AnthropicModelInfo.translate_legacy_thinking_for_adaptive_model(
+-                        model=model, optional_params=optional_params, custom_llm_provider=self._resolved_provider
++                        model=model,
++                        optional_params=optional_params,
++                        custom_llm_provider=self._resolved_provider,
++                        carries_block_binding=self._carries_thinking_block_binding,
+                     )
+             elif param == "reasoning_effort":
+                 # Accept both string ("low") and dict ({"effort": "low",
 diff --git a/litellm/llms/anthropic/common_utils.py b/litellm/llms/anthropic/common_utils.py
 --- a/litellm/llms/anthropic/common_utils.py
 +++ b/litellm/llms/anthropic/common_utils.py
@@ -100,6 +126,14 @@
          user_agent is not None
          and is_claude_code_user_agent(user_agent)
 @@ class AnthropicModelInfo(BaseLLMModelInfo):
+         model: str,
+         optional_params: MutableMapping[str, object],  # mutable-ok: in-place out-param like the sibling helpers
+         custom_llm_provider: str,
++        carries_block_binding: bool = False,
+     ) -> None:
+         """Translate legacy ``thinking.type=enabled`` to adaptive for the
+         adaptive-thinking models that reject it (4.7+ and the 5 families).
+@@ class AnthropicModelInfo(BaseLLMModelInfo):
              return
          if AnthropicModelInfo._supports_legacy_thinking(model, custom_llm_provider):
              return
@@ -123,10 +157,12 @@
 -        else:
 -            optional_params["thinking"] = {"type": "adaptive"}
 +        supported_display: Final = {"display": display} if display in ("summarized", "omitted") else {}
-+        carried_thinking_keys: Final = {
-+            key: value for key, value in thinking.items() if key not in ("type", "budget_tokens", "display")
-+        }
-+        optional_params["thinking"] = {**carried_thinking_keys, "type": "adaptive", **supported_display}
++        carried_block_binding: Final = (
++            {"block_binding": thinking["block_binding"]}
++            if carries_block_binding and "block_binding" in thinking
++            else {}
++        )
++        optional_params["thinking"] = {**carried_block_binding, "type": "adaptive", **supported_display}
          optional_params["output_config"] = {
              "effort": effort,
              **(existing_output_config if isinstance(existing_output_config, dict) else MappingProxyType({})),
@@ -151,15 +187,28 @@
  def strip_thinking_blocks_from_anthropic_messages(messages: Sequence[object]) -> list[object]:
      """
      Return a new message list with thinking / redacted_thinking content blocks removed
-@@ def _replayed_server_tool_use(block: object) -> _ReplayedServerToolUse | None:
- def tool_call_is_rebuilt_as_server_tool_use(
-     tool_call_id: object, provider_specific_fields: object, answered_tool_ids: Container[str] = frozenset()
- ) -> bool:
--    fields: Final = _validated_claude_code_mapping(provider_specific_fields)
-+    fields: Final = validated_object_mapping(provider_specific_fields)
-     if not isinstance(tool_call_id, str) or tool_call_id in answered_tool_ids or fields is None:
-         return False
-     return (
+diff --git a/litellm/llms/anthropic/pass_through/messages/transformation.py b/litellm/llms/anthropic/pass_through/messages/transformation.py
+--- a/litellm/llms/anthropic/pass_through/messages/transformation.py
++++ b/litellm/llms/anthropic/pass_through/messages/transformation.py
+@@ class AnthropicMessagesConfig(BaseAnthropicMessagesConfig):
+     def _resolved_provider(self) -> str:
+         return self.custom_llm_provider or "anthropic"
+ 
++    @property
++    def _carries_thinking_block_binding(self) -> bool:
++        return self._resolved_provider in ("anthropic", "azure_ai")
++
+     def get_supported_anthropic_messages_params(self, model: str) -> list:
+         return [
+             "messages",
+@@ class AnthropicMessagesConfig(BaseAnthropicMessagesConfig):
+             model=model,
+             optional_params=anthropic_messages_optional_request_params,
+             custom_llm_provider=self._resolved_provider,
++            carries_block_binding=self._carries_thinking_block_binding,
+         )
+ 
+         self._translate_adaptive_effort_for_non_adaptive_model(
 diff --git a/litellm/llms/base_llm/anthropic_messages/transformation.py b/litellm/llms/base_llm/anthropic_messages/transformation.py
 --- a/litellm/llms/base_llm/anthropic_messages/transformation.py
 +++ b/litellm/llms/base_llm/anthropic_messages/transformation.py
@@ -206,15 +255,38 @@
 --- a/litellm/llms/bedrock/chat/invoke_transformations/anthropic_claude3_transformation.py
 +++ b/litellm/llms/bedrock/chat/invoke_transformations/anthropic_claude3_transformation.py
 @@ class AmazonAnthropicClaudeConfig(AmazonInvokeConfig, AnthropicConfig):
+     def custom_llm_provider(self) -> str | None:
+         return "bedrock"
+ 
++    @property
++    def _carries_thinking_block_binding(self) -> bool:
++        return True
++
+     def should_strip_billing_metadata(self) -> bool:
+         return True
+ 
+@@ class AmazonAnthropicClaudeConfig(AmazonInvokeConfig, AnthropicConfig):
+         model = original_model
+ 
+         AnthropicModelInfo.translate_legacy_thinking_for_adaptive_model(
+-            model=original_model, optional_params=optional_params, custom_llm_provider="bedrock"
++            model=original_model,
++            optional_params=optional_params,
++            custom_llm_provider="bedrock",
++            carries_block_binding=self._carries_thinking_block_binding,
+         )
+         translated_thinking: Final = optional_params.get("thinking")
+         if (
+@@ class AmazonAnthropicClaudeConfig(AmazonInvokeConfig, AnthropicConfig):
              and isinstance(translated_thinking, dict)
              and translated_thinking.get("type") == "adaptive"
          ):
 -            thinking_with_display: Final[AnthropicThinkingParam] = {"type": "adaptive", "display": "updates"}
--            mapped_params["thinking"] = thinking_with_display
-+            mapped_params["thinking"] = {**translated_thinking, "display": "updates"}
- 
-         return mapped_params
- 
+-            optional_params["thinking"] = thinking_with_display
++            optional_params["thinking"] = {**translated_thinking, "display": "updates"}
+ 
+         # The stub model hides the original model from the parent's forced-tool-use backstop
+         response_format_tool_choice: Final = optional_params.get("tool_choice")
 diff --git a/litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py b/litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py
 --- a/litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py
 +++ b/litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py
@@ -235,6 +307,17 @@
  )
  from litellm.types.llms.bedrock import BedrockInvokeAnthropicMessagesRequest
  from litellm.types.llms.openai import AllMessageValues
+@@ class AmazonAnthropicClaudeMessagesConfig(
+     def custom_llm_provider(self) -> str | None:
+         return "bedrock"
+ 
++    @property
++    def _carries_thinking_block_binding(self) -> bool:
++        return True
++
+     @property
+     def beta_headers_provider(self) -> str:
+         return self.custom_llm_provider or "bedrock"
 @@ class AmazonAnthropicClaudeMessagesConfig(
          if not isinstance(output_config, dict):
              output_config = {}
@@ -311,14 +394,14 @@
 --- a/tests/unit/litellm_core_utils/prompt_templates/test_litellm_core_utils_prompt_templates_factory.py
 +++ b/tests/unit/litellm_core_utils/prompt_templates/test_litellm_core_utils_prompt_templates_factory.py
 @@ from litellm.litellm_core_utils.prompt_templates.factory import (
+     ollama_pt,
      sanitize_messages_for_tool_calling,
-     THOUGHT_SIGNATURE_SEPARATOR,
  )
 -from litellm.types.llms.openai import ChatCompletionToolMessage
 +from litellm.types.llms.openai import ChatCompletionAssistantMessage, ChatCompletionToolMessage
- from litellm.utils import (
-     _invalidate_model_cost_lowercase_map,
-     function_setup,
+ from litellm.utils import validate_and_fix_openai_messages
+ 
+ 
 @@ def test_anthropic_messages_pt_drops_a_system_message_with_no_text():
      assert [m["role"] for m in result] == ["user", "assistant"]
  
@@ -402,7 +485,7 @@
 -    the same as a fully empty string and drop the block.
 -
 -    The check lives in the shared `is_unsignable_thinking_block` helper, which
--    `_replayable_thinking_blocks` calls standalone, so the whitespace-aware
+-    `_drop_unsignable_thinking_blocks` calls standalone, so the whitespace-aware
 -    test has to hold there rather than only at the factory call site.
 +    An empty block without a signature is the shape Claude Code replays after a
 +    non-Anthropic turn, and Anthropic rejects it, so only the missing signature
@@ -456,18 +539,23 @@
 +        "signed-empty-thinking-part",
          "function-call",
          "pydantic-tool-calls",
-         "unanswered-tool-search-use-beside-a-client-call",
+     ],
 diff --git a/tests/unit/llms/anthropic/test_anthropic_common_utils.py b/tests/unit/llms/anthropic/test_anthropic_common_utils.py
 --- a/tests/unit/llms/anthropic/test_anthropic_common_utils.py
 +++ b/tests/unit/llms/anthropic/test_anthropic_common_utils.py
-@@ import json
+@@ Verifies that:
+ import json
  import os
  import sys
- import threading
 +from collections.abc import Mapping
- from pathlib import Path
  from types import SimpleNamespace
  from typing import Final
+ from unittest.mock import patch
+ 
++import httpx
+ import pytest
+ 
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../../..")))
 @@ class TestPassthroughAuthToken:
          assert url == "https://custom.example.com/v1/messages"
  
@@ -535,28 +623,98 @@
      assert optional_params["thinking"] == expected_thinking
  
  
++LEGACY_THINKING_WITH_BINDING: Final = {
++    "type": "enabled",
++    "budget_tokens": 2048,
++    "block_binding": {"prefix_mismatch_behavior": "error"},
++    "future_key": 1,
++}
++
++
++def _rebuilt_thinking(carries_block_binding: bool) -> dict[str, object]:
++    return {
++        "type": "adaptive",
++        **({"block_binding": LEGACY_THINKING_WITH_BINDING["block_binding"]} if carries_block_binding else {}),
++    }
++
++
 +@pytest.mark.usefixtures("local_model_cost_map")
-+def test_shared_legacy_thinking_translation_carries_block_binding() -> None:
-+    from litellm.llms.anthropic.common_utils import AnthropicModelInfo
-+
-+    optional_params: Final = {
-+        "thinking": {
-+            "type": "enabled",
-+            "budget_tokens": 2048,
-+            "block_binding": {"prefix_mismatch_behavior": "error"},
-+        },
-+    }
-+
-+    AnthropicModelInfo.translate_legacy_thinking_for_adaptive_model(
-+        model="claude-opus-5",
-+        optional_params=optional_params,
-+        custom_llm_provider="azure_ai",
-+    )
-+
-+    assert optional_params["thinking"] == {
-+        "type": "adaptive",
-+        "block_binding": {"prefix_mismatch_behavior": "error"},
-+    }
++@pytest.mark.parametrize(
++    ("provider", "carries_block_binding"),
++    (
++        ("anthropic", True),
++        ("azure_ai", True),
++        ("bedrock_invoke", True),
++        ("vertex_ai", False),
++        ("databricks", False),
++        ("bedrock_converse", False),
++    ),
++)
++def test_chat_legacy_thinking_rebuild_carries_only_block_binding_and_only_where_supported(
++    provider: str, carries_block_binding: bool
++) -> None:
++    from litellm.llms.anthropic.chat.transformation import AnthropicConfig
++    from litellm.llms.azure_ai.anthropic.transformation import AzureAnthropicConfig
++    from litellm.llms.bedrock.chat.converse_transformation import AmazonConverseConfig
++    from litellm.llms.bedrock.chat.invoke_transformations.anthropic_claude3_transformation import (
++        AmazonAnthropicClaudeConfig,
++    )
++    from litellm.llms.databricks.chat.transformation import DatabricksConfig
++    from litellm.llms.vertex_ai.vertex_ai_partner_models.anthropic.transformation import VertexAIAnthropicConfig
++
++    config, model = {
++        "anthropic": (AnthropicConfig(), "claude-opus-4-8"),
++        "azure_ai": (AzureAnthropicConfig(), "claude-opus-4-8"),
++        "bedrock_invoke": (AmazonAnthropicClaudeConfig(), "us.anthropic.claude-opus-4-8"),
++        "vertex_ai": (VertexAIAnthropicConfig(), "claude-opus-4-8"),
++        "databricks": (DatabricksConfig(), "databricks-claude-opus-4-8"),
++        "bedrock_converse": (AmazonConverseConfig(), "us.anthropic.claude-opus-4-8"),
++    }[provider]
++
++    mapped: Final = config.map_openai_params(
++        non_default_params={"max_tokens": 4096, "thinking": dict(LEGACY_THINKING_WITH_BINDING)},
++        optional_params={},
++        model=model,
++        drop_params=False,
++    )
++
++    assert mapped["thinking"] == _rebuilt_thinking(carries_block_binding)
++
++
++@pytest.mark.usefixtures("local_model_cost_map")
++@pytest.mark.parametrize(
++    ("provider", "carries_block_binding"),
++    (("anthropic", True), ("azure_ai", True), ("bedrock_invoke", True), ("vertex_ai", False)),
++)
++def test_messages_legacy_thinking_rebuild_carries_only_block_binding_and_only_where_supported(
++    provider: str, carries_block_binding: bool
++) -> None:
++    from litellm.llms.anthropic.pass_through.messages.transformation import AnthropicMessagesConfig
++    from litellm.llms.azure_ai.anthropic.messages_transformation import AzureAnthropicMessagesConfig
++    from litellm.llms.bedrock.messages.invoke_transformations.anthropic_claude3_transformation import (
++        AmazonAnthropicClaudeMessagesConfig,
++    )
++    from litellm.llms.vertex_ai.vertex_ai_partner_models.anthropic.experimental_pass_through.transformation import (
++        VertexAIPartnerModelsAnthropicMessagesConfig,
++    )
++    from litellm.types.router import GenericLiteLLMParams
++
++    config, model = {
++        "anthropic": (AnthropicMessagesConfig(), "claude-opus-4-8"),
++        "azure_ai": (AzureAnthropicMessagesConfig(), "claude-opus-4-8"),
++        "bedrock_invoke": (AmazonAnthropicClaudeMessagesConfig(), "us.anthropic.claude-opus-4-8"),
++        "vertex_ai": (VertexAIPartnerModelsAnthropicMessagesConfig(), "claude-opus-4-8"),
++    }[provider]
++
++    request: Final = config.transform_anthropic_messages_request(
++        model=model,
++        messages=[{"role": "user", "content": "Reply with OK"}],
++        anthropic_messages_optional_request_params={"max_tokens": 4096, "thinking": dict(LEGACY_THINKING_WITH_BINDING)},
++        litellm_params=GenericLiteLLMParams(),
++        headers={},
++    )
++
++    assert request["thinking"] == _rebuilt_thinking(carries_block_binding)
 +
 +
  @pytest.mark.usefixtures("local_model_cost_map", "local_beta_headers_config")

#47067

  • This line has no _check_model_access_helper: Final = check_model_access_helper alias, its helper is already named _check_model_access_helper, so the new ownership check calls that name
  • The PR's tests needed Final in the batches endpoint test imports and Router in the auth utils test imports
Interdiff against main e979bd0
--- main e979bd0ecf
+++ line 3ed027b5a6
@@ -1,8 +1,8 @@
 diff --git a/litellm/proxy/auth/auth_checks.py b/litellm/proxy/auth/auth_checks.py
 --- a/litellm/proxy/auth/auth_checks.py
 +++ b/litellm/proxy/auth/auth_checks.py
-@@ def check_model_access_helper(
- _check_model_access_helper: Final = check_model_access_helper
+@@ def _check_model_access_helper(
+     return True
  
  
 +def _owning_team_names_for_team_deployment(
@@ -45,7 +45,7 @@
          ):
              return True
 +    if any(
-+        check_model_access_helper(model=name, llm_router=llm_router, models=models, team_id=team_id)
++        _check_model_access_helper(model=name, llm_router=llm_router, models=models, team_id=team_id)
 +        for name in owning_team_names
 +    ):
 +        return True
@@ -55,6 +55,14 @@
 diff --git a/tests/unit/proxy/auth/test_auth_utils.py b/tests/unit/proxy/auth/test_auth_utils.py
 --- a/tests/unit/proxy/auth/test_auth_utils.py
 +++ b/tests/unit/proxy/auth/test_auth_utils.py
+@@ from litellm.proxy.auth.auth_utils import (
+     log_once_if_budget_reservation_disabled,
+     warn_once_if_custom_auth_skips_common_checks,
+ )
++from litellm.router import Router
+ 
+ 
+ class TestCustomAuthCommonChecksWarning:
 @@ async def test_managed_batch_routes_pass_team_model_access_check(route, request_
          )
  
@@ -183,6 +191,15 @@
 diff --git a/tests/unit/proxy/batches_endpoints/test_endpoints.py b/tests/unit/proxy/batches_endpoints/test_endpoints.py
 --- a/tests/unit/proxy/batches_endpoints/test_endpoints.py
 +++ b/tests/unit/proxy/batches_endpoints/test_endpoints.py
+@@ import logging
+ from contextlib import ExitStack
+ from dataclasses import dataclass
+ from datetime import datetime, timedelta, timezone
+-from typing import Any, Dict, Optional
++from typing import Any, Dict, Final, Optional
+ from unittest.mock import AsyncMock, MagicMock, patch
+ 
+ import httpx
 @@ async def test_cancel__unified_batch_id_rejects_key_without_model_grant(cancel_h
      cancel_harness.router_acancel.assert_not_called()
  

#47389 (the stable/1.104.x count_tokens merge)

  • litellm/llms/anthropic/experimental_pass_through is litellm/llms/anthropic/pass_through on this line. Git placed the new files in the new folder, and their imports were rewritten to the new module path in 9 files
  • Tests the 1.104 merge added under tests/test_litellm/ live under tests/unit/ here, with empty __init__.py files in 4 new test folders (as on main) so same-named test modules do not collide
  • tests/integration/_support/process.py keeps this line's env-driven graceful_stop_seconds
  • The test_utils.py cost map schema takes the union of both lines' keys
  • test_routes_utils.py takes fix(proxy)!: count prompt-only token_counter requests with the provider when call_endpoint is set #46839's own update of the prompt-with-tools fallback test, since the merge counts tools on the prompt path now
  • The merge's own pricing hunks (token_count_framing and token_count_tokenizer, plus two cost-less Databricks entries) are applied from the merge, matching main and v1.104.4. There is no other pricing change
  • Count tokens behaviour was diffed file by file against v1.104.4 (5346a40c37), and every remaining difference is either an import path or 1.105-only code
Interdiff against stable/1.104.x 5e4d160, with paths moved to this line's layout
--- 1.104 litellm/llms/vertex_ai/common_utils.py
+++ 1.105 litellm/llms/vertex_ai/common_utils.py
@@ -102,13 +102,12 @@
 +                return count_context_error_response(blocks_error, request_model, model_to_use)
  
              resolved_contents: Final = (
-                 contents
-                 if contents is not None
--                else _gemini_convert_messages_with_history(
--                    messages=messages or []  # mutable-ok: fallback for None messages; helper signature requires list
+-                contents if contents is not None else _gemini_convert_messages_with_history(messages=messages or [])
++                contents
++                if contents is not None
 +                else await gemini_count_contents(
 +                    request_view.messages, messages_format, model_to_use, "vertex_ai", count_tokens_params_request
-                 )
++                )
              )
 +            if isinstance(resolved_contents, VertexGeminiCountContextError):
 +                return count_context_error_response(resolved_contents, request_model, model_to_use)
--- 1.104 litellm/proxy/proxy_server.py
+++ 1.105 litellm/proxy/proxy_server.py
@@ -1,14 +1,6 @@
 diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py
 --- a/litellm/proxy/proxy_server.py
 +++ b/litellm/proxy/proxy_server.py
-@@ from collections.abc import (
-     MutableMapping,
-     Sequence,
- )
-+from dataclasses import dataclass
- from datetime import datetime, timedelta, timezone
- from itertools import chain
- from types import MappingProxyType, UnionType
 @@ from typing import (
  )
  
@@ -93,7 +85,7 @@
 +    region: str | None,
      messages: list | None,
      contents: list | None,
--    deployment: dict[str, Any] | None,
+-    deployment: dict[str, object] | None,
 +    deployment: Mapping[str, object] | None,
      request_model: str,
      tools: list | None = None,
--- 1.104 tests/integration/_support/process.py
+++ 1.105 tests/integration/_support/process.py
@@ -1,21 +0,0 @@
-diff --git a/tests/integration/_support/process.py b/tests/integration/_support/process.py
---- a/tests/integration/_support/process.py
-+++ b/tests/integration/_support/process.py
-@@ def signal_group(group: int, action: int) -> None:
-         pass
- 
- 
-+def graceful_stop_seconds() -> float:
-+    return 30.0
-+
-+
- def stop_root_process(process: subprocess.Popen[bytes]) -> bool:
-     if process.poll() is not None:
-         return True
-     process.terminate()
-     try:
--        process.wait(timeout=30)
-+        process.wait(timeout=graceful_stop_seconds())
-     except subprocess.TimeoutExpired:
-         return False
-     return True
--- 1.104 tests/unit/llms/azure_ai/anthropic/__init__.py
+++ 1.105 tests/unit/llms/azure_ai/anthropic/__init__.py
@@ -0,0 +1,2 @@
+diff --git a/tests/unit/llms/azure_ai/anthropic/__init__.py b/tests/unit/llms/azure_ai/anthropic/__init__.py
+new file mode 100644
--- 1.104 tests/unit/llms/azure_ai/anthropic/count_tokens/__init__.py
+++ 1.105 tests/unit/llms/azure_ai/anthropic/count_tokens/__init__.py
@@ -0,0 +1,2 @@
+diff --git a/tests/unit/llms/azure_ai/anthropic/count_tokens/__init__.py b/tests/unit/llms/azure_ai/anthropic/count_tokens/__init__.py
+new file mode 100644
--- 1.104 tests/unit/llms/openai/responses/count_tokens/__init__.py
+++ 1.105 tests/unit/llms/openai/responses/count_tokens/__init__.py
@@ -0,0 +1,2 @@
+diff --git a/tests/unit/llms/openai/responses/count_tokens/__init__.py b/tests/unit/llms/openai/responses/count_tokens/__init__.py
+new file mode 100644
--- 1.104 tests/unit/llms/vertex_ai/count_tokens/__init__.py
+++ 1.105 tests/unit/llms/vertex_ai/count_tokens/__init__.py
@@ -0,0 +1,2 @@
+diff --git a/tests/unit/llms/vertex_ai/count_tokens/__init__.py b/tests/unit/llms/vertex_ai/count_tokens/__init__.py
+new file mode 100644
--- 1.104 tests/unit/proxy/proxy_server/test_routes_utils.py
+++ 1.105 tests/unit/proxy/proxy_server/test_routes_utils.py
@@ -9,3 +9,21 @@
          "original_response": None,
          "error": False,
          "error_message": None,
+@@ def test_token_counter_fallback_counts_tools_system_and_anthropic_blocks(client,
+     assert full > bare
+ 
+ 
+-def test_token_counter_fallback_prompt_with_tools_does_not_500(client, auth_as, monkeypatch):
+-    """Regression: a ``prompt`` request carrying ``tools`` but no ``messages`` still counts, because the fallback attaches tools only when counting messages (``token_counter`` rejects tools on the text path)."""
++def test_token_counter_fallback_counts_a_prompt_with_tools_like_its_messages_form(client, auth_as, monkeypatch):
+     monkeypatch.setattr(proxy_server, "llm_router", None)
+     monkeypatch.setattr(litellm, "disable_token_counter", False, raising=False)
+     prompt = "count the tokens in this sentence please"
+@@ def test_token_counter_fallback_prompt_with_tools_does_not_500(client, auth_as,
+         )
+ 
+     assert response.status_code == 200, response.text
+-    assert response.json()["total_tokens"] == litellm.token_counter(model="claude-fable-5", text=prompt)
++    assert response.json()["total_tokens"] == litellm.token_counter(
++        model="claude-fable-5", messages=[{"role": "user", "content": prompt}], tools=tools
++    )
--- 1.104 tests/unit/test_utils.py
+++ 1.105 tests/unit/test_utils.py
@@ -2,9 +2,9 @@
 --- a/tests/unit/test_utils.py
 +++ b/tests/unit/test_utils.py
 @@ def test_aaamodel_prices_and_context_window_json_is_valid():
-                 "supports_video_input": {"type": "boolean"},
-                 "supports_vision": {"type": "boolean"},
                  "supports_web_search": {"type": "boolean"},
+                 "supports_bedrock_runtime_chat_completions_tools_with_reasoning": {"type": "boolean"},
+                 "supports_bedrock_runtime_chat_completions_response_format": {"type": "boolean"},
 +                "token_count_framing": {"type": "integer"},
 +                "token_count_model": {
 +                    "type": "object",

Gate

  • Targeted tests: 42 files, 4501 passed, 0 new failures
  • Cost map tests: 118 files, 6642 passed, 0 new failures, 60 failures already red on the line tip
  • Importer scan: 0 hits
  • Format check: ruff 0.15.3, 50 files clean
  • Gauntlet-mini: run gm-0fcc229ba14b reviewed the tree at 9a4884cd12 across 5 lenses, and this PR stays a draft until that review is done

User Flow

#44277

Before: right after an admin adds a model, part of a client burst for it fails with 400

  1. The admin runs the proxy with 2 workers, models stored in the DB, and no Redis
  2. They send POST http://localhost:4000/model/new for a new model name backed by openai/gpt-4o-mini and get 200
  3. Their clients immediately send 60 concurrent POST http://localhost:4000/v1/chat/completions for that model name
  4. 3 to 12 of them come back 400 Invalid model name passed in model=<name>, the rest 200

After: the same burst succeeds in full

  1. The admin runs the proxy with 2 workers, models stored in the DB, and no Redis
  2. They send POST http://localhost:4000/model/new for a new model name backed by openai/gpt-4o-mini and get 200
  3. Their clients immediately send 60 concurrent POST http://localhost:4000/v1/chat/completions for that model name
  4. All 60 come back 200

#44341

Before: a team streaming chat completions through a dotted Claude alias sees their spend and budgets stay at $0

  1. The admin adds model_name: claude-opus-4.6 pointing at vertex_ai/claude-opus-4-6@default
  2. A developer's app (opencode, the OpenAI SDK) sends POST https://litellm-domain/v1/chat/completions with "model": "claude-opus-4.6" and "stream": true
  3. The stream comes back with "model": "claude-opus-4.6" on every chunk
  4. https://litellm-domain/ui/?page=logs shows the request at $0 spend and the team budget does not move

After: the same streamed request is billed at the deployment's real price

  1. The admin adds model_name: claude-opus-4.6 pointing at vertex_ai/claude-opus-4-6@default
  2. A developer's app sends the same POST https://litellm-domain/v1/chat/completions with "stream": true
  3. The stream still comes back with "model": "claude-opus-4.6" on every chunk
  4. https://litellm-domain/ui/?page=logs shows the request at the claude-opus-4-6 price and the team budget goes up by the same amount

#44346

Before: an agent app sends a tools request through the proxy and the tool call lands in a second choice the app ignores

  1. The app sends POST https://litellm-domain/v1/chat/completions with model: gpt-5.4-mini and one function tool
  2. The response has 2 choices: choices[0] holds the text "Let me check the weather." with finish_reason: "stop"
  3. choices[1] holds the get_weather call with finish_reason: "tool_calls"
  4. The app reads only choices[0], sees a finished answer, and never runs the tool

After: the same request returns the text and the tool call together, so the app runs the tool

  1. The app sends the same POST https://litellm-domain/v1/chat/completions
  2. The response has 1 choice with the text and the get_weather call, finish_reason: "tool_calls"
  3. The app reads choices[0], runs get_weather, and continues the conversation

#46099

Before: an agent built on a choices[0]-only client never calls its weather tool

  1. They send POST https://litellm-domain/v1/chat/completions with model: azure/gpt-5.4-mini, a get_weather tool and no reasoning_effort
  2. The model answers with two short progress messages and then the get_weather call
  3. The response has two choices, choices[0] is "Let me check the weather." with finish_reason: stop and the tool call sits on choices[1]
  4. Their agent reads choices[0], sees plain text, and replies to the user without running the tool

After: the same request returns one choice with the text and the tool call together

  1. They send the same POST https://litellm-domain/v1/chat/completions
  2. The response has one choice, choices[0].message.content is "Let me check the weather. Looking up Paris now." and choices[0].message.tool_calls[0] is get_weather with finish_reason: tool_calls
  3. Their agent runs the tool

#41362

Before: a multi-turn tool-use loop against Claude Fable 5.1 behind the proxy loses the model's reasoning every turn

  1. They send POST https://litellm-domain/v1/messages to a bedrock/us.anthropic.claude-fable-5-1 (or vertex_ai/ / anthropic/) deployment with "thinking": {"type": "adaptive"}
  2. They get HTTP 200 with content: [{"type": "thinking", "thinking": "", "signature": "EqQB..."}, {"type": "text", ...}]
  3. They append that assistant turn verbatim and the next user message. The proxy forwards content: [{"type": "text", ...}]; the provider answers without the earlier reasoning, and under thinking.block_binding an edited earlier message is never reported because the block never arrived

After: the same replay reaches the provider intact

  1. Same two requests
  2. The second request leaves the proxy with the thinking block in place
  3. The provider verifies the signature and continues with the prior reasoning; under block_binding an edited prefix is reported (input_transformations: [{"type": "thinking_dropped", "path": "messages.1.content.0", "reason": "prefix_binding_mismatch"}]) or rejected, as Anthropic documents. An empty block with no signature is still removed, so the LIT-6357 400 does not come back

#46342

Before: a developer who pins thinking blocks to their conversation still gets a 200 when they replay a block from another conversation

  1. They send POST https://litellm-domain/v1/messages with header anthropic-beta: thinking-binding-controls-2026-08-01
  2. The body has "thinking": {"type": "adaptive", "block_binding": {"prefix_mismatch_behavior": "error"}} and an assistant turn holding a thinking block from an unrelated conversation
  3. Anthropic rejects the block, but the gateway strips every thinking block, retries and returns 200 Tokyo.
  4. On a Bedrock Invoke model the gateway drops block_binding before calling Bedrock, so the same replay is a 200 on /v1/messages and /v1/chat/completions too

After: the same replay gets the 400 the developer asked for

  1. They send POST https://litellm-domain/v1/messages with header anthropic-beta: thinking-binding-controls-2026-08-01
  2. The body has "thinking": {"type": "adaptive", "block_binding": {"prefix_mismatch_behavior": "error"}} and an assistant turn holding a thinking block from an unrelated conversation
  3. They get 400 Invalid signature in thinking block. The block is bound to a different conversation. after one upstream call
  4. On a Bedrock Invoke model block_binding reaches Bedrock, and the replay gets Bedrock's same 400 on /v1/messages and /v1/chat/completions

The same pinned request whose bad block is unrelated to binding (for example a null signature) still self-heals to a 200, and a chat completions replay of a signed thinking block with empty text now forwards that block to Anthropic instead of dropping it

#47067

Before: a team member can create a batch on their team's model but cannot check on it, cancel it, or download its results

  1. A team admin adds team model team-batch-model on https://litellm-domain/ui/?page=models
  2. A team member sends POST https://litellm-domain/v1/files (purpose=batch, target_model_names=team-batch-model), then POST https://litellm-domain/v1/batches, and gets a batch id
  3. They send GET https://litellm-domain/v1/batches/{batch_id} with the same team key or custom auth token
  4. It returns 403 team_model_access_denied naming model_name_<team id>_<uuid>, and POST .../cancel fails the same way
  5. Even with the output_file_id from an admin, GET https://litellm-domain/v1/files/{output_file_id}/content returns 403
  6. Another team's key also gets 403 on the batch

After: the same team member checks, cancels, and downloads the results with the key that created the batch

  1. A team admin adds team model team-batch-model on https://litellm-domain/ui/?page=models
  2. A team member sends POST https://litellm-domain/v1/files (purpose=batch, target_model_names=team-batch-model), then POST https://litellm-domain/v1/batches, and gets a batch id
  3. They send GET https://litellm-domain/v1/batches/{batch_id} with the same team key or custom auth token
  4. It returns 200 and moves to completed with an output_file_id, and POST .../cancel returns 200 with status cancelling
  5. GET https://litellm-domain/v1/files/{output_file_id}/content returns 200 with the JSONL results
  6. Another team's key still gets 403, even when that team also has a team-batch-model

#47389

Before, counting a PDF and tool request drops most input tokens

  1. Send POST https://litellm-domain/v1/messages/count_tokens with a PDF, system prompt and tool
  2. Observe input_tokens of 152
  3. Send the same body to POST https://litellm-domain/v1/messages and observe usage.input_tokens of 990

After, the same count matches inference

  1. Send POST https://litellm-domain/v1/messages/count_tokens with the same body
  2. Observe input_tokens of 990 and litellm_count_source of provider
  3. Send the same body to POST https://litellm-domain/v1/messages and observe usage.input_tokens of 990

#47446

Before: a developer receives 400 for a compatible Google countTokens request

  1. Send POST /v1beta/models/gemini-3.8-flash:countTokens with a single text system part or tools: null
  2. Receive HTTP 400 with Invalid Google countTokens request body

After: the same developer receives a provider token count

  1. Send POST /v1beta/models/gemini-3.8-flash:countTokens with a single text system part or tools: null
  2. Receive HTTP 200 with totalTokens and litellm_count_source: provider

#47454

Before, adding a prompt to a conversation rejects the count

  1. POST http://localhost:4568/utils/token_counter?call_endpoint=false with messages and drop_params disabled on the deployment
  2. Observe a successful token count
  3. Add a nonempty prompt and repeat the request
  4. Observe HTTP 400 requiring drop_params

After, adding a prompt preserves the conversation count

  1. POST http://localhost:4568/utils/token_counter?call_endpoint=false with messages and drop_params disabled on the deployment
  2. Observe a successful token count
  3. Add a nonempty prompt and repeat the request
  4. Observe HTTP 200 with the same conversation count

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • Every automated review on my PR's latest commit has finished, and I have addressed or replied to each of its findings before requesting a maintainer review

Type

🐛 Bug Fix

Caveats (if any)

Low

  • No live-proxy proof, and CI does not run on stable PRs
  • 60 cost map test failures were already red on the line tip
  • /v1/messages/count_tokens 400s now use Anthropic's error body shape
  • Two cost-less Databricks entries now price at $0 instead of unmapped
  • Signed empty thinking blocks are now replayed upstream, not checked live
  • The streamed alias stamp in logging is pinned by an integration test only, not run here

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

yuneng-berri and others added 11 commits October 19, 2026 22:25
…dget (#44277)

* fix(proxy): stop queued registry read-throughs spending the resync budget

RegistryReadThrough.attempt serializes misses behind one lock, but every
request that was queued behind the first one still spent a unit of the
20-per-5s resync budget and re-ran the DB resync, even though the first
request had already loaded the object. A burst of more than 20 requests
for a model created on another worker therefore exhausted the budget and
the rest got 400 "Invalid model name".

attempt now checks whether the key is already loaded once it holds the
lock and returns early without touching the budget. Models check the
router's model names and deployment ids, guardrails and agents reuse
their existing registry lookups.

* test(proxy): gate the queued read-through test on events and cover each registry's loaded check

The queued-requests test now holds the first resync on an asyncio.Event instead of
a timed sleep and records calls in a recorder with tuple and frozenset state. New
tests show the model, guardrail and agent read-throughs each answer an object that
is already loaded without reading the database, so rewiring any registry's loaded
check now fails a test

* test(proxy): keep the queued read-through recorder inside its test and type the agent registry fixture

(cherry picked from commit b877a38)
…o pricing sees the deployment model (#44341)

* fix(proxy): stamp the client alias on a copy of each streamed chunk so pricing sees the deployment model

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test(spend): streamed alias matching a capability rule bills the deployment price

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test(spend): assert every streamed chunk carries the client alias

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(logging): log the client alias on the priced streamed response, the same as non-streamed

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: kerry <kerry@berri.ai>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
(cherry picked from commit 7b432d7)
…text (#44346)

* revert(responses): revert "fix(responses): keep gpt-5.4/5.5 tool calls on chat and merge bridged tool calls into one choice" (#44295)

This reverts commit ca1994e.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(responses): merge bridged tool calls into the same choice as the text

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: kerry <kerry@berri.ai>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
(cherry picked from commit 5724117)
…46099)

* fix(responses): fold bridged Responses output into one chat choice

A Chat Completions request bridged to /responses got one choice per
Responses message item, so a reply shaped [message, message,
function_call] put the tool call on choices[1] and clients reading
only choices[0] never saw it. Fold every message text, annotation,
reasoning item and tool call into choices[0]

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(responses): drop mutable annotations and the extra cast in the choice fold

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(responses): remove a cast-ok marker that suppressed nothing

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(responses): join folded message texts with a newline

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* revert(responses): join folded message texts with no separator so stream and non-stream match

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
(cherry picked from commit 4b7b8ef)
…uests (#41362)

The request-side sanitizer on /v1/messages dropped every thinking block whose
text is empty, even with a valid signature. Claude Opus 4.8 / Fable 5 / Fable 5.1
return exactly that shape by default (thinking.display omitted): the signature
is the preserved reasoning. Replaying the assistant turn as returned therefore
lost the model's reasoning on every multi-turn request, silently (the provider
answers 200 without it), and left preserved-thinking enforcement
(thinking.block_binding) nothing to bind.

Anthropic accepts an empty thinking block that carries a signature and binds it
to its prefix; only an empty block with no signature (the LIT-6357 case, a turn
a non-Anthropic model served through the bridge) is rejected with "each
thinking block must contain thinking". Use the signature-aware predicate
is_empty_unsigned_thinking_block, which #38809 already applied on the emit
side, for the request side too. The unsigned case is still dropped.

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
(cherry picked from commit 897bfea)
…block_binding (#46342)

* fix(anthropic): treat adaptive thinking as enabled when mapping response_format

is_thinking_enabled only recognised thinking.type=enabled, so a request that
paired thinking.type=adaptive with response_format took the synthetic JSON
tool path with a forced tool_choice, which Anthropic rejects alongside
thinking. The same check also gates the Bedrock Converse and Databricks
forced tool_choice downgrades, so they now see adaptive thinking too.

* fix(anthropic): keep signed thinking blocks with empty text on chat completions

Models that default to display: omitted return signed thinking blocks whose
text is empty, and Anthropic rejects the next turn when they are not replayed
unchanged. is_unsignable_thinking_block dropped them along with unsigned
blocks, and the inline content path required non-empty text, so a tool-use
turn on Opus 4.7+ or the 5 families lost its thinking blocks and 400ed on the
tool-result turn. Only a missing signature now drops a block, and the
mid-conversation system placement mirrors that rule. The /v1/messages strip
helper is left to #41362.

* fix(anthropic): skip the thinking-strip retry when block_binding asks for an error

The /v1/messages retry loop strips thinking blocks and resends on any
invalid-thinking 400, including the binding mismatch a caller opted into
with thinking.block_binding.prefix_mismatch_behavior: error. The retry
decision now sees the request body and surfaces that 400 instead of
overriding the caller's choice. #42888 covers the litellm_params side.

* fix(bedrock): carry thinking.block_binding through the Invoke thinking rebuilds

Bedrock Invoke rebuilt the thinking param from scratch when display: updates
was requested, on both the /v1/messages and chat completions paths, and the
legacy enabled-to-adaptive translation plus the clear_thinking injection did
the same, so thinking.block_binding never reached Bedrock. Every rebuild now
spreads the caller's thinking and only overrides the keys it owns, and
AnthropicThinkingParam types block_binding. The thinking-binding-controls
beta was already on the Bedrock allowlist.

* fix(anthropic): keep forcing the response_format tool under adaptive thinking

This reverts ad9e861. Anthropic, Bedrock Invoke and Vertex all accept a
forced tool_choice next to thinking.type=adaptive and only reject it with
type=enabled, so counting adaptive as enabled fixed no live failure. It did
drop the forced JSON tool, so Claude answered response_format requests in
prose, and it downgraded a required tool_choice to auto on Bedrock Converse

* test(e2e): drop the adaptive thinking tool round trip case

With adaptive thinking the model often skips thinking on the weather prompt, so
turn 1 carries no signed empty block and the case fails before the replay it is
meant to cover. Anthropic also answers the replay with a 200 whether or not the
block is forwarded, so the case could not tell the fix from main. The factory
unit tests pin the outgoing shape instead

* fix(anthropic): only skip the thinking-strip retry for a binding mismatch 400

prefix_mismatch_behavior: error asks Anthropic to reject a block bound to
another conversation. It says nothing about unrelated bad blocks such as a
null signature, so those still get the strip-and-retry self-heal. Also trims
the empty-thinking docstrings to what the code guarantees and types the new
test parameters

* refactor(anthropic): narrow thinking fields with the mapping validator instead of typing.cast

typing.cast is banned by the strict ruff gate (TID251), so the three new casts pushed that rule one over its merge-base count. The existing pydantic mapping validator gives the same typed view without an unchecked cast, and it now has a generic name since it is no longer only used for Claude Code payloads

* refactor(anthropic): read thinking settings through the validated mapping so basedpyright stays at its merge-base count

The Bedrock clear_thinking rewrite still narrowed with a cast and an untyped dict fallback, which added two reportUnknownVariableType errors. It now uses the same pydantic mapping validator, made public for that reuse, and the retry hook validates the request body itself so the handler passes a typed dict instead of an untyped one

---------

Co-authored-by: yuneng-jiang <yuneng@berri.ai>
(cherry picked from commit f470e41)
… retrieve/cancel (#47067)

* fix(proxy): authorize the public name of a team-scoped model on batch retrieve/cancel

A unified batch id resolves to the deployment's internal model_name
(model_name_{team_id}_{uuid}), which is in no key or team allowlist, so
authorize_model_for_key always denied and team keys got 403 retrieving or
cancelling their own batches. Authorize against model_info
team_public_model_name when the resolved deployment is team-scoped, falling
back to the resolved name otherwise.

Fixes #46958

* fix(proxy): authorize team-scoped batch models by their public name on both auth paths

* fix(proxy): accept the owning team's public name for its own team deployment on every auth path

Managed batch, file, fine-tuning, vector store, character and video ids resolve to the
team deployment's internal name again, so teams that granted the internal name keep access.
The model access check now also accepts the owning team's public name and its legacy team
aliases for that internal name, and only when the caller's team owns the deployment.

* fix(proxy): match a team deployment's public and alias names against the caller's own grants

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
(cherry picked from commit e979bd0)
…stable_1_104_x

fix(count_tokens): backport October 19 fixes to stable/1.104.x

(cherry picked from commit 5e4d160)
…shapes_stable_1_104_x

fix(count_tokens): restore Google request compatibility on stable/1.104.x

(cherry picked from commit a63df16)
…put_precedence

fix(proxy): restore legacy token count input precedence

(cherry picked from commit 5346a40)
litellm 1.105.1 already shipped, so the next release off this line is 1.105.2
@yuneng-berri

Copy link
Copy Markdown
Contributor Author

@litellm-stampbot please review this nightly backport to stable/1.105.x, every pick and its gate result is in the description

@kerry-berri

kerry-berri commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

litellm-stampbot: risk high

Not approved at 60876f2. risk is high, a human reviewer is needed.

Rules (stampbot/risk_rules.yml):

  • high: 2857 changed source lines is over the 500 line cap (tests, docs, cookbook and markdown are not counted)

Judge: skipped, the rules alone decided.

Pushes do not re-run this check. Comment @litellm-stampbot again to re-check the new head.

@kerry-berri kerry-berri added the risk:high Sensitive, broad, or high-risk change label Oct 20, 2026
@yuneng-berri
yuneng-berri marked this pull request as draft October 20, 2026 09:12
…pic, Azure AI and Bedrock Invoke configs

The #46342 backport carried block_binding through every subclass of the
Anthropic and Bedrock Invoke configs, so Bedrock Mantle, Claude Platform and
OpenAI-compatible Anthropic endpoints started sending it. Each of the six chat
and messages configs now opts in by exact class, and the Bedrock Invoke
display updates and clear_thinking rebuilds carry block_binding only when the
config opts in. Every other config sends the same thinking as 1.105.1
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
6 out of 7 committers have signed the CLA.

✅ clonylu
✅ yuneng-berri
✅ ryan-crabbe-berri
✅ Mrun25
✅ joshua-berri
✅ mateo-berri
❌ devin-ai-integration[bot]
You have signed the CLA already but the status is still pending? Let us recheck it.

@yuneng-berri
yuneng-berri marked this pull request as ready for review October 20, 2026 16:08
@yuneng-berri
yuneng-berri merged commit fc43640 into stable/1.105.x Oct 20, 2026
8 of 9 checks passed
@yuneng-berri
yuneng-berri deleted the patch_27570705 branch October 20, 2026 16:10

This branch was successfully deployed

No deployments
e2e-changed — 9a4884cd Deployed Oct 20, 2026 by yuneng-berri via oauth #5975
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:high Sensitive, broad, or high-risk change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants