« All posts

rememori: A Zero-Dependency TypeScript Memory Engine for AI Agents

rememori is a zero-dependency TypeScript library giving AI agents persistent memory by combining cosine similarity, entity graphs and time decay.

rememori is an embedded, zero-runtime-dependency TypeScript library that gives AI agents memory across sessions without standing up a vector database or separate service. Its entire API boils down to three verbs — remember, recall, forget — and the embedder is abstracted behind an interface, letting the same engine run in Node, Bun, or entirely inside a browser tab via transformers.js.

The core insight is that plain cosine similarity makes a poor memory system: it ignores time and misses queries about specific people or projects when phrasing differs. rememori's recall score therefore combines cosine similarity with an entity-overlap bonus (from a bipartite memory-to-entity graph built at write time), a user-set importance weight, and an optional time-decay half-life — so memories about the right person or project can surface even with weak textual similarity, and older memories fade unless reinforced.

Storage is handled via pluggable adapters: an append-only, crash-safe JSONL log for Node/Bun, and IndexedDB in the browser, which conveniently stores Float32Array vectors natively through structured clone. To scale past small memory sets, the project added a pure-TypeScript HNSW index — and hit an instructive benchmarking pitfall along the way: uniform random high-dimensional test vectors produced near-random recall, not because the index was broken, but because such data lacks the neighborhood structure real embeddings have. Once benchmarked with realistic, structured vectors, HNSW delivered full recall with far lower latency at scale, while exact scanning remained the better choice for small or tag-filtered memory sets.

» SourceDev.to