WOLBΛRG

Compression Pipeline

Summarize and archive memories with an optional LLM via compress().

What is it?

compress() uses a configured LLM to summarize selected memories into a compact record and optionally archive the originals.

Why does it exist?

Long agent histories explode context and storage. Compression keeps signal while shrinking volume.

How does it work?

Requires llm on the constructor (compile-time + runtime):

import { Wolbarg, sqlite, openaiEmbedding, openaiLlm } from "wolbarg";

const ctx = new Wolbarg({
  organization: "my-org",
  storage: sqlite("./memory.db"),
  embedding: openaiEmbedding({ /* … */ }),
  llm: openaiLlm({
    apiKey: process.env.OPENAI_API_KEY!,
    model: "gpt-4.1-mini",
  }),
});

const result = await ctx.compress({
  agent: "research",
  // filter / ids / strategy options per CompressOptions
});

Without llm, TypeScript rejects compress and runtime throws ProviderNotConfiguredError.

When should it be used?

Periodic maintenance jobs, end-of-session summarization, or when agent history exceeds a token budget.

Performance notes

  • Dominated by LLM latency and input size
  • Published mock suite shows high reduction ratios — verify on your own texts
  • Archive carefully if you need reversible history (history() still tracks events)