Skip to content

Commit 60b4a31

Browse files
author
Eva
committed
fix: add currentTokenCount to compact() type, use LeafTriggerResult import
- compact() wrapper now includes currentTokenCount in its input type so TS excess-property checks pass and live counts flow through to compactFullSweep - engine.ts evaluateLeafTrigger uses imported LeafTriggerResult type instead of duplicating the shape inline, preventing type drift
1 parent 4f55a37 commit 60b4a31

2 files changed

Lines changed: 3 additions & 15 deletions

File tree

src/compaction.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@ export class CompactionEngine {
556556
tokenBudget: number;
557557
/** LLM call function for summarization */
558558
summarize: CompactionSummarizeFn;
559+
currentTokenCount?: number;
559560
force?: boolean;
560561
hardTrigger?: boolean;
561562
summaryModel?: string;

src/engine.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
pickToolIsError,
2626
pickToolName,
2727
} from "./assembler.js";
28-
import { CompactionEngine, type CompactionConfig } from "./compaction.js";
28+
import { CompactionEngine, type CompactionConfig, type LeafTriggerResult } from "./compaction.js";
2929
import type { LcmConfig } from "./db/config.js";
3030
import { getLcmDbFeatures } from "./db/features.js";
3131
import { runLcmMigrations } from "./db/migration.js";
@@ -2846,20 +2846,7 @@ export class LcmContextEngine implements ContextEngine {
28462846
}
28472847

28482848
/** Evaluate whether incremental leaf compaction should run for a session. */
2849-
async evaluateLeafTrigger(sessionId: string, sessionKey?: string, tokenBudget?: number, liveContextTokens?: number): Promise<{
2850-
shouldCompact: boolean;
2851-
rawTokensOutsideTail: number;
2852-
threshold: number;
2853-
skipReason?: string;
2854-
context?: {
2855-
totalAssembledTokens: number;
2856-
budgetCeiling?: number;
2857-
budgetPressure: boolean;
2858-
estimatedReduction?: number;
2859-
reductionThreshold?: number;
2860-
headroomFactor: number;
2861-
};
2862-
}> {
2849+
async evaluateLeafTrigger(sessionId: string, sessionKey?: string, tokenBudget?: number, liveContextTokens?: number): Promise<LeafTriggerResult> {
28632850
this.ensureMigrated();
28642851
const conversation = await this.conversationStore.getConversationForSession({
28652852
sessionId,

0 commit comments

Comments
 (0)