Core API

compress()

Summarize related memories into one compressed memory.

Signature

typescripttypescript
await ctx.compress(options: CompressOptions): Promise<CompressResult>

Behavior

  1. Loads active memories for the agent
  2. Asks the configured LLM for a concise summary
  3. Stores the summary as a new memory
  4. Archives originals and records lineage

Example

typescripttypescript
const { summary, archivedIds } = await ctx.compress({
  agent: "research",
  limit: 50,
});

console.log(summary.content.text);
console.log(archivedIds);

Notes