feat(compaction): add proactive context budget and checkpointing
This commit is contained in:
@@ -1169,6 +1169,12 @@ describe('configSchema — compaction importance threshold', () => {
|
||||
it('defaults compaction importance threshold to disabled behavior', () => {
|
||||
const result = configSchema.parse(minimalConfig);
|
||||
expect(result.compaction.importance_threshold).toBe(1);
|
||||
expect(result.compaction.proactive.enabled).toBe(false);
|
||||
expect(result.compaction.proactive.warn_pct).toBe(75);
|
||||
expect(result.compaction.proactive.checkpoint_pct).toBe(85);
|
||||
expect(result.compaction.proactive.auto_compact_pct).toBe(95);
|
||||
expect(result.compaction.proactive.checkpoint_cooldown_ms).toBe(300000);
|
||||
expect(result.compaction.proactive.memory_namespace).toBe('session/checkpoints');
|
||||
});
|
||||
|
||||
it('accepts a custom importance threshold', () => {
|
||||
@@ -1176,9 +1182,23 @@ describe('configSchema — compaction importance threshold', () => {
|
||||
...minimalConfig,
|
||||
compaction: {
|
||||
importance_threshold: 0.5,
|
||||
proactive: {
|
||||
enabled: true,
|
||||
warn_pct: 70,
|
||||
checkpoint_pct: 82,
|
||||
auto_compact_pct: 93,
|
||||
checkpoint_cooldown_ms: 120000,
|
||||
memory_namespace: 'notes/checkpoints',
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(result.compaction.importance_threshold).toBe(0.5);
|
||||
expect(result.compaction.proactive.enabled).toBe(true);
|
||||
expect(result.compaction.proactive.warn_pct).toBe(70);
|
||||
expect(result.compaction.proactive.checkpoint_pct).toBe(82);
|
||||
expect(result.compaction.proactive.auto_compact_pct).toBe(93);
|
||||
expect(result.compaction.proactive.checkpoint_cooldown_ms).toBe(120000);
|
||||
expect(result.compaction.proactive.memory_namespace).toBe('notes/checkpoints');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -486,6 +486,14 @@ const compactionSchema = z.object({
|
||||
keep_turns: z.number().min(1).max(50).default(4),
|
||||
summary_max_tokens: z.number().min(128).max(4096).default(1024),
|
||||
importance_threshold: z.number().min(0).max(1).default(1),
|
||||
proactive: z.object({
|
||||
enabled: z.boolean().default(false),
|
||||
warn_pct: z.number().min(10).max(100).default(75),
|
||||
checkpoint_pct: z.number().min(10).max(100).default(85),
|
||||
auto_compact_pct: z.number().min(10).max(100).default(95),
|
||||
checkpoint_cooldown_ms: z.number().min(1000).max(86_400_000).default(300_000),
|
||||
memory_namespace: z.string().default('session/checkpoints'),
|
||||
}).default({}),
|
||||
}).default({});
|
||||
|
||||
const discordSchema = z.object({
|
||||
|
||||
Reference in New Issue
Block a user