@@ -3,11 +3,9 @@ import { describe, expect, it } from "vitest";
|
3 | 3 | import type { OpenClawConfig } from "../config/config.js"; |
4 | 4 | import { |
5 | 5 | CONTEXT_WINDOW_HARD_MIN_TOKENS, |
6 | | -CONTEXT_WINDOW_WARN_BELOW_TOKENS, |
7 | 6 | evaluateContextWindowGuard, |
8 | 7 | formatContextWindowBlockMessage, |
9 | 8 | formatContextWindowWarningMessage, |
10 | | -resolveContextWindowGuardThresholds, |
11 | 9 | resolveContextWindowInfo, |
12 | 10 | } from "./context-window-guard.js"; |
13 | 11 | |
@@ -297,24 +295,22 @@ describe("context-window-guard", () => {
|
297 | 295 | expect(guard.shouldBlock).toBe(false); |
298 | 296 | }); |
299 | 297 | |
300 | | -it("exports threshold floors as expected", () => { |
| 298 | +it("exports the public hard-min floor as expected", () => { |
301 | 299 | expect(CONTEXT_WINDOW_HARD_MIN_TOKENS).toBe(4_000); |
302 | | -expect(CONTEXT_WINDOW_WARN_BELOW_TOKENS).toBe(8_000); |
303 | 300 | }); |
304 | 301 | |
305 | | -it("derives percentage-based thresholds above the safe floors", () => { |
306 | | -expect(resolveContextWindowGuardThresholds(1_000_000)).toEqual({ |
307 | | -hardMinTokens: 100_000, |
308 | | -warnBelowTokens: 200_000, |
| 302 | +it("derives percentage-based guard thresholds above the safe floors", () => { |
| 303 | +const largeGuard = evaluateContextWindowGuard({ |
| 304 | +info: { tokens: 1_000_000, source: "model" }, |
309 | 305 | }); |
310 | | -expect(resolveContextWindowGuardThresholds(64_000)).toEqual({ |
311 | | -hardMinTokens: 6_400, |
312 | | -warnBelowTokens: 12_800, |
313 | | -}); |
314 | | -expect(resolveContextWindowGuardThresholds(Number.NaN)).toEqual({ |
315 | | -hardMinTokens: 4_000, |
316 | | -warnBelowTokens: 8_000, |
| 306 | +expect(largeGuard.hardMinTokens).toBe(100_000); |
| 307 | +expect(largeGuard.warnBelowTokens).toBe(200_000); |
| 308 | + |
| 309 | +const mediumGuard = evaluateContextWindowGuard({ |
| 310 | +info: { tokens: 64_000, source: "model" }, |
317 | 311 | }); |
| 312 | +expect(mediumGuard.hardMinTokens).toBe(6_400); |
| 313 | +expect(mediumGuard.warnBelowTokens).toBe(12_800); |
318 | 314 | }); |
319 | 315 | |
320 | 316 | it("derives guard thresholds from the reference window when capped", () => { |
|