Skip to content

Commit 4cd1c81

Browse files
committed
fix: add supports_mid_conversation_system to bare first-party Claude cost-map keys
1 parent 2bc9bb4 commit 4cd1c81

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
@@ -12106,6 +12106,7 @@
1210612106
"search_context_size_medium": 0.01
1210712107
},
1210812108
"supports_adaptive_thinking": true,
12109+
"supports_mid_conversation_system": true,
1210912110
"supports_assistant_prefill": false,
1211012111
"supports_computer_use": true,
1211112112
"supports_function_calling": true,
@@ -12493,6 +12494,7 @@
1249312494
"search_context_size_medium": 0.01
1249412495
},
1249512496
"supports_adaptive_thinking": true,
12497+
"supports_mid_conversation_system": true,
1249612498
"supports_assistant_prefill": false,
1249712499
"supports_computer_use": true,
1249812500
"supports_function_calling": true,
@@ -12528,6 +12530,7 @@
1252812530
"search_context_size_medium": 0.01
1252912531
},
1253012532
"supports_adaptive_thinking": true,
12533+
"supports_mid_conversation_system": true,
1253112534
"supports_assistant_prefill": false,
1253212535
"supports_computer_use": true,
1253312536
"supports_function_calling": true,
@@ -12566,6 +12569,7 @@
1256612569
"search_context_size_medium": 0.01
1256712570
},
1256812571
"supports_adaptive_thinking": true,
12572+
"supports_mid_conversation_system": true,
1256912573
"supports_assistant_prefill": false,
1257012574
"supports_computer_use": true,
1257112575
"supports_function_calling": true,
@@ -47684,6 +47688,7 @@
4768447688
},
4768547689
"source": "https://docs.claude.com/en/docs/about-claude/models/overview",
4768647690
"supports_adaptive_thinking": true,
47691+
"supports_mid_conversation_system": true,
4768747692
"supports_assistant_prefill": false,
4768847693
"supports_computer_use": true,
4768947694
"supports_function_calling": true,

model_prices_and_context_window.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12106,6 +12106,7 @@
1210612106
"search_context_size_medium": 0.01
1210712107
},
1210812108
"supports_adaptive_thinking": true,
12109+
"supports_mid_conversation_system": true,
1210912110
"supports_assistant_prefill": false,
1211012111
"supports_computer_use": true,
1211112112
"supports_function_calling": true,
@@ -12493,6 +12494,7 @@
1249312494
"search_context_size_medium": 0.01
1249412495
},
1249512496
"supports_adaptive_thinking": true,
12497+
"supports_mid_conversation_system": true,
1249612498
"supports_assistant_prefill": false,
1249712499
"supports_computer_use": true,
1249812500
"supports_function_calling": true,
@@ -12528,6 +12530,7 @@
1252812530
"search_context_size_medium": 0.01
1252912531
},
1253012532
"supports_adaptive_thinking": true,
12533+
"supports_mid_conversation_system": true,
1253112534
"supports_assistant_prefill": false,
1253212535
"supports_computer_use": true,
1253312536
"supports_function_calling": true,
@@ -12566,6 +12569,7 @@
1256612569
"search_context_size_medium": 0.01
1256712570
},
1256812571
"supports_adaptive_thinking": true,
12572+
"supports_mid_conversation_system": true,
1256912573
"supports_assistant_prefill": false,
1257012574
"supports_computer_use": true,
1257112575
"supports_function_calling": true,
@@ -47684,6 +47688,7 @@
4768447688
},
4768547689
"source": "https://docs.claude.com/en/docs/about-claude/models/overview",
4768647690
"supports_adaptive_thinking": true,
47691+
"supports_mid_conversation_system": true,
4768747692
"supports_assistant_prefill": false,
4768847693
"supports_computer_use": true,
4768947694
"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)