mirror of
https://bitbucket.org/siakitem/my-pi.git
synced 2026-10-26 10:45:22 +00:00
feat: unify context compaction
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { shouldCompact } from "../src/token-accounting.ts";
|
||||
|
||||
test("raw pressure cannot trigger compaction while effective lower-bound stays below 90%", () => {
|
||||
const config = { hardRatio: 0.9 };
|
||||
const snapshot = { lowerBound: 231_000, contextWindow: 300_000 };
|
||||
assert.equal(shouldCompact("threshold", snapshot, config), false);
|
||||
assert.equal(shouldCompact("manual", snapshot, config), true);
|
||||
assert.equal(shouldCompact("overflow", snapshot, config), true);
|
||||
});
|
||||
|
||||
test("effective lower-bound at the configured threshold compacts", () => {
|
||||
assert.equal(shouldCompact(
|
||||
"threshold",
|
||||
{ lowerBound: 270_000, contextWindow: 300_000 },
|
||||
{ hardRatio: 0.9 },
|
||||
), true);
|
||||
});
|
||||
Reference in New Issue
Block a user