fix(shared): extract shared context limit resolver to eliminate monitor/truncator drift

- New context-limit-resolver.ts with resolveActualContextLimit() shared helper
- Anthropic provider detection now uses .includes('anthropic') instead of hard-coded IDs
- Both context-window-monitor and dynamic-truncator use the shared resolver
- Added missing test cases: Anthropic+1M disabled+cached limit, non-Anthropic without cache
This commit is contained in:
YeonGyu-Kim
2026-03-11 21:45:44 +09:00
parent d4232c9eac
commit 59f0f06e71
7 changed files with 197 additions and 57 deletions
+16
View File
@@ -125,6 +125,22 @@ describe("getContextWindowUsage", () => {
expect(usage?.remainingTokens).toBe(82144)
})
it("returns null for non-anthropic providers without a cached limit", async () => {
// given
const ctx = createContextUsageMockContext(180000, {
providerID: "openai",
modelID: "gpt-5",
})
// when
const usage = await getContextWindowUsage(ctx as never, "ses_no_cached_limit", {
anthropicContext1MEnabled: false,
})
// then
expect(usage).toBeNull()
})
describe("#given Anthropic provider with cached context limit and 1M mode enabled", () => {
describe("#when context usage is resolved", () => {
it("#then should ignore the cached limit and use the 1M Anthropic limit", async () => {