context: Fable and Mythos 5 report a 1M window (#1522)

This commit is contained in:
Swizzy 2026-09-23 16:35:29 +02:00 • committed by GitHub
parent 445d7ad944
commit 4d0f02a51c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 3 deletions

View file

@ -406,9 +406,11 @@ async function findLastBoundary(filePath: string): Promise<{
}
// Claude models with a 1M window: opus-4-8 (auto-compactions on disk show
// ~1.0M preTokens) and the "[1m]" long-context variants. Others default to
// 200K unless the session itself proves bigger.
const MILLION_WINDOW_RE = /opus-4-8|\[1m\]/
// ~1.0M preTokens), the Claude 5 Fable / Mythos ids (claude-fable-5-1 and
// claude-mythos-5-1 run a 1M window from the first turn), and the "[1m]"
// long-context variants. Others default to 200K unless the session itself
// proves bigger.
const MILLION_WINDOW_RE = /opus-4-8|fable-5|mythos-5|\[1m\]/
export function reportedContextWindow(model: string, maxSeenTokens: number): number {
return MILLION_WINDOW_RE.test(model) || maxSeenTokens > 220_000 ? 1_000_000 : 200_000

View file

@ -0,0 +1,17 @@
import { describe, expect, it } from 'vitest'
import { reportedContextWindow } from '../src/context-tree.js'
describe('reportedContextWindow', () => {
it('treats the Claude 5 Fable and Mythos ids as 1M windows from the first turn', () => {
expect(reportedContextWindow('claude-fable-5-1', 10_000)).toBe(1_000_000)
expect(reportedContextWindow('claude-mythos-5-1', 10_000)).toBe(1_000_000)
})
it('keeps the existing 1M names and the 220k proof rule', () => {
expect(reportedContextWindow('claude-opus-4-8', 10_000)).toBe(1_000_000)
expect(reportedContextWindow('claude-sonnet-4-5[1m]', 10_000)).toBe(1_000_000)
expect(reportedContextWindow('claude-sonnet-4-5', 10_000)).toBe(200_000)
expect(reportedContextWindow('claude-sonnet-4-5', 220_001)).toBe(1_000_000)
})
})