From 4d0f02a51ccca29f6726b26cfc16a95685b470f4 Mon Sep 17 00:00:00 2001 From: Swizzy Date: Wed, 23 Sep 2026 16:35:29 +0200 Subject: [PATCH] context: Fable and Mythos 5 report a 1M window (#1522) --- src/context-tree.ts | 8 +++++--- tests/context-window.test.ts | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 tests/context-window.test.ts diff --git a/src/context-tree.ts b/src/context-tree.ts index 1040431a..9e91cb68 100644 --- a/src/context-tree.ts +++ b/src/context-tree.ts @@ -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 diff --git a/tests/context-window.test.ts b/tests/context-window.test.ts new file mode 100644 index 00000000..5bc28394 --- /dev/null +++ b/tests/context-window.test.ts @@ -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) + }) +})