The problem
An AI assistant with memory usually reads that memory the expensive way. A whole index of notes is
loaded into every session, whatever the question is, and a whole note is read when one line would
have answered it. Every one of those tokens is paid for.
Memory also lets mistakes stick. If an assistant saves whatever it is told, sourced or not, a guess
written down once comes back later looking like a fact.
Why it is hard
- Finding the right note. Handing over less only helps if what is handed over is the right
thing. A wrong pick costs a second lookup and can cost more than loading everything.
- Saving safely. The assistant writes to its own memory. Without rules, duplicates pile up,
old versions overwrite new ones, and unsourced claims sit beside verified ones.
- Measuring honestly. A token saving is easy to overstate by choosing friendly questions or
comparing against an unfair baseline.
What I built
Five tools the assistant calls over MCP:
- recall returns the top three subjects for a question, one line each.
- open returns one subject in full, only when its one line is not enough.
- remember saves or updates a subject, through a gate.
- check returns the exact stored sentences that bear on a claim, or says plainly that memory
has no evidence. It never decides what is true.
- report shows the tokens handed out this session against loading every note whole.
The gate is deterministic, with no AI judgment in it. A summary must fit on one line. A note with no
source is stored but always shown as unverified. A near-duplicate is refused with the name of the
subject it repeats. An update must name the version it replaces, so a stale update is dropped.
The proof
Measured on 116 real working notes with 30 questions asked in everyday wording. Tokens are estimated
at four characters per token, with the same rule on both sides. The baseline loads the full index
once per session.
- Recall accuracy: the right subject came first for 26 of 30 questions (87%), and was in the
top three for all 30.
- One question, summary enough: 134 tokens against 4,589.
- One question, full note needed: 670 tokens against 5,131.
- Three questions: 426 against 4,589 when summaries answer, 2,529 against 6,186 when notes
are needed.
- Tests: 16 checks on made-up notes try to break the gate, the receipts and the MCP protocol,
and all pass.
Anyone can rerun the benchmark on the example notes in the repository, or point it at their own.
What it does not claim
- A long session that opens many full notes costs more than the baseline. At ten note-heavy
questions it used 16,313 tokens against 10,617, because a wrong first pick is opened and paid for.
- Matching is by shared words, not meaning. A question that uses none of a note's words misses it.
The public example set shows this on purpose.
- The 30 questions were written by the same AI that built the tool. A test with questions written by
someone else is still owed.
- Token counts are estimates, not billing figures.
Technologies and skills
- Model Context Protocol over JSON-RPC 2.0 on standard input and output, with no outside packages.
- Node.js with the built-in SQLite, storing subjects in my
kravitz datastore.
- Context and token optimization: summaries first, detail on demand, a per-session token ledger.
- Evaluation: a benchmark that charges every miss and every wrong pick, against a fair baseline.
- AI-assisted engineering with Claude Code. I set the design and the rules; the AI wrote and
tested the code under my direction.
7–34×fewer tokens, short sessions
30/30right note in the top three
16tests, all passing
0outside packages