Models: prefer longest known context match

KNOWN_CONTEXT_WINDOWS lists 'o1' (200k) before 'o1-mini' (128k), and
_lookup_known returned on the first substring hit — so "o1-mini" matched
'o1' and reported 200000 instead of 128000. Track the longest matching
key instead, so the most specific entry wins regardless of table order.
This commit is contained in:
SurprisedDuck
2026-06-02 13:33:09 +02:00
committed by GitHub
parent 0b0be3c339
commit d06b6d87d3
2 changed files with 24 additions and 3 deletions
+13
View File
@@ -109,6 +109,19 @@ class TestLookupKnown:
result = _lookup_known("deepseek-r1:free")
assert result == 64000
def test_o1_mini_not_shadowed_by_o1(self):
"""'o1' (200k) precedes 'o1-mini' (128k) in the table; longest match wins."""
assert _lookup_known("o1-mini") == 128000
def test_o1_full(self):
assert _lookup_known("o1") == 200000
def test_gpt4o_mini_not_shadowed_by_gpt4(self):
assert _lookup_known("gpt-4o-mini") == 128000
def test_gpt4_base(self):
assert _lookup_known("gpt-4") == 8192
class TestGetContextLength:
def setup_method(self):