Benchmark

June 29, 2026 ยท View on GitHub

This report is generated by npm run benchmark (scripts/benchmark.mjs). It runs the real production retrieval and injection functions (retrieveMemories, formatStartupInjection, countTokens) over a curated, synthetic fixture set to measure two things: how much token reduction startup injection provides versus carrying full session history, and the retrieval relevance of the ranker. The benchmark is fully offline and deterministic. deterministicEmbed is hash-based with no network calls and the clock is pinned, so re-running produces a byte-identical report.

Headline: ~85.6% token reduction and a 100.0% retrieval hit-rate across 10 curated queries.

Token reduction

Token counts use the production countTokens (js-tiktoken o200k_base). Two framings are reported; the headline above leads with the stronger one.

FramingBaseline tokens (full history)Injected tokensReduction
(a) Top-3 startup injection vs full history158722885.6%
(b) Per-query injected context (avg) vs full history158723285.4%

Framing (a) measures a single startup injection of the top-ranked memories. Framing (b) averages the injected context across each curated query, modelling the realistic per-turn scenario where only the relevant memories are surfaced.

Retrieval relevance

Each query is run through retrieveMemories (top-3) and the returned ids are compared against a curated set of expected memory ids. A query hits when at least one expected memory appears in the results.

  • Hit-rate: 100.0% (10 queries)
  • Overall recall: 100.0%
  • Overall precision: 33.3%
Query (memory content)Expected memoryRecallPrecision
We chose JWT access tokens with a 15-minute expiry and ro...mem-auth-decision100.0%33.3%
The persistence layer uses better-sqlite3 with WAL mode; ...mem-db-decision100.0%33.3%
Embeddings are computed offline with a deterministic sha2...mem-embed-fact100.0%33.3%
Retrieval ranks candidates by a weighted blend of semanti...mem-retrieval-fact100.0%33.3%
Startup injection formats the top-ranked memories under a...mem-injection-fact100.0%33.3%
Never edit an already-shipped migration file in place; ad...mem-migration-warning100.0%33.3%
Redaction must run on every memory-write path before stor...mem-secret-warning100.0%33.3%
The CLI exposes remember, retention prune, redact-scan, a...mem-cli-fact100.0%33.3%
Tests use vitest; integration specs seed an in-memory dat...mem-testing-fact100.0%33.3%
The MCP server runs over stdio and exposes memory retriev...mem-mcp-decision100.0%33.3%

Relevance interpretation

The offline deterministicEmbed is a hash-based fingerprint: identical text scores a perfect cosine of 1.0, but any wording change collapses the score to noise. It is an exact/near-exact recall embedding, not a fuzzy semantic one. The hit-rate above measures what it actually guarantees: that the ranking pipeline surfaces a memory when the query contains that memory's content (the realistic "recall this fact" case). Fuzzy paraphrase matching requires swapping in a real vector-embedding model; the retrieval and scoring code paths are unchanged by that swap, so this benchmark continues to apply.

Reproducing

npm run build      # benchmark imports built functions from dist/
npm run benchmark  # regenerates this file deterministically

Fixtures are synthetic; the report contains only aggregate metrics and synthetic example content. Generated by scripts/benchmark.mjs.