fix(tokens): 1M context window for Fable 5 / Mythos 5 / Opus 4.6+ / Sonnet 4.6

The blanket claude→200k rule predates the 1M-window generation. With
a 200k detected window, preventive compaction (threshold 0.6) fired
at ~120k tokens on models that actually hold 1M — 5x too early.

Match the 1M family explicitly (claude-fable, claude-mythos,
claude-opus-4-6/7/8/9, claude-sonnet-4-6) before the 200k fallback;
older Claude models (3.x, 4.0-4.5 era, Haiku 4.5) keep 200k.
This commit is contained in:
sausheong committed 2026-06-10 19:32:09 +08:00
1 parent cf47b2fca8
commit 3064a0da14
2 files changed
+43 -2

No files matched your search

+13 -1
View File
@@ -110,8 +110,20 @@ func windowByModelFamily(modelID string) int {
leaf = leaf[i+1:]
}
switch {
case strings.Contains(id, "claude-fable"),
strings.Contains(id, "claude-mythos"),
strings.Contains(id, "claude-opus-4-6"),
strings.Contains(id, "claude-opus-4-7"),
strings.Contains(id, "claude-opus-4-8"),
strings.Contains(id, "claude-opus-4-9"),
strings.Contains(id, "claude-sonnet-4-6"):
// The 1M-window Claude generation: Fable 5, Mythos 5,
// Opus 4.6+, Sonnet 4.6. Matching the 200k blanket rule below
// would make preventive compaction fire ~5x too early.
return 1000000
case strings.Contains(id, "claude"):
// All current Claude chat models share a 200k window.
// Older Claude chat models (3.x through the 4.5 era, Haiku 4.5)
// share a 200k window.
return 200000
case strings.HasPrefix(leaf, "gpt-4o"), strings.HasPrefix(leaf, "gpt-4-turbo"):
return 128000