The full upstream README, mirrored here for reference. Install config, tool schemas, adoption signals, and an original overview live on the ZenBrain Memory listing page.
The neuroscience-inspired memory system for AI agents.
7 memory layers. Real neuroscience — FSRS, Hebbian, sleep consolidation, emotional tagging, plus 10 advanced research modules (vmPFC-FSRS, two-factor Hebbian, simulation-selection sleep, Fiedler-value KG health, IB budget, Hopfield STM, ...).
Pure TypeScript. Zero dependencies. 528 tests. Extracted from a production AI platform.
Status: pre-1.0, semver — the public API can still change before 1.0.
528 tests green on Node 22, 24 and 26 in CI · every release published to npm with build provenance ·
every change recorded in the CHANGELOG · issues and pull requests get a first response typically within 72 hours.
▶ Try the live playground in your browser — runs this published code, no install required.
Feedback, replications, and counter-results are explicitly welcome — please open an issue or reach out via research@zensation.ai.
Your AI forgets everything after every conversation. ZenBrain fixes that — with the same mechanisms your brain uses: spaced repetition, emotional consolidation, Hebbian strengthening, and exponential forgetting curves. Not a vector database with a wrapper. Actual neuroscience.
Architecture vs. this package. ZenBrain's architecture is 15 neuroscience-inspired mechanisms — 9 foundational algorithms + 6 Predictive Memory Architecture (PMA) components (paper). The 6 PMA components are proprietary and run in the production system. This open-source package ships the algorithm library: 10 core algorithms + 10 advanced research modules (20 modules), zero-dependency.
On LongMemEval-500, ZenBrain wins all nine head-to-head answer-quality comparisons against Letta, Mem0 and A-Mem — three competitors x three LLM judges, under Bonferroni-corrected significance (alpha = 0.05/18, p_min = 6.2e-31, d in [0.18, 0.52]). It reaches 91.3% of a full-context oracle's binary-judge accuracy at 1/106th of the per-query token cost (47.7% vs. 52.2%).
The paper prints where ZenBrain loses as well: on LoCoMo, substring-based aggregate F1 favours lexical retrieval (BM25) by metric design, and we do not contest that. The advantage is most pronounced on judge-graded answer quality and cross-session reasoning.
The mechanism comparison further down re-runs from this repository in under a minute —
bash scripts/compare-mechanisms.sh, no API keys and nothing to install. It prints a positive
and a negative control before the result, so the instrument can be checked before its output
is trusted. The method, the effect sizes and the ablations behind the numbers above are in the
paper; this repository ships no runner for them. The archived packages below run the significance
tests and effect sizes in full, and the mechanism ablation behind paper Tables 7–9.
The raw material behind the numbers above is deposited on Zenodo, open access and citable. Both links are concept DOIs and resolve to the latest version, the same convention this README uses for the paper archive; each description was measured against the version named after it.
verify-against-reference.mjs, which diffs a fresh run against
that reference and exits non-zero on drift. npm install && npm run experiments; the run itself
needs no API keys and no network, and finishes in under a minute on a laptop. Two of the paper's
other ablation tables need data this package does not carry: Table 11 the LoCoMo corpus, Table 13
a different pipeline. The package says so itself.SHA256SUMS.txt covering every file in the package, and the analysis scripts. Three of those
scripts are stdlib-only and self-checking — the oracle comparison behind the 91.3% figure, the
judge-agreement figures, and the real-pipeline flag-ablation table: each prints every re-derived
value next to the reference it has to match, and exits non-zero on mismatch. The significance
tests behind the nine head-to-head comparisons against Letta, Mem0 and A-Mem sit in a separate
script that needs numpy and scipy; it recomputes all eighteen pairwise tests and rewrites the
deposited significance JSON byte-identically, so what catches a mismatch there is the checksum,
not an exit code.Both packages name what they do not cover. Replications and counter-results are welcome: research@zensation.ai.
ZenBrain implements fifteen mechanisms taken from human memory research. No system among those surveyed in the paper integrates more than two of them. The table below records which of the mechanisms appear in the public source of three widely used memory systems, at pinned versions, on a fixed date.
| Mechanism | ZenBrain | Mem0 | Letta | Zep |
|---|---|---|---|---|
| FSRS spaced repetition | yes | — | — | — |
| Hebbian learning | yes | — | — | — |
| Ebbinghaus forgetting curves | yes | — | — | — |
| Sleep consolidation | yes | — | — | — |
| Emotional tagging | yes | — | — | — |
| Zero runtime dependencies | yes | — | — | — |
How this was measured, 27 August 2026. Full-text search over the
checked-out public source of mem0ai/mem0
(npm mem0ai 3.1.7, PyPI mem0ai 2.0.19),
letta-ai/letta-code
(npm @letta-ai/letta-code 0.31.2) and
getzep/zep, lockfiles excluded. A dash means
the term does not occur in that snapshot — not that the system cannot do
something comparable under another name. Dependency counts are declared direct dependencies:
@zensation/core resolves to two packages, both our own; mem0ai
declares four, @letta-ai/letta-code eighteen. Re-run the whole check yourself with
scripts/compare-mechanisms.sh; it
prints its own positive and negative controls so you can see the instrument works before you
trust the result.
Human memory does not work like a key-value store. The brain keeps specialised systems for different kinds of memory, forgets actively, modulates by emotion and retrieves by context. ZenBrain brings those mechanisms to AI agents.
On top of the 10 core algorithms above, @zensation/algorithms ships 10 advanced algorithms grounded in recent neuroscience and ML research. Each is exposed as its own sub-path (@zensation/algorithms/<name>) and remains zero-dependency:
fsrs-vmPFC — Prediction-Error coupled FSRShebbian-two-factor — Two-Factor synaptic consolidationsleep-simulation-selection — RL-based replay selectionspectral-health — Fiedler-value KG health monitorib-budget — Information-Bottleneck retention budgetdopamine-routing · hopfield-stm · personalized-pagerank · surprise-gradient-memory · temporal-multi-routeSee CHANGELOG.md for details.
Requires Node.js 22 or newer (since
0.4.0). On Node 20 or older, npm silently installs the last compatible release (@zensation/algorithms@0.3.4,@zensation/core@0.2.2) instead of the current one — which looks like a broken package but is a platform mismatch. See CHANGELOG.
Each advanced algorithm has its own sub-path (@zensation/algorithms/spectral-health, @zensation/algorithms/ib-budget, …). All zero dependencies.
Five self-contained examples live in examples/:
| Example | Shows |
|---|---|
basic-chatbot.ts | Working Memory + Short-Term Memory for conversation context — no SDK needed |
with-claude.ts | An Anthropic Claude assistant that remembers across conversations |
with-langchain.ts | ZenBrain as the memory backend of a LangChain agent |
with-crewai.ts | Multiple agents sharing Working Memory, with Hebbian strengthening |
with-vercel-ai.ts | A memory-aware system prompt for the Vercel AI SDK streamText pattern |
The integration examples additionally need their respective SDK installed. Want a LlamaIndex.TS or Mastra example? Those are open as good first issues.
Each layer has different retention characteristics, consolidation rules, and retrieval mechanisms — just like the human brain.
FSRS (Free Spaced Repetition Scheduler) outperforms SM-2 by 30%. It uses the desirable difficulty principle: reviewing when retention is low gives a bigger stability boost. Your AI reviews important facts at optimal intervals — never too early (wasteful), never too late (forgotten).
The amygdala modulates memory consolidation — emotional events are remembered more vividly (flashbulb memory). ZenBrain's emotional tagger assigns arousal, valence, and significance scores using a 400+ keyword lexicon (English & German). Emotional memories get up to 3x longer decay half-lives.
"Neurons that fire together wire together" (Hebb, 1949). Knowledge graph edges that are frequently co-activated grow stronger. Unused edges decay and eventually get pruned. The result: a self-organizing knowledge structure that reflects actual usage patterns, with homeostatic normalization to prevent runaway growth.
Ebbinghaus (1885) showed that memory decays exponentially: R = e^(-t/S). ZenBrain implements personalized decay profiles that adapt to individual learning patterns, with SM-2 compatibility for existing spaced repetition systems.
Tulving's Encoding Specificity Principle (1973): memories are recalled better when the retrieval context matches the encoding context. ZenBrain captures temporal context (time of day, day of week) and task type at encoding time, providing up to a 30% retrieval boost when contexts match.
Knowledge isn't isolated — facts support or contradict each other. ZenBrain propagates confidence through your knowledge graph using Bayesian belief updates: supporting evidence increases confidence, contradictions decrease it, with damping for numerical stability.
During sleep, the hippocampus replays recent experiences, strengthening important memories and pruning weak connections (Stickgold & Walker, 2013). ZenBrain simulates this process: selectForReplay() prioritizes emotional and recently-accessed memories, simulateReplay() boosts their stability by 50%, and pruneWeakConnections() removes weak Hebbian edges — implementing the Synaptic Homeostasis Hypothesis (Tononi & Cirelli, 2006).
The MemoryCoordinator orchestrates all 7 layers into a single cohesive system — inspired by Global Workspace Theory (Baars, 1988):
| Package | Description | Status |
|---|---|---|
@zensation/algorithms · source | 20 algorithm modules — 10 core (FSRS, Hebbian, Ebbinghaus, emotional, Bayesian, sleep consolidation, intervals, visualization) + 10 advanced (vmPFC-FSRS, two-factor Hebbian, IB budget, Hopfield STM, …) | :white_check_mark: Published |
@zensation/core · source | Memory layers, coordinator, adapter interfaces | :white_check_mark: Published |
@zensation/adapter-postgres · source | PostgreSQL + pgvector storage adapter | :white_check_mark: Published |
@zensation/adapter-sqlite · source | SQLite storage adapter (zero-config) | :white_check_mark: Published |
@zensation/mcp · source | MCP server — gives any MCP client (Claude Desktop, Claude Code, Cursor) the seven layers as four tools. Carries the protocol SDK, so the core stays dependency-free | :white_check_mark: Published |
@zensation/ai-sdk · source | Vercel AI SDK middleware — recall before the model call, store after it. Works with any provider, zero runtime dependencies | :white_check_mark: Published |
Every algorithm is available as a subpath export:
These aren't toy implementations — ZenBrain's algorithms are extracted from ZenAI, a production AI platform. Everything claimed here is verifiable in this repository:
@zensation/algorithms@0.4.4 tarball published on npmWe welcome contributions! See CONTRIBUTING.md for guidelines. Issues and pull requests get a first response typically within 72 hours.
Resources: API Reference | Recipes | Architecture | Benchmarks | FAQ | Roadmap
ZenBrain's architecture and algorithms are documented in an open-access technical disclosure:
If you use ZenBrain in academic work, please cite:
Apache 2.0 — use it in production, modify it, distribute it. Just keep the attribution.
Built by ZenSation in Kiel, Germany.