aegiscode 5.2.29 → 5.2.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +263 -263
- package/package.json +1 -1
- package/scripts/repro-compact.ts +59 -0
package/package.json
CHANGED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verification: store-side (emergency) auto-compact in aegiscodex-
|
|
3
|
+
*
|
|
4
|
+
* Two properties the fix must hold:
|
|
5
|
+
* 1. No shadowing — the store-side path sits ABOVE the UI autoCompactThreshold,
|
|
6
|
+
* so growing up to (but below) the emergency fraction does NOT fire it,
|
|
7
|
+
* leaving normal compaction to the UI's LLM-quality path.
|
|
8
|
+
* 2. No balloon — once past the emergency threshold, continued growth re-fires
|
|
9
|
+
* it (no wall-clock cooldown), so context can't grow to 2× the window during
|
|
10
|
+
* a rapid burst of large turns.
|
|
11
|
+
*/
|
|
12
|
+
import { ContextManager } from '/home/neo/aegiscodex-/src/context/ContextManager.js';
|
|
13
|
+
|
|
14
|
+
const MAX_CTX = 24000;
|
|
15
|
+
const UI_FRACTION = 0.5; // UI path compacts here (LLM quality)
|
|
16
|
+
const EMERGENCY = Math.floor(MAX_CTX * 0.9); // store-side emergency threshold
|
|
17
|
+
|
|
18
|
+
async function run(label: string, threshold: number, iterations: number) {
|
|
19
|
+
const cm = new ContextManager({ compressionThreshold: threshold });
|
|
20
|
+
await cm.createSession();
|
|
21
|
+
|
|
22
|
+
const filler = 'The quick brown fox jumps over the lazy dog repeatedly. '.repeat(30); // ~1800 chars
|
|
23
|
+
let compactCount = 0;
|
|
24
|
+
const origLog = console.log;
|
|
25
|
+
(console as any).log = (...args: any[]) => {
|
|
26
|
+
if (args.join(' ').includes('[CompactionService] Fast compact')) compactCount++;
|
|
27
|
+
};
|
|
28
|
+
for (let i = 0; i < iterations; i++) {
|
|
29
|
+
await cm.addMessage('user', `user message ${i}: ${filler}`);
|
|
30
|
+
await cm.addMessage('assistant', `assistant reply ${i}: ${filler}`);
|
|
31
|
+
}
|
|
32
|
+
(console as any).log = origLog;
|
|
33
|
+
|
|
34
|
+
const tokens = cm.getTokenCount();
|
|
35
|
+
console.log(`\n=== ${label} ===`);
|
|
36
|
+
console.log('store-side compactions fired:', compactCount);
|
|
37
|
+
console.log('final store token count:', tokens);
|
|
38
|
+
await cm.cleanup();
|
|
39
|
+
return { compactCount, tokens };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function main() {
|
|
43
|
+
// 1. Below emergency: grow to ~60% of window. Store-side must NOT fire.
|
|
44
|
+
const below = await run('Below emergency (UI owns compaction)', EMERGENCY, 4);
|
|
45
|
+
console.log('shadowing avoided (0 store compactions expected):', below.compactCount === 0 ? 'PASS' : 'FAIL');
|
|
46
|
+
|
|
47
|
+
// 2. Rapid large burst past emergency. Store-side must fire repeatedly and
|
|
48
|
+
// keep context bounded (no 60s cooldown blocking → no 2× balloon).
|
|
49
|
+
const burst = await run('Rapid burst past emergency', EMERGENCY, 120);
|
|
50
|
+
const balloonLimit = EMERGENCY * 1.5;
|
|
51
|
+
console.log('\n=== Summary ===');
|
|
52
|
+
console.log('emergency threshold:', EMERGENCY, '| balloon guard (<1.5×):', Math.floor(balloonLimit));
|
|
53
|
+
console.log('re-fired on continued growth (>1 compaction):', burst.compactCount > 1 ? 'PASS' : 'FAIL',
|
|
54
|
+
`(fired ${burst.compactCount}×)`);
|
|
55
|
+
console.log('context stayed bounded (<1.5× emergency):', burst.tokens < balloonLimit ? 'PASS' : 'FAIL',
|
|
56
|
+
`(final ${burst.tokens})`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
main().catch(e => { console.error(e); process.exit(1); });
|