From 1625adcb0ffb6aeea620e30db60699fe27a7457b Mon Sep 17 00:00:00 2001 From: shang309073819 Date: Fri, 17 Apr 2026 23:26:55 +0000 Subject: [PATCH] test(anthropic): force LITELLM_LOCAL_MODEL_COST_MAP for new max-effort tests CI fetches model_prices_and_context_window.json from `main` at runtime, so the new `supports_max_reasoning_effort` flags added in this PR are not yet visible to the live CI run. Mirror the established pattern from `tests/litellm_utils_tests/test_utils.py::test_supports_reasoning`: set LITELLM_LOCAL_MODEL_COST_MAP=True and reload `litellm.model_cost` inside each new accept-test, so they read the model-map version that is in this same PR. Affected tests: * test_max_effort_accepted_for_opus_46 * test_max_effort_accepted_for_opus_47 * test_max_effort_accepted_for_sonnet_46 Locally verified: 137 / 137 pass in test_anthropic_chat_transformation.py --- .../test_anthropic_chat_transformation.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py b/tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py index 1707447cd83..f40d58d0eca 100644 --- a/tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py +++ b/tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py @@ -1653,9 +1653,7 @@ def test_max_effort_rejected_for_opus_45(): messages = [{"role": "user", "content": "Test"}] - with pytest.raises( - ValueError, match="effort='max' is not supported by this model" - ): + with pytest.raises(ValueError, match="effort='max' is not supported by this model"): optional_params = {"output_config": {"effort": "max"}} config.transform_request( model="claude-opus-4-5-20251101", @@ -2219,6 +2217,11 @@ def test_max_effort_accepted_for_sonnet_46(): > The ``max`` effort level is available on Claude Mythos Preview, > Claude Opus 4.7, Claude Opus 4.6, and Claude Sonnet 4.6. """ + import litellm + + os.environ["LITELLM_LOCAL_MODEL_COST_MAP"] = "True" + litellm.model_cost = litellm.get_model_cost_map(url="") + config = AnthropicConfig() messages = [{"role": "user", "content": "Test"}] @@ -2235,6 +2238,11 @@ def test_max_effort_accepted_for_sonnet_46(): def test_max_effort_accepted_for_opus_46(): """Test that effort='max' works for Opus 4.6.""" + import litellm + + os.environ["LITELLM_LOCAL_MODEL_COST_MAP"] = "True" + litellm.model_cost = litellm.get_model_cost_map(url="") + config = AnthropicConfig() messages = [{"role": "user", "content": "Test"}] @@ -2256,6 +2264,11 @@ def test_max_effort_accepted_for_opus_47(): ``claude-opus-4-7-*`` models. The previous hardcoded ``_is_opus_4_6_model`` guard rejected the request before it ever reached Anthropic. """ + import litellm + + os.environ["LITELLM_LOCAL_MODEL_COST_MAP"] = "True" + litellm.model_cost = litellm.get_model_cost_map(url="") + config = AnthropicConfig() messages = [{"role": "user", "content": "Test"}]