feat(FN-4180): compact room transcript context to reduce token usage
Adds room transcript context compaction (FN-4180) to the dashboard chat layer — widens the fetch window then compacts older messages into a summary window to reduce token overhead while keeping full context recent. Includes a new 127-line test suite covering the compaction logic, a small fix to reus Fusion-Task-Id: FN-4180 Fusion-Task-Lineage: 9e7e3a32-f2da-4c86-871b-37891f747561
This commit is contained in:
@@ -173,6 +173,10 @@ function cleanupTempDir(dir?: string): void {
|
||||
|
||||
sleepSync(attempt * 25);
|
||||
}
|
||||
|
||||
if (existsSync(dir)) {
|
||||
throw new Error(`failed to clean temp dir: ${dir}`);
|
||||
}
|
||||
}
|
||||
|
||||
afterAll(() => {
|
||||
|
||||
@@ -87,19 +87,29 @@ const STUB_SETTINGS = {
|
||||
|
||||
const createdDirs = new Set<string>();
|
||||
|
||||
function sleepSync(ms: number): void {
|
||||
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
||||
}
|
||||
|
||||
function cleanupTempDir(dir?: string): void {
|
||||
if (!dir) return;
|
||||
createdDirs.delete(dir);
|
||||
for (let attempt = 1; attempt <= 3; attempt += 1) {
|
||||
for (let attempt = 1; attempt <= 5; attempt += 1) {
|
||||
try {
|
||||
if (!existsSync(dir)) return;
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
return;
|
||||
if (!existsSync(dir)) return;
|
||||
} catch (error) {
|
||||
if (attempt === 3) {
|
||||
if (attempt === 5) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
sleepSync(attempt * 25);
|
||||
}
|
||||
|
||||
if (existsSync(dir)) {
|
||||
throw new Error(`failed to clean temp dir: ${dir}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user