Class SessionSummarizer

LLM-backed session summarizer with a persistent on-disk cache.

Example

const summarizer = new SessionSummarizer({
invoker: async (system, user) => {
const resp = await reader.invoke({ system, user, maxTokens: 140, temperature: 0 });
return { text: resp.text, tokensIn: resp.tokensIn, tokensOut: resp.tokensOut, model: resp.model };
},
cacheDir: '/path/to/data/.session-summary-cache',
modelId: 'gpt-5-mini',
});

const summary = await summarizer.summarize('conv-26-session-3', sessionText);
// => "User discussed adopting a new rescue dog from a Portland shelter..."

Constructors

Methods

  • Summarize a single session. Returns cached result if available, otherwise calls the LLM and writes to cache.

    Parameters

    • _sessionKey: string

      — a stable identifier for the session (e.g. ${caseId}:${sessionId}). Used only for logging; the cache key is content-addressed.

    • sessionText: string

      — the raw text of the session (all turns concatenated).

    Returns Promise<string>

Properties

stats: SummarizerStats = ...

Running stats for diagnostics.