Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(llm-gateway): serve claude sonnet 5.5 (#108405)

Brandon86edcdbbdbed
diff --git a/services/llm-gateway/src/llm_gateway/anthropic_request.py b/services/llm-gateway/src/llm_gateway/anthropic_request.py
index 059c64a82ece..dbcae7a22c2a 100644
--- a/services/llm-gateway/src/llm_gateway/anthropic_request.py
+++ b/services/llm-gateway/src/llm_gateway/anthropic_request.py
@@ -12,9 +12,18 @@ CLEAR_THINKING_EDIT: Final[str] = "clear_thinking_20251015"
OPUS_5_REQUIRED_THINKING_EFFORTS: Final[frozenset[str]] = frozenset({"xhigh", "max"})
# Rejects `thinking: {"type": "disabled"}` at every effort level, not only the top two.
ALWAYS_THINKING_MODELS: Final[frozenset[str]] = frozenset({"claude-opus-5-5"})
+# Also rejects disabled thinking; `between_tools`, its thinking-off shape, is legal only at effort
+# high or below and without a per-message output_config.
+BETWEEN_TOOLS_MODELS: Final[frozenset[str]] = frozenset({"claude-sonnet-5-5"})
+BETWEEN_TOOLS_EFFORTS: Final[frozenset[object]] = frozenset({None, "", "low", "medium", "high"})
-def enable_required_opus_5_thinking(request_data: dict[str, Any]) -> dict[str, Any]:
+def _has_message_output_config(messages: object) -> bool:
+ return isinstance(messages, list) and any(isinstance(m, dict) and "output_config" in m for m in messages)
+
+
+def normalize_disabled_thinking(request_data: dict[str, Any]) -> dict[str, Any]:
+ """Rewrite `thinking: disabled` for models that refuse it."""
output_config = request_data.get("output_config")
effort = output_config.get("effort") if isinstance(output_config, dict) else None
thinking = request_data.get("thinking")
@@ -22,6 +31,10 @@ def enable_required_opus_5_thinking(request_data: dict[str, Any]) -> dict[str, A
if not isinstance(thinking, dict) or thinking.get("type") != "disabled":
return request_data
+ if model in BETWEEN_TOOLS_MODELS:
+ if effort in BETWEEN_TOOLS_EFFORTS and not _has_message_output_config(request_data.get("messages")):
+ return {**request_data, "thinking": {"type": "between_tools"}}
+ return {**request_data, "thinking": {"type": "adaptive"}}
if model not in ALWAYS_THINKING_MODELS and (
model != "claude-opus-5" or effort not in OPUS_5_REQUIRED_THINKING_EFFORTS
):
diff --git a/services/llm-gateway/src/llm_gateway/api/anthropic.py b/services/llm-gateway/src/llm_gateway/api/anthropic.py
index 146ea70b241e..b995d6aa82ea 100644
--- a/services/llm-gateway/src/llm_gateway/api/anthropic.py
+++ b/services/llm-gateway/src/llm_gateway/api/anthropic.py
@@ -11,7 +11,7 @@ from botocore.exceptions import ClientError
from fastapi import APIRouter, HTTPException, Request
from fastapi.responses import StreamingResponse
-from llm_gateway.anthropic_request import drop_orphaned_clear_thinking, enable_required_opus_5_thinking
+from llm_gateway.anthropic_request import drop_orphaned_clear_thinking, normalize_disabled_thinking
from llm_gateway.api.handler import (
ANTHROPIC_CONFIG,
BEDROCK_CONFIG,
@@ -530,7 +530,7 @@ async def _handle_anthropic_messages(
product: str = "llm_gateway",
) -> dict[str, Any] | StreamingResponse:
data = body.model_dump(exclude_none=True, exclude=GATEWAY_ONLY_FIELDS)
- data = enable_required_opus_5_thinking(data)
+ data = normalize_disabled_thinking(data)
provider = _get_provider_from_headers(request)
use_bedrock_fallback = _get_use_bedrock_fallback_from_headers(request)
@@ -626,7 +626,9 @@ async def _handle_count_tokens(
breaker: AnthropicCircuitBreaker | None,
product: str = "llm_gateway",
) -> dict[str, Any]:
- data = _sanitize_request_data(body.model_dump(exclude_none=True, exclude=GATEWAY_ONLY_FIELDS))
+ data = normalize_disabled_thinking(
+ _sanitize_request_data(body.model_dump(exclude_none=True, exclude=GATEWAY_ONLY_FIELDS))
+ )
provider = _get_provider_from_headers(request)
use_bedrock_fallback = _get_use_bedrock_fallback_from_headers(request)
diff --git a/services/llm-gateway/src/llm_gateway/bedrock.py b/services/llm-gateway/src/llm_gateway/bedrock.py
index 01cee8fd01a5..ef3cd07ded36 100644
--- a/services/llm-gateway/src/llm_gateway/bedrock.py
+++ b/services/llm-gateway/src/llm_gateway/bedrock.py
@@ -98,6 +98,11 @@ ANTHROPIC_TO_BEDROCK_MODEL_MAP: Final[dict[str, dict[str, str]]] = {
"us": "us.anthropic.claude-sonnet-5",
"eu": "eu.anthropic.claude-sonnet-5",
},
+ # Bedrock offers Sonnet 5.5 only through the global profile.
+ "claude-sonnet-5-5": {
+ "us": "global.anthropic.claude-sonnet-5-5",
+ "eu": "global.anthropic.claude-sonnet-5-5",
+ },
"claude-haiku-4-5": {
"us": "us.anthropic.claude-haiku-4-5-20251001-v1:0",
"eu": "eu.anthropic.claude-haiku-4-5-20251001-v1:0",
diff --git a/services/llm-gateway/src/llm_gateway/products/config.py b/services/llm-gateway/src/llm_gateway/products/config.py
index 1ad1eae74ed0..87142864074d 100644
--- a/services/llm-gateway/src/llm_gateway/products/config.py
+++ b/services/llm-gateway/src/llm_gateway/products/config.py
@@ -93,6 +93,7 @@ _POSTHOG_CODE_AGENT_MODELS: Final[frozenset[str]] = frozenset(
"claude-sonnet-4-5",
"claude-sonnet-4-6",
"claude-sonnet-5",
+ "claude-sonnet-5-5",
"claude-haiku-4-5",
"gpt-5.6-sol",
"gpt-5.6-terra",
@@ -165,6 +166,7 @@ PRODUCTS: Final[dict[str, ProductConfig]] = {
"claude-opus-5-5",
"claude-sonnet-4-5",
"claude-sonnet-5",
+ "claude-sonnet-5-5",
"claude-haiku-4-5",
"gpt-5.4",
"gpt-5.3-codex",
diff --git a/services/llm-gateway/src/llm_gateway/rate_limiting/model_cost_overrides.py b/services/llm-gateway/src/llm_gateway/rate_limiting/model_cost_overrides.py
index 8004e1db9b5c..f59009b8b844 100644
--- a/services/llm-gateway/src/llm_gateway/rate_limiting/model_cost_overrides.py
+++ b/services/llm-gateway/src/llm_gateway/rate_limiting/model_cost_overrides.py
@@ -65,6 +65,25 @@ BASETEN_DEEPSEEK_COST: Final[ModelCost] = {
"supports_prompt_caching": True,
}
+# litellm picks a Claude model's thinking and effort handling from these flags; a bridge row without
+# them loses adaptive thinking, between_tools and output_config.effort. Mirrors litellm's claude-sonnet-5.
+CLAUDE_5_CAPABILITIES: Final[ModelCost] = {
+ "supports_vision": True,
+ "supports_prompt_caching": True,
+ "supports_adaptive_thinking": True,
+ "supports_reasoning": True,
+ "supports_xhigh_reasoning_effort": True,
+ "supports_max_reasoning_effort": True,
+ "supports_output_config": True,
+ "supports_sampling_params": False,
+ "supports_assistant_prefill": False,
+ "supports_function_calling": True,
+ "supports_tool_choice": True,
+ "supports_response_schema": True,
+ "supports_pdf_input": True,
+ "supports_computer_use": True,
+}
+
MODEL_COST_OVERRIDES: Final[dict[str, ModelCost]] = {
BASETEN_METRIC_MODEL: cast("ModelCost", dict(BASETEN_GLM_COST)),
BASETEN_DEEPSEEK_METRIC_MODEL: cast("ModelCost", dict(BASETEN_DEEPSEEK_COST)),
@@ -72,6 +91,7 @@ MODEL_COST_OVERRIDES: Final[dict[str, ModelCost]] = {
BASETEN_GLM53_FLASH_METRIC_MODEL: cast("ModelCost", dict(BASETEN_GLM53_FLASH_COST)),
"moonshotai/kimi-k3": cast("ModelCost", dict(KIMI_K3_COST)),
"claude-fable-5": {
+ **CLAUDE_5_CAPABILITIES,
"litellm_provider": "anthropic",
"mode": "chat",
# 200k not 1M: the 1M window is a beta-header feature, same as opus-4.x.
@@ -81,10 +101,9 @@ MODEL_COST_OVERRIDES: Final[dict[str, ModelCost]] = {
"output_cost_per_token": 5e-05,
"cache_read_input_token_cost": 1e-06,
"cache_creation_input_token_cost": 1.25e-05,
- "supports_vision": True,
- "supports_prompt_caching": True,
},
"claude-fable-5-1": {
+ **CLAUDE_5_CAPABILITIES,
"litellm_provider": "anthropic",
"mode": "chat",
# 200k not 1M: the 1M window is a beta-header feature, same as opus-4.x.
@@ -94,10 +113,9 @@ MODEL_COST_OVERRIDES: Final[dict[str, ModelCost]] = {
"output_cost_per_token": 5e-05,
"cache_read_input_token_cost": 1e-06,
"cache_creation_input_token_cost": 1.25e-05,
- "supports_vision": True,
- "supports_prompt_caching": True,
},
"claude-opus-5-5": {
+ **CLAUDE_5_CAPABILITIES,
"litellm_provider": "anthropic",
"mode": "chat",
# 200k not 1M: the 1M window is a beta-header feature, same as opus-4.x.
@@ -107,8 +125,17 @@ MODEL_COST_OVERRIDES: Final[dict[str, ModelCost]] = {
"output_cost_per_token": 2e-05,
"cache_read_input_token_cost": 2e-07,
"cache_creation_input_token_cost": 5e-06,
- "supports_vision": True,
- "supports_prompt_caching": True,
+ },
+ "claude-sonnet-5-5": {
+ **CLAUDE_5_CAPABILITIES,
+ "litellm_provider": "anthropic",
+ "mode": "chat",
+ "max_input_tokens": 1_000_000,
+ "max_output_tokens": 128_000,
+ "input_cost_per_token": 2e-06,
+ "output_cost_per_token": 1e-05,
+ "cache_read_input_token_cost": 2e-07,
+ "cache_creation_input_token_cost": 2.5e-06,
},
"gpt-5.6-sol": {
"litellm_provider": "openai",
diff --git a/services/llm-gateway/src/llm_gateway/rate_limiting/model_cost_service.py b/services/llm-gateway/src/llm_gateway/rate_limiting/model_cost_service.py
index 43664a11bba6..722071b5df0a 100644
--- a/services/llm-gateway/src/llm_gateway/rate_limiting/model_cost_service.py
+++ b/services/llm-gateway/src/llm_gateway/rate_limiting/model_cost_service.py
@@ -54,6 +54,18 @@ class ModelCost(TypedDict, total=False):
"""Cost in USD per input token written to the cache."""
supports_prompt_caching: bool
"""Whether the model supports prompt caching."""
+ supports_adaptive_thinking: bool
+ supports_reasoning: bool
+ supports_xhigh_reasoning_effort: bool
+ supports_max_reasoning_effort: bool
+ supports_output_config: bool
+ supports_sampling_params: bool
+ supports_assistant_prefill: bool
+ supports_function_calling: bool
+ supports_tool_choice: bool
+ supports_response_schema: bool
+ supports_pdf_input: bool
+ supports_computer_use: bool
class ModelCostService:
diff --git a/services/llm-gateway/tests/test_anthropic.py b/services/llm-gateway/tests/test_anthropic.py
index c7ba75124950..77f843edbf5f 100644
--- a/services/llm-gateway/tests/test_anthropic.py
+++ b/services/llm-gateway/tests/test_anthropic.py
@@ -477,6 +477,31 @@ class TestAnthropicMessagesEndpoint:
assert response.status_code == 200
assert mock_anthropic.call_args.kwargs["thinking"] == {"type": "adaptive"}
+ @patch("llm_gateway.api.anthropic.litellm.anthropic_messages")
+ def test_sonnet_5_5_disabled_thinking_becomes_between_tools(
+ self,
+ mock_anthropic: MagicMock,
+ authenticated_client: TestClient,
+ provider_request_headers: dict[str, str],
+ provider_mock_response: dict,
+ ) -> None:
+ mock_response = MagicMock()
+ mock_response.model_dump = MagicMock(return_value=provider_mock_response)
+ mock_anthropic.return_value = mock_response
+
+ response = authenticated_client.post(
+ "/ci/v1/messages",
+ json={
+ "model": "claude-sonnet-5-5",
+ "messages": [{"role": "user", "content": "Hello"}],
+ "thinking": {"type": "disabled"},
+ },
+ headers=provider_request_headers,
+ )
+
+ assert response.status_code == 200
+ assert mock_anthropic.call_args.kwargs["thinking"] == {"type": "between_tools"}
+
@patch("llm_gateway.api.anthropic.litellm.anthropic_messages")
def test_retired_wizard_route_answers_the_upgrade_path(
self,
@@ -1210,6 +1235,39 @@ class TestAnthropicCountTokensEndpoint:
assert call_kwargs[0][0] == "https://api.anthropic.com/v1/messages/count_tokens"
assert call_kwargs[1]["headers"]["x-api-key"] == "test-anthropic-key"
+ @patch("llm_gateway.api.anthropic.get_settings")
+ @patch("llm_gateway.api.anthropic.httpx.AsyncClient")
+ def test_sonnet_5_5_disabled_thinking_counts_as_between_tools(
+ self,
+ mock_httpx_client_cls: MagicMock,
+ mock_get_settings: MagicMock,
+ authenticated_client: TestClient,
+ mock_count_tokens_response: httpx.Response,
+ ) -> None:
+ mock_settings = MagicMock()
+ mock_settings.anthropic_api_key = "test-anthropic-key"
+ mock_settings.request_timeout = 300.0
+ mock_get_settings.return_value = mock_settings
+
+ mock_client = MagicMock()
+ mock_client.__aenter__ = AsyncMock(return_value=mock_client)
+ mock_client.__aexit__ = AsyncMock(return_value=None)
+ mock_client.post = AsyncMock(return_value=mock_count_tokens_response)
+ mock_httpx_client_cls.return_value = mock_client
+
+ response = authenticated_client.post(
+ "/v1/messages/count_tokens",
+ json={
+ "model": "claude-sonnet-5-5",
+ "messages": [{"role": "user", "content": "Hello"}],
+ "thinking": {"type": "disabled"},
+ },
+ headers={"Authorization": "Bearer phx_test_key"},
+ )
+
+ assert response.status_code == 200
+ assert mock_client.post.call_args[1]["json"]["thinking"] == {"type": "between_tools"}
+
@patch("llm_gateway.api.anthropic.get_settings")
@patch("llm_gateway.api.anthropic.httpx.AsyncClient")
def test_extra_fields_not_forwarded(
diff --git a/services/llm-gateway/tests/test_anthropic_request.py b/services/llm-gateway/tests/test_anthropic_request.py
index 1bc72bdfd118..fd90b56057e9 100644
--- a/services/llm-gateway/tests/test_anthropic_request.py
+++ b/services/llm-gateway/tests/test_anthropic_request.py
@@ -5,7 +5,7 @@ import pytest
from llm_gateway.anthropic_request import (
convert_enabled_thinking_to_adaptive,
drop_orphaned_clear_thinking,
- enable_required_opus_5_thinking,
+ normalize_disabled_thinking,
)
from llm_gateway.metrics.prometheus import CLEAR_THINKING_EDIT_DROPPED
@@ -23,24 +23,59 @@ def test_opus_5_high_effort_enables_adaptive_thinking(effort: str) -> None:
"thinking": {"type": "disabled"},
}
- normalized = enable_required_opus_5_thinking(request)
+ normalized = normalize_disabled_thinking(request)
assert normalized["thinking"] == {"type": "adaptive"}
assert request["thinking"] == {"type": "disabled"}
[email protected]("effort", [None, "low", "medium", "high"])
+def test_sonnet_5_5_disabled_becomes_between_tools(effort: str | None) -> None:
+ request: dict = {"model": "claude-sonnet-5-5", "thinking": {"type": "disabled", "display": "summarized"}}
+ if effort is not None:
+ request["output_config"] = {"effort": effort}
+
+ normalized = normalize_disabled_thinking(request)
+
+ # between_tools takes no other field, so display must not carry over.
+ assert normalized["thinking"] == {"type": "between_tools"}
+ assert request["thinking"] == {"type": "disabled", "display": "summarized"}
+
+
+ ("effort", "messages"),
+ [
+ pytest.param("xhigh", [], id="xhigh"),
+ pytest.param("max", [], id="max"),
+ pytest.param("low", [{"role": "system", "content": [], "output_config": {"effort": "low"}}], id="per_message"),
+ ],
+)
+def test_sonnet_5_5_disabled_becomes_adaptive_where_between_tools_is_refused(effort: str, messages: list) -> None:
+ request = {
+ "model": "claude-sonnet-5-5",
+ "messages": messages,
+ "output_config": {"effort": effort},
+ "thinking": {"type": "disabled"},
+ }
+
+ assert normalize_disabled_thinking(request)["thinking"] == {"type": "adaptive"}
+
+
@pytest.mark.parametrize(
("model", "effort", "thinking"),
[
pytest.param("claude-opus-5", "high", {"type": "disabled"}, id="lower_effort"),
pytest.param("claude-opus-4-8", "xhigh", {"type": "disabled"}, id="other_model"),
pytest.param("claude-opus-5", "xhigh", {"type": "adaptive"}, id="already_adaptive"),
+ pytest.param("claude-sonnet-5", "low", {"type": "disabled"}, id="sonnet_5_accepts_disabled"),
+ pytest.param("claude-sonnet-5-5", "low", {"type": "between_tools"}, id="already_between_tools"),
+ pytest.param("claude-sonnet-5-5", "low", {"type": "adaptive"}, id="sonnet_5_5_adaptive"),
],
)
def test_other_thinking_configurations_are_untouched(model: str, effort: str, thinking: dict[str, str]) -> None:
request = {"model": model, "output_config": {"effort": effort}, "thinking": thinking}
- assert enable_required_opus_5_thinking(request) is request
+ assert normalize_disabled_thinking(request) is request
@pytest.mark.parametrize(
diff --git a/services/llm-gateway/tests/test_bedrock.py b/services/llm-gateway/tests/test_bedrock.py
index f351daf7c5fa..936a33b03709 100644
--- a/services/llm-gateway/tests/test_bedrock.py
+++ b/services/llm-gateway/tests/test_bedrock.py
@@ -125,6 +125,9 @@ class TestBedrockSpecific:
pytest.param("claude-fable-5", "bedrock/us.anthropic.claude-fable-5", id="fable_5_inference_profile"),
pytest.param("claude-fable-5-1", "bedrock/us.anthropic.claude-fable-5-1", id="fable_5_1_inference_profile"),
pytest.param("claude-sonnet-5", "bedrock/us.anthropic.claude-sonnet-5", id="sonnet_5_inference_profile"),
+ pytest.param(
+ "claude-sonnet-5-5", "bedrock/global.anthropic.claude-sonnet-5-5", id="sonnet_5_5_inference_profile"
+ ),
pytest.param("claude-opus-5", "bedrock/us.anthropic.claude-opus-5", id="opus_5_inference_profile"),
pytest.param(
"us.anthropic.claude-sonnet-4-6", "bedrock/us.anthropic.claude-sonnet-4-6", id="already_bedrock_id"
@@ -871,6 +874,7 @@ class TestModelMapping:
pytest.param("claude-sonnet-4-5", "us.anthropic.claude-sonnet-4-5-20250929-v1:0", id="sonnet_4_5"),
pytest.param("claude-sonnet-4-6", "us.anthropic.claude-sonnet-4-6", id="sonnet_4_6"),
pytest.param("claude-sonnet-5", "us.anthropic.claude-sonnet-5", id="sonnet_5"),
+ pytest.param("claude-sonnet-5-5", "global.anthropic.claude-sonnet-5-5", id="sonnet_5_5"),
pytest.param("claude-opus-5", "us.anthropic.claude-opus-5", id="opus_5"),
pytest.param("claude-haiku-4-5", "us.anthropic.claude-haiku-4-5-20251001-v1:0", id="haiku_4_5"),
],
@@ -890,6 +894,7 @@ class TestModelMapping:
[
pytest.param("claude-opus-4-6", "eu.anthropic.claude-opus-4-6-v1", id="opus_4_6"),
pytest.param("claude-fable-5", "global.anthropic.claude-fable-5", id="fable_5"),
+ pytest.param("claude-sonnet-5-5", "global.anthropic.claude-sonnet-5-5", id="sonnet_5_5"),
],
)
def test_maps_to_available_profile_for_eu_regions(self, anthropic_model: str, expected_bedrock_model: str) -> None:
diff --git a/services/llm-gateway/tests/test_model_cost_overrides.py b/services/llm-gateway/tests/test_model_cost_overrides.py
index 0ccd34f542b8..81a3ae82ce3b 100644
--- a/services/llm-gateway/tests/test_model_cost_overrides.py
+++ b/services/llm-gateway/tests/test_model_cost_overrides.py
@@ -1,12 +1,16 @@
from __future__ import annotations
+import copy
import os
from collections.abc import Iterator
from unittest.mock import MagicMock, patch
import litellm
import pytest
+from litellm.llms.anthropic.experimental_pass_through.messages.transformation import AnthropicMessagesConfig
+from litellm.types.router import GenericLiteLLMParams
+from llm_gateway.rate_limiting.cost_refresh import set_litellm_model_cost
from llm_gateway.rate_limiting.model_cost_overrides import (
MODEL_COST_OVERRIDES,
PINNED_MODEL_COST_OVERRIDES,
@@ -112,6 +116,8 @@ class TestOverrideSurfacesThroughRefresh:
[
("claude-fable-5", "anthropic", 200_000),
("claude-fable-5-1", "anthropic", 200_000),
+ ("claude-opus-5-5", "anthropic", 200_000),
+ ("claude-sonnet-5-5", "anthropic", 1_000_000),
("gpt-6.1-sol", "openai", 1_050_000),
],
)
@@ -166,3 +172,70 @@ class TestOverrideSurfacesThroughRefresh:
assert "claude-fable-5" in model_ids
assert "claude-fable-5-1" in model_ids
assert "gpt-6.1-sol" in model_ids
+
+ @pytest.mark.parametrize("product", ["posthog_code", "background_agents", "slack_app", "workflows"])
+ @patch("llm_gateway.rate_limiting.model_cost_service.get_model_cost_map")
+ def test_sonnet_5_5_listed_for_agent_products(self, mock_get_cost_map: MagicMock, product: str) -> None:
+ mock_get_cost_map.return_value = {
+ "claude-opus-4-8": {
+ "litellm_provider": "anthropic",
+ "mode": "chat",
+ "max_input_tokens": 200_000,
+ },
+ }
+ ModelCostService.get_instance()._refresh_cache()
+
+ settings = MagicMock()
+ settings.openai_api_key = None
+ settings.anthropic_api_key = "sk-ant-test"
+ settings.openrouter_api_key = None
+ settings.fireworks_api_key = None
+
+ with patch.dict(os.environ, {}, clear=False):
+ for var in PROVIDER_ENV_VARS:
+ os.environ.pop(var, None)
+ with patch(
+ "llm_gateway.services.model_registry.get_settings",
+ return_value=settings,
+ ):
+ model_ids = {m.id for m in get_available_models(product)}
+
+ assert "claude-sonnet-5-5" in model_ids
+
+
+CLAUDE_BRIDGE_MODELS = ["claude-fable-5", "claude-fable-5-1", "claude-opus-5-5", "claude-sonnet-5-5"]
+
+
+def bridged_litellm_cost_map() -> Iterator[None]:
+ """litellm.model_cost with every Claude bridge row applied over a map that lacks them."""
+ original = litellm.model_cost
+ model_cost = {k: v for k, v in copy.deepcopy(original).items() if k not in CLAUDE_BRIDGE_MODELS}
+ apply_model_cost_overrides(model_cost)
+ set_litellm_model_cost(model_cost)
+ yield
+ set_litellm_model_cost(original)
+
+
[email protected]("bridged_litellm_cost_map")
[email protected]("model", CLAUDE_BRIDGE_MODELS)
+ "thinking,effort",
+ [({"type": "between_tools"}, "high"), ({"type": "adaptive"}, "xhigh")],
+)
+def test_claude_bridge_row_keeps_thinking_and_effort(model: str, thinking: dict[str, str], effort: str) -> None:
+ # Without the capability flags litellm treats the model as non-adaptive and strips both fields.
+ out = AnthropicMessagesConfig().transform_anthropic_messages_request(
+ model=model,
+ messages=[{"role": "user", "content": "hi"}],
+ anthropic_messages_optional_request_params={
+ "max_tokens": 1024,
+ "thinking": dict(thinking),
+ "output_config": {"effort": effort},
+ },
+ litellm_params=GenericLiteLLMParams(),
+ headers={},
+ )
+
+ assert out["thinking"] == thinking
+ assert out["output_config"] == {"effort": effort}