In daily use · architecture case study
Hippocampus
A hybrid AI memory engine combining FTS5, exact vector search, rank fusion, diversity selection, typed freshness, and source recovery inside SQLite.
My role Memory architecture, retrieval implementation, consolidation, and operating workflow.
The design question
An AI assistant with no memory starts every conversation from zero. Loading every old conversation solves that problem badly: context becomes expensive, relevant details compete with noise, and the model still has to discover which statements are current.
The real question is narrower and harder: out of everything the system has seen, which few memories belong in front of the agent for this task, and how can the original source remain available when the summary is not enough?
Hippocampus is my answer. It is the memory subsystem inside the Agentic System, built in Python on one SQLite database with two distinct stores and several retrieval stages.
Database counts inspected September 14, 2026. They describe corpus size, not recall accuracy.
Finds exact names, commands, phrases, and file references.
Top 30 candidatesFinds related decisions even when the question uses different words.
sqlite-vec · top 30 candidatesDifferent memories age at different speeds
A reminder to ship today loses urgency quickly. The decision that explains how shipping works can matter years later. Change the age below to see how much weight each memory keeps.
Share of its original recency contribution remaining after 90 days.
Freshness contributes 15% of the default score. Relevance and importance account for the rest.
How the decay is calculated
The freshness multiplier is exp(−age / τ), with age and the type’s time constant (τ) in days. After one time constant, roughly 37% of the original freshness remains. Relevance and importance keep their weights. Retirement is a separate maintenance step.
Two stores in one SQLite file
“What did we decide?” and “What exactly did we say?” lead to different places.
Brain
Returns the decision an agent can act on. Each concise record carries its type, project, tags, importance, creation time, and consolidation state.
Echo
Recovers the original exchange. An explicit transcript search can surface the wording, alternatives, and reasoning behind a stored decision.
When each layer enters a session
- Session start
- A small set of shared operating and communication rules loads every time.
- Task routing
- The subject selects the relevant project guidance, procedures, and skills.
- Memory lookup
- At task start or on request, Brain returns a focused set of records.
- Source lookup
- Echo loads original transcript excerpts when the agent asks for them.
How a query becomes five memories
A filename needs an exact match. A decision phrased in new words needs a meaning match. Brain combines both searches, then discounts repeated answers so one decision can’t fill all five slots.
Inspect all eight retrieval stages
- Embed the question
Brain caches query embeddings in the running process. It uses OpenAI’s text-embedding-3-small with 1,536 dimensions, the same model used for the stored memories.
- Search both indexes
FTS5 ranks literal matches with BM25. The sqlite-vec extension finds the nearest vectors using exact Euclidean distance (L2). Each path returns up to 30 active candidates and can filter by memory tier.
- Combine the lists
Reciprocal rank fusion uses each candidate’s position in both lists with a denominator constant of 60. Brain normalizes the fused scores.
- Recognize task language
Words such as “reminder,” “deadline,” and “next” give tasks and to-dos a small relevance boost.
- Make room for variety
Maximal marginal relevance selects up to ten candidates. It balances relevance (0.65) against similarity to results already selected (0.35).
- Score the shortlist
The default score combines fused relevance (75%), stored importance (10%), and freshness (15%).
- Optionally rerank
The optional Voyage cross-encoder is dormant on this workstation. When configured, its 800 ms timeout, three-failure circuit breaker, five-minute backoff, and daily call cap bound the remote dependency. On failure, Brain keeps its local ordering.
- Return the memories
The default result contains five memories with type, project, date, importance, and score. Source metadata lets the agent inspect a record or look up the original wording in Echo.
How memory stays current
After a working session goes quiet, an hourly watcher reads the new conversation and extracts what a future agent can reuse.
- HourlyRead new workProcess eligible sessions after 30 minutes of inactivity.
- 11:55 p.m.Catch upCheck the same bookmarks again, including active sessions.
- 3:00 a.m.ConsolidateMerge eligible duplicates and retire eligible old tasks.
Schedule shown in workstation time.
Automatic nightly cleanup
At 3 a.m. workstation time, a scheduled job screens eligible memories for possible duplicates. Only memories with a plausible match need an exact neighbor lookup in SQLite.
Recorded nightly run ·
Watermarks, consolidation, and retirement
Each session has a watermark that records the last processed position. The watcher resumes there. SQLite’s write-ahead log allows concurrent readers while new records are written. Echo independently chunks and embeds meaningful messages, including exchanges that yield no curated memory.
Nightly consolidation can merge eligible records within an L2 distance of 0.07. The higher-importance record keeps the merged statement and embedding. Repeated procedures can gain confidence. The retired row leaves vector search, and FTS5 is rebuilt as a consistency check.
Curated rules, architecture, and decisions stay protected. Old tasks and to-dos can retire unless pinned or marked canonical.
What happens when a lookup falls short?
- Keyword index offline
- Vector search can still find related material. Exact identifiers become easier to miss.
- Embedding service offline
- A new semantic query requires an embedding. An uncached query stops here.
- Reranker unavailable
- Brain returns the locally ranked shortlist.
- Answer looks stale
- The agent can follow the source metadata and check the original conversation in Echo.