From 593b12dc566ed0bf69f0cc70f59b50c4e6521b29 Mon Sep 17 00:00:00 2001 From: shivam Date: Fri, 24 Jul 2026 21:53:12 +0000 Subject: [PATCH 1/2] fix(azure_ai): advertise 1M context window for Claude Opus 4.6+ on Foundry Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- ...odel_prices_and_context_window_backup.json | 6 ++--- model_prices_and_context_window.json | 6 ++--- .../test_get_model_cost_map.py | 25 +++++++++++++++++++ .../test_claude_opus_4_6_config.py | 2 +- .../test_claude_opus_4_8_config.py | 3 +-- 5 files changed, 33 insertions(+), 9 deletions(-) diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index d43eda39b1f..ccce2f20e0c 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -2887,7 +2887,7 @@ "input_cost_per_token": 5e-06, "output_cost_per_token": 2.5e-05, "litellm_provider": "azure_ai", - "max_input_tokens": 200000, + "max_input_tokens": 1000000, "max_output_tokens": 128000, "max_tokens": 128000, "mode": "chat", @@ -2916,7 +2916,7 @@ "input_cost_per_token": 5e-06, "output_cost_per_token": 2.5e-05, "litellm_provider": "azure_ai", - "max_input_tokens": 200000, + "max_input_tokens": 1000000, "max_output_tokens": 128000, "max_tokens": 128000, "mode": "chat", @@ -3010,7 +3010,7 @@ "input_cost_per_token": 5e-06, "output_cost_per_token": 2.5e-05, "litellm_provider": "azure_ai", - "max_input_tokens": 200000, + "max_input_tokens": 1000000, "max_output_tokens": 128000, "max_tokens": 128000, "mode": "chat", diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json index 749b2566c2a..ebe99a77d8b 100644 --- a/model_prices_and_context_window.json +++ b/model_prices_and_context_window.json @@ -2887,7 +2887,7 @@ "input_cost_per_token": 5e-06, "output_cost_per_token": 2.5e-05, "litellm_provider": "azure_ai", - "max_input_tokens": 200000, + "max_input_tokens": 1000000, "max_output_tokens": 128000, "max_tokens": 128000, "mode": "chat", @@ -2916,7 +2916,7 @@ "input_cost_per_token": 5e-06, "output_cost_per_token": 2.5e-05, "litellm_provider": "azure_ai", - "max_input_tokens": 200000, + "max_input_tokens": 1000000, "max_output_tokens": 128000, "max_tokens": 128000, "mode": "chat", @@ -3010,7 +3010,7 @@ "input_cost_per_token": 5e-06, "output_cost_per_token": 2.5e-05, "litellm_provider": "azure_ai", - "max_input_tokens": 200000, + "max_input_tokens": 1000000, "max_output_tokens": 128000, "max_tokens": 128000, "mode": "chat", diff --git a/tests/test_litellm/litellm_core_utils/test_get_model_cost_map.py b/tests/test_litellm/litellm_core_utils/test_get_model_cost_map.py index 1a38b5dc769..2c7bd8d9b65 100644 --- a/tests/test_litellm/litellm_core_utils/test_get_model_cost_map.py +++ b/tests/test_litellm/litellm_core_utils/test_get_model_cost_map.py @@ -209,3 +209,28 @@ def test_shipped_backup_marks_claude_4_6_plus_adaptive_not_4_0(): "claude-opus-4-5", ]: assert "supports_adaptive_thinking" not in backup[non_adaptive], non_adaptive + + +def test_azure_ai_claude_1m_context_entries(): + """Microsoft Foundry serves a 1M-token context window for Opus 4.6+ and Sonnet + 4.6+, so the ``azure_ai`` entries must not advertise the 200k cap that made + context-aware clients compact prompts early (LIT-4406).""" + backup = GetModelCostMap.load_local_model_cost_map() + + for model in [ + "azure_ai/claude-opus-4-6", + "azure_ai/claude-opus-4-7", + "azure_ai/claude-opus-4-8", + "azure_ai/claude-opus-5", + "azure_ai/claude-sonnet-5", + "azure_ai/claude-sonnet-4-6", + ]: + assert backup[model]["max_input_tokens"] == 1000000, model + + for model in [ + "azure_ai/claude-opus-4-1", + "azure_ai/claude-opus-4-5", + "azure_ai/claude-sonnet-4-5", + "azure_ai/claude-haiku-4-5", + ]: + assert backup[model]["max_input_tokens"] == 200000, model diff --git a/tests/test_litellm/test_claude_opus_4_6_config.py b/tests/test_litellm/test_claude_opus_4_6_config.py index d946d1b41af..89d2cd916e0 100644 --- a/tests/test_litellm/test_claude_opus_4_6_config.py +++ b/tests/test_litellm/test_claude_opus_4_6_config.py @@ -102,7 +102,7 @@ def test_opus_4_6_model_pricing_and_capabilities(): "azure_ai/claude-opus-4-6": { "provider": "azure_ai", "has_long_context_pricing": False, - "max_input_tokens": 200000, + "max_input_tokens": 1000000, }, } diff --git a/tests/test_litellm/test_claude_opus_4_8_config.py b/tests/test_litellm/test_claude_opus_4_8_config.py index 8eead8a9c84..f9f9214295a 100644 --- a/tests/test_litellm/test_claude_opus_4_8_config.py +++ b/tests/test_litellm/test_claude_opus_4_8_config.py @@ -60,10 +60,9 @@ def test_opus_4_8_model_pricing_and_capabilities(): "provider": "vertex_ai-anthropic_models", "max_input_tokens": 1000000, }, - # Microsoft Foundry / Azure caps Opus 4.8 at a 200k context window. "azure_ai/claude-opus-4-8": { "provider": "azure_ai", - "max_input_tokens": 200000, + "max_input_tokens": 1000000, }, } From e6b5511dcf53194579d0f7b34db9d209629fdb2d Mon Sep 17 00:00:00 2001 From: shivam Date: Fri, 24 Jul 2026 22:09:18 +0000 Subject: [PATCH 2/2] test(cost_map): cover root map in the Foundry Claude context matrix Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../test_get_model_cost_map.py | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/tests/test_litellm/litellm_core_utils/test_get_model_cost_map.py b/tests/test_litellm/litellm_core_utils/test_get_model_cost_map.py index 2c7bd8d9b65..f21c667276e 100644 --- a/tests/test_litellm/litellm_core_utils/test_get_model_cost_map.py +++ b/tests/test_litellm/litellm_core_utils/test_get_model_cost_map.py @@ -4,6 +4,7 @@ count actual model entries, not reserved meta keys) and the extraction of the ``fallback_generalizations`` block out of the raw map. """ +import json import os import sys @@ -25,6 +26,14 @@ from litellm.litellm_core_utils.get_model_cost_map import ( ) +def _load_root_cost_map() -> dict: + path = os.path.join( + os.path.dirname(__file__), "../../../model_prices_and_context_window.json" + ) + with open(path) as f: + return json.load(f) + + def _make_models(n: int) -> dict: return { f"model-{i}": {"litellm_provider": "openai", "mode": "chat"} for i in range(n) @@ -211,12 +220,17 @@ def test_shipped_backup_marks_claude_4_6_plus_adaptive_not_4_0(): assert "supports_adaptive_thinking" not in backup[non_adaptive], non_adaptive -def test_azure_ai_claude_1m_context_entries(): +@pytest.mark.parametrize( + "cost_map", + [_load_root_cost_map(), GetModelCostMap.load_local_model_cost_map()], + ids=["root", "bundled_backup"], +) +def test_azure_ai_claude_1m_context_entries(cost_map: dict): """Microsoft Foundry serves a 1M-token context window for Opus 4.6+ and Sonnet 4.6+, so the ``azure_ai`` entries must not advertise the 200k cap that made - context-aware clients compact prompts early (LIT-4406).""" - backup = GetModelCostMap.load_local_model_cost_map() - + context-aware clients compact prompts early (LIT-4406). Both the root map (used + by default network loading) and the bundled fallback are checked so the two can + never drift apart.""" for model in [ "azure_ai/claude-opus-4-6", "azure_ai/claude-opus-4-7", @@ -225,7 +239,7 @@ def test_azure_ai_claude_1m_context_entries(): "azure_ai/claude-sonnet-5", "azure_ai/claude-sonnet-4-6", ]: - assert backup[model]["max_input_tokens"] == 1000000, model + assert cost_map[model]["max_input_tokens"] == 1000000, model for model in [ "azure_ai/claude-opus-4-1", @@ -233,4 +247,4 @@ def test_azure_ai_claude_1m_context_entries(): "azure_ai/claude-sonnet-4-5", "azure_ai/claude-haiku-4-5", ]: - assert backup[model]["max_input_tokens"] == 200000, model + assert cost_map[model]["max_input_tokens"] == 200000, model