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:
1 parent
cf47b2fca8
commit
3064a0da14
2 files changed
+43
-2
No files matched your search
+13
-1
@@ -110,8 +110,20 @@ func windowByModelFamily(modelID string) int {
|
|||||||
leaf = leaf[i+1:]
|
leaf = leaf[i+1:]
|
||||||
}
|
}
|
||||||
switch {
|
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"):
|
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
|
return 200000
|
||||||
case strings.HasPrefix(leaf, "gpt-4o"), strings.HasPrefix(leaf, "gpt-4-turbo"):
|
case strings.HasPrefix(leaf, "gpt-4o"), strings.HasPrefix(leaf, "gpt-4-turbo"):
|
||||||
return 128000
|
return 128000
|
||||||
|
|||||||
+30
-1
@@ -84,7 +84,7 @@ func TestContextWindowProxyProviderDetectedByModelFamily(t *testing.T) {
|
|||||||
model string
|
model string
|
||||||
want int
|
want int
|
||||||
}{
|
}{
|
||||||
{"platformai/claude-sonnet-4-6-asia-southeast1", 200000},
|
{"platformai/claude-sonnet-4-6-asia-southeast1", 1000000},
|
||||||
{"openrouter/anthropic/claude-3-opus", 200000},
|
{"openrouter/anthropic/claude-3-opus", 200000},
|
||||||
{"bedrock/anthropic.claude-3-haiku", 200000},
|
{"bedrock/anthropic.claude-3-haiku", 200000},
|
||||||
{"vertex/gemini-1.5-pro-001", 2000000},
|
{"vertex/gemini-1.5-pro-001", 2000000},
|
||||||
@@ -135,3 +135,32 @@ func TestCalibratorIgnoresZeroOrNegative(t *testing.T) {
|
|||||||
c.Update(-5, 100)
|
c.Update(-5, 100)
|
||||||
assert.Equal(t, 100, c.Adjust(100), "bad samples must be ignored")
|
assert.Equal(t, 100, c.Adjust(100), "bad samples must be ignored")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestContextWindow1MClaudeFamily pins the 1M-window Claude generation:
|
||||||
|
// Fable 5, Mythos 5, Opus 4.6+, and Sonnet 4.6 all ship a 1M context
|
||||||
|
// window. The old blanket claude→200k rule made compaction fire ~5x too
|
||||||
|
// early on these models. Older Claude (3.x, 4.0-4.5 era) stays 200k.
|
||||||
|
func TestContextWindow1MClaudeFamily(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
model string
|
||||||
|
want int
|
||||||
|
}{
|
||||||
|
{"anthropic/claude-fable-5", 1000000},
|
||||||
|
{"platformai/claude-fable-5-global", 1000000},
|
||||||
|
{"anthropic/claude-mythos-5", 1000000},
|
||||||
|
{"anthropic/claude-opus-4-6", 1000000},
|
||||||
|
{"anthropic/claude-opus-4-7", 1000000},
|
||||||
|
{"anthropic/claude-opus-4-8", 1000000},
|
||||||
|
{"platformai/claude-sonnet-4-6-asia-southeast1", 1000000},
|
||||||
|
// Older generations keep 200k.
|
||||||
|
{"anthropic/claude-haiku-4-5-20251001", 200000},
|
||||||
|
{"anthropic/claude-sonnet-4-5", 200000},
|
||||||
|
{"anthropic/claude-3-5-sonnet-20241022", 200000},
|
||||||
|
{"anthropic/claude-opus-4-0-20250514", 200000},
|
||||||
|
}
|
||||||
|
for _, tc := range tests {
|
||||||
|
t.Run(tc.model, func(t *testing.T) {
|
||||||
|
assert.Equal(t, tc.want, ContextWindow(tc.model))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user