feat(compaction): add proactive context budget and checkpointing
This commit is contained in:
@@ -15,6 +15,23 @@ export interface CompactionConfig {
|
||||
summaryMaxTokens: number;
|
||||
/** Preserve messages at or above this importance score from compaction. */
|
||||
importanceThreshold: number;
|
||||
/** Optional proactive context usage thresholds and actions. */
|
||||
proactive?: ProactiveCompactionConfig;
|
||||
}
|
||||
|
||||
export interface ProactiveCompactionConfig {
|
||||
/** Enable proactive context warnings/checkpoints before hard compaction cliffs. */
|
||||
enabled: boolean;
|
||||
/** Emit warning signals when usage crosses this percentage. */
|
||||
warnPct: number;
|
||||
/** Save a checkpoint summary to memory when usage crosses this percentage. */
|
||||
checkpointPct: number;
|
||||
/** Auto-run compaction when usage crosses this percentage. */
|
||||
autoCompactPct: number;
|
||||
/** Cooldown window between checkpoint writes. */
|
||||
checkpointCooldownMs: number;
|
||||
/** Memory namespace base for proactive checkpoints. */
|
||||
memoryNamespace: string;
|
||||
}
|
||||
|
||||
export interface CompactionResult {
|
||||
@@ -33,6 +50,14 @@ export const DEFAULT_COMPACTION_CONFIG: CompactionConfig = {
|
||||
keepTurns: 4,
|
||||
summaryMaxTokens: 1024,
|
||||
importanceThreshold: 1,
|
||||
proactive: {
|
||||
enabled: false,
|
||||
warnPct: 75,
|
||||
checkpointPct: 85,
|
||||
autoCompactPct: 95,
|
||||
checkpointCooldownMs: 300_000,
|
||||
memoryNamespace: 'session/checkpoints',
|
||||
},
|
||||
};
|
||||
|
||||
export async function compactHistory(opts: {
|
||||
|
||||
Reference in New Issue
Block a user