When to compress
- An agent has many overlapping notes on one topic
- You want a durable summary without losing lineage
- Recall quality drops due to fragmented memories
How it works
Compression uses your configured LLM, stores a new summary memory, and archives the sources. History preserves the relationship.
Example
typescripttypescript
const result = await ctx.compress({ agent: "research" });
console.log(result.summary.content.text);
const lineage = await ctx.history({ id: result.archivedIds[0]! });
console.log(lineage.memory.compressedInto);