Skip to content

Commit 6fcdea0

Browse files
authored
Merge pull request #36969 from oneKn8/fix-cost-map-mid-conversation-flag
fix: add supports_mid_conversation_system to bare first-party Claude cost-map keys
2 parents 5290150 + 4cd1c81 commit 6fcdea0

3 files changed

Lines changed: 47 additions & 0 deletions

File tree

litellm/model_prices_and_context_window_backup.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12373,6 +12373,7 @@
1237312373
"search_context_size_medium": 0.01
1237412374
},
1237512375
"supports_adaptive_thinking": true,
12376+
"supports_mid_conversation_system": true,
1237612377
"supports_assistant_prefill": false,
1237712378
"supports_computer_use": true,
1237812379
"supports_function_calling": true,
@@ -12769,6 +12770,7 @@
1276912770
"search_context_size_medium": 0.01
1277012771
},
1277112772
"supports_adaptive_thinking": true,
12773+
"supports_mid_conversation_system": true,
1277212774
"supports_assistant_prefill": false,
1277312775
"supports_computer_use": true,
1277412776
"supports_function_calling": true,
@@ -12805,6 +12807,7 @@
1280512807
"search_context_size_medium": 0.01
1280612808
},
1280712809
"supports_adaptive_thinking": true,
12810+
"supports_mid_conversation_system": true,
1280812811
"supports_assistant_prefill": false,
1280912812
"supports_computer_use": true,
1281012813
"supports_function_calling": true,
@@ -12844,6 +12847,7 @@
1284412847
"search_context_size_medium": 0.01
1284512848
},
1284612849
"supports_adaptive_thinking": true,
12850+
"supports_mid_conversation_system": true,
1284712851
"supports_assistant_prefill": false,
1284812852
"supports_computer_use": true,
1284912853
"supports_function_calling": true,
@@ -48628,6 +48632,7 @@
4862848632
},
4862948633
"source": "https://docs.claude.com/en/docs/about-claude/models/overview",
4863048634
"supports_adaptive_thinking": true,
48635+
"supports_mid_conversation_system": true,
4863148636
"supports_assistant_prefill": false,
4863248637
"supports_computer_use": true,
4863348638
"supports_function_calling": true,

model_prices_and_context_window.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12373,6 +12373,7 @@
1237312373
"search_context_size_medium": 0.01
1237412374
},
1237512375
"supports_adaptive_thinking": true,
12376+
"supports_mid_conversation_system": true,
1237612377
"supports_assistant_prefill": false,
1237712378
"supports_computer_use": true,
1237812379
"supports_function_calling": true,
@@ -12769,6 +12770,7 @@
1276912770
"search_context_size_medium": 0.01
1277012771
},
1277112772
"supports_adaptive_thinking": true,
12773+
"supports_mid_conversation_system": true,
1277212774
"supports_assistant_prefill": false,
1277312775
"supports_computer_use": true,
1277412776
"supports_function_calling": true,
@@ -12805,6 +12807,7 @@
1280512807
"search_context_size_medium": 0.01
1280612808
},
1280712809
"supports_adaptive_thinking": true,
12810+
"supports_mid_conversation_system": true,
1280812811
"supports_assistant_prefill": false,
1280912812
"supports_computer_use": true,
1281012813
"supports_function_calling": true,
@@ -12844,6 +12847,7 @@
1284412847
"search_context_size_medium": 0.01
1284512848
},
1284612849
"supports_adaptive_thinking": true,
12850+
"supports_mid_conversation_system": true,
1284712851
"supports_assistant_prefill": false,
1284812852
"supports_computer_use": true,
1284912853
"supports_function_calling": true,
@@ -48628,6 +48632,7 @@
4862848632
},
4862948633
"source": "https://docs.claude.com/en/docs/about-claude/models/overview",
4863048634
"supports_adaptive_thinking": true,
48635+
"supports_mid_conversation_system": true,
4863148636
"supports_assistant_prefill": false,
4863248637
"supports_computer_use": true,
4863348638
"supports_function_calling": true,

tests/test_litellm/llms/anthropic/experimental_pass_through/messages/test_anthropic_experimental_pass_through_messages_handler.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,3 +960,40 @@ def test_gate_passthrough_skipped_when_only_chat_completions_supported(monkeypat
960960
assert result == "translated"
961961
assert translation_calls["count"] == 1
962962
assert "config" not in captured
963+
964+
965+
def test_first_party_claude_4_8_plus_cost_map_entries_carry_mid_conversation_system_flag():
966+
"""Regional and provider-prefixed Claude 4.8+/5 entries carry
967+
``supports_mid_conversation_system``, but the bare first-party keys
968+
(``claude-opus-4-8``) that a plain ``custom_llm_provider="anthropic"``
969+
lookup resolves were missed, so that lookup reports the capability as
970+
unset. Every mapped first-party entry the fallback rule matches must
971+
carry the flag."""
972+
import json
973+
import os
974+
import re
975+
976+
import litellm
977+
978+
cost_map_path = os.path.join(
979+
os.path.dirname(litellm.__file__), "model_prices_and_context_window_backup.json"
980+
)
981+
with open(cost_map_path) as f:
982+
cost_map = json.load(f)
983+
rules = cost_map["fallback_generalizations"]["rules"]
984+
rule_pattern = next(
985+
(r["pattern"] for r in rules if r["name"] == "claude-mid-conversation-system"),
986+
None,
987+
)
988+
assert rule_pattern is not None, "claude-mid-conversation-system rule not found in fallback_generalizations"
989+
pattern = re.compile(rule_pattern, re.IGNORECASE)
990+
missing = [
991+
key
992+
for key, info in cost_map.items()
993+
if isinstance(info, dict)
994+
and info.get("litellm_provider") == "anthropic"
995+
and "claude" in key
996+
and pattern.search(key)
997+
and info.get("supports_mid_conversation_system") is not True
998+
]
999+
assert missing == []

0 commit comments

Comments
 (0)