fix(shared): return GA 1M context limit for Anthropic 4.6/4.7 models without cached entry

Anthropic made the 1M context window GA for Opus 4.6, Sonnet 4.6, and 4.7 models on March 13, 2026 — no beta header required. The resolver was still falling back to 200K when no modelContextLimitsCache entry existed, causing premature compaction and over-truncation.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-05-18 13:36:01 +09:00
parent 5555dbfc67
commit b9a8ffec51
2 changed files with 77 additions and 4 deletions
+70
View File
@@ -158,6 +158,76 @@ describe("resolveActualContextLimit", () => {
expect(actualLimit).toBe(200_000)
})
it("returns GA 1M for claude-sonnet-4-6 without cached limit (GA context window)", () => {
// given
delete process.env[ANTHROPIC_CONTEXT_ENV_KEY]
delete process.env[VERTEX_CONTEXT_ENV_KEY]
// when
const actualLimit = resolveActualContextLimit("anthropic", "claude-sonnet-4-6", {
anthropicContext1MEnabled: false,
})
// then
expect(actualLimit).toBe(1_000_000)
})
it("returns GA 1M for claude-opus-4-6 without cached limit (GA context window)", () => {
// given
delete process.env[ANTHROPIC_CONTEXT_ENV_KEY]
delete process.env[VERTEX_CONTEXT_ENV_KEY]
// when
const actualLimit = resolveActualContextLimit("anthropic", "claude-opus-4-6", {
anthropicContext1MEnabled: false,
})
// then
expect(actualLimit).toBe(1_000_000)
})
it("returns GA 1M for claude-opus-4-7 without cached limit (GA context window)", () => {
// given
delete process.env[ANTHROPIC_CONTEXT_ENV_KEY]
delete process.env[VERTEX_CONTEXT_ENV_KEY]
// when
const actualLimit = resolveActualContextLimit("anthropic", "claude-opus-4-7", {
anthropicContext1MEnabled: false,
})
// then
expect(actualLimit).toBe(1_000_000)
})
it("returns GA 1M for claude-sonnet-4-6-high without cached limit (GA context window)", () => {
// given
delete process.env[ANTHROPIC_CONTEXT_ENV_KEY]
delete process.env[VERTEX_CONTEXT_ENV_KEY]
// when
const actualLimit = resolveActualContextLimit("anthropic", "claude-sonnet-4-6-high", {
anthropicContext1MEnabled: false,
})
// then
expect(actualLimit).toBe(1_000_000)
})
it("returns GA 1M for GA models on google-vertex-anthropic without cached limit", () => {
// given
delete process.env[ANTHROPIC_CONTEXT_ENV_KEY]
delete process.env[VERTEX_CONTEXT_ENV_KEY]
// when
const actualLimit = resolveActualContextLimit("google-vertex-anthropic", "claude-sonnet-4-6", {
anthropicContext1MEnabled: false,
})
// then
expect(actualLimit).toBe(1_000_000)
})
it("returns null for non-Anthropic providers without a cached limit", () => {
// given
delete process.env[ANTHROPIC_CONTEXT_ENV_KEY]