Skip to content

Commit 74f9c09

Browse files
committed
test: bound the compaction remaining-window cap against the history estimate
1 parent 1ea5543 commit 74f9c09

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

packages/agent-core/test/agent/compaction/full.test.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1908,9 +1908,17 @@ describe('FullCompaction', () => {
19081908

19091909
expect(callCount).toBe(3);
19101910
expect(compactionMaxCompletionTokens).toHaveLength(1);
1911-
const cap = compactionMaxCompletionTokens[0] as number;
1912-
expect(cap).toBeGreaterThanOrEqual(1);
1913-
expect(cap).toBeLessThan(maxContextTokens);
1911+
const cap = compactionMaxCompletionTokens[0];
1912+
if (typeof cap !== 'number') {
1913+
throw new TypeError(`expected a numeric max_completion_tokens, got ${String(cap)}`);
1914+
}
1915+
// The 8000 ASCII history chars estimate to >= 2000 tokens (~4 chars per
1916+
// token), so the remaining-window cap must land at or below
1917+
// maxContextTokens - 2000 — well under the flat min(maxCtx, 128k) the
1918+
// budget used before the fix. The exact value tracks the estimator and
1919+
// message-projection internals, so bound it instead of pinning it.
1920+
expect(cap).toBeGreaterThan(1);
1921+
expect(cap).toBeLessThanOrEqual(maxContextTokens - 2000);
19141922
});
19151923

19161924
it('ignores filtered assistant placeholders when checking the retained overflow suffix', async () => {

0 commit comments

Comments
 (0)