Providers: skip context1m beta for Anthropic OAuth tokens (#24620)

* Providers: skip context1m beta for Anthropic OAuth tokens

* Tests: cover OAuth context1m beta skip behavior

* Docs: note context1m OAuth incompatibility

* Agents: add context1m-aware context token resolver

* Agents: cover context1m context-token resolver

* Commands: apply context1m-aware context tokens in session store

* Commands: apply context1m-aware context tokens in status summary

* Status: resolve context tokens with context1m model params

* Status: test context1m status context display
This commit is contained in:
Vincent Koc
2026-02-23 12:29:09 -05:00
committed by GitHub
parent 28377e1b7a
commit f03ff39754
11 changed files with 248 additions and 23 deletions

View File

@@ -1,5 +1,10 @@
import { describe, expect, it } from "vitest";
import { applyConfiguredContextWindows, applyDiscoveredContextWindows } from "./context.js";
import {
ANTHROPIC_CONTEXT_1M_TOKENS,
applyConfiguredContextWindows,
applyDiscoveredContextWindows,
resolveContextTokensForModel,
} from "./context.js";
import { createSessionManagerRuntimeRegistry } from "./pi-extensions/session-manager-runtime-registry.js";
describe("applyDiscoveredContextWindows", () => {
@@ -75,3 +80,47 @@ describe("createSessionManagerRuntimeRegistry", () => {
expect(registry.get(123)).toBeNull();
});
});
describe("resolveContextTokensForModel", () => {
it("returns 1M context when anthropic context1m is enabled for opus/sonnet", () => {
const result = resolveContextTokensForModel({
cfg: {
agents: {
defaults: {
models: {
"anthropic/claude-opus-4-6": {
params: { context1m: true },
},
},
},
},
},
provider: "anthropic",
model: "claude-opus-4-6",
fallbackContextTokens: 200_000,
});
expect(result).toBe(ANTHROPIC_CONTEXT_1M_TOKENS);
});
it("does not force 1M context for non-opus/sonnet Anthropic models", () => {
const result = resolveContextTokensForModel({
cfg: {
agents: {
defaults: {
models: {
"anthropic/claude-haiku-3-5": {
params: { context1m: true },
},
},
},
},
},
provider: "anthropic",
model: "claude-haiku-3-5",
fallbackContextTokens: 200_000,
});
expect(result).toBe(200_000);
});
});