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:
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user