Added on 11 October 2026. This post describes the state of ZenAI in April 2026. Five of the nine methods are now functions in
@zensation/algorithms(fsrs-vmPFC, sleep-simulation-selection, hebbian-two-factor, ib-budget, spectral-health) that you call yourself; the MemoryCoordinator calls none of them, and the nightly pipeline below is part of ZenAI, not of the open-source packages. #B, #G, #H and #I are not included there. Corrected: a priority claim, a sentence about other systems, and the source given for the prediction-error signal (correction notice of 18 September 2026, §8).
TL;DR
- In April 2026, ZenAI's memory used nine research algorithms, each inspired by published work from neuroscience, information theory or AI research (some of it preprints).
- They include a prediction-error-coupled FSRS-style variant, a two-factor model for graph edges, and a sleep loop that selects what to replay.
- The goal: memory that consolidates, decays and forgets instead of only growing.
- Five of the nine (#A, #C, #D, #E, #F) are open source today in
@zensation/algorithms, zero dependencies, pure TypeScript; #B, #G, #H and #I are not part of the open-source packages.
Updated 26 November 2026: Title and description spoke of “9 Neuroscience Algorithms Behind ZenBrain”. What is meant are the nine research algorithms from ZenAI; the paper counts them as harness mechanisms, not as its nine foundational algorithms (how we count).
Most AI systems forget everything the moment a conversation ends.
That's not a bug — it's a design choice. But it's the wrong one. Knowledge workers don't think in isolated sessions. They build context over weeks, revisit half-formed ideas, connect a meeting from Tuesday with a document from last month.
So when we built ZenBrain — the open-source memory system at the core of ZenAI — we decided not to paper over this problem with longer context windows or naive vector search. We went deeper.
We read the neuroscience.
Why Neuroscience?
The human brain has been solving the "what to remember, what to forget, and when to retrieve it" problem for 300 million years. It does this with remarkable efficiency — not by storing everything, but by selectively consolidating, linking, and decaying information based on relevance and use.
Modern AI memory systems mostly use one of three approaches: RAG (dump everything into a vector DB), fine-tuning (bake knowledge into weights), or naive key-value stores. All three have serious limitations for long-running personal AI.
We implemented 9 algorithms, each inspired by published work from neuroscience, information theory or AI research (some of it preprints), that work together as a coherent memory architecture.
The Nine Research Algorithms
During Conversation (Active, Real-Time)
#A — vmPFC Prediction-Error Coupled FSRS Own construction; inspired by Zou et al., Cell Reports 2025 (7T fMRI study)
Standard spaced repetition systems (Anki, FSRS-5, SuperMemo) schedule reviews based on recall history. But a 2025 fMRI study found that the vmPFC encodes re-encoding similarity, and this signal, not repetition count, drives which memories get strengthened.
We couple a prediction-error signal of our own to our FSRS-style scheduler: how far an item's embedding has shifted since the last review. When your knowledge graph shows high PE at review time (the information surprised you), the interval shortens, the ideal learning window. Low PE means the information was expected; extend the interval. The Zou et al. study describes re-encoding similarity, not a prediction-error signal; it is the inspiration, not the source of this signal.
#B — Compositional Context Embeddings Nature 2025 (Compositional PFC) + bioRxiv 2025 (Orthogonal Neural Codes)
ZenAI has 4 contexts: personal, work, learning, creative. The naive approach is to completely isolate them. But that means insights from your learning context can never inform work — exactly what a human brain does do.
The neuroscience shows that prefrontal cortex encodes different task contexts in orthogonal neural subspaces — separate but not hermetically sealed. We implement this as:
h(context, memory) = P_shared × embedding + Q_context × context_code
where P^T × Q = 0 (mathematical orthogonality). Cross-context transfer is permitted through the shared subspace; contamination is blocked by the orthogonal context codes.
#G — iMAD Selective Debate Protocol arXiv 2511.11306, Nov 2025
Multi-Agent Debate (MAD) improves AI answer quality, but it's expensive — you're running the same query through multiple models and synthesizing. We implemented a selective trigger: a single agent first generates self-critique and hesitation features (confidence gap, hedging language, detected contradictions). A lightweight classifier decides whether to escalate to full debate or accept the initial response.
Debate only happens when it's actually needed.
Correction, 15 November 2026: In the production system, no code beyond its own two files calls the iMAD module (version 9 of the paper, arXiv:2604.23878v4). In the paper's ablation it is a constant factor.
#H — Metacognitive HyperAgent arXiv 2603.19461, Meta AI, March 2026
This one is recursive. The system doesn't just improve task performance — it improves the improvement mechanism itself. The Metacognitive HyperAgent analyzes strategy performance patterns, generates meta-insights about its own reasoning, and proposes structural changes to how it approaches future tasks.
Budget-constrained to max 3 meta-improvements per day with governance-layer approval requirements. Unbounded self-modification is how you get misaligned systems; bounded meta-cognition with human-in-the-loop is how you get trustworthy ones.
Correction, 15 November 2026: In the production system, the daily run passes the HyperAgent one attempt per strategy, while the agent only evaluates strategies with at least five. It therefore reports no improvement (version 9 of the paper).
During Sleep (Nightly Consolidation Pipeline)
Every night, when the system is idle, a BullMQ job triggers a 5-stage consolidation pipeline that runs the remaining 5 algorithms in sequence.
#C — Simulation-Selection Sleep Loop Frontiers in Computational Neuroscience 2025
Inspired by hippocampal replay during sleep. Stage 1 (CA3-analog): generate diverse replay candidates from the episodic buffer, including counterfactual variations of failed interactions. Stage 2 (CA1-analog): score candidates using:
Tag(episode) = α × |TD_error| + β × Reward + γ × Novelty
High-scoring replays receive LTP (Long-Term Potentiation — strengthening). Low-scoring replays receive LTD (Long-Term Depression — decay). The system literally replays its day and decides what mattered.
#D — Two-Factor Synaptic Model Own construction; related work: Iatropoulos, Gerstner & Brea, PNAS 2025
Standard Knowledge Graph edges have a single weight. We extended them to (weight, variance) pairs. Variance decreases with activation frequency — an edge you've traversed 100 times has low variance (mature, stable). An edge you've traversed twice has high variance (uncertain).
The importance score 1/variance stands in for the Fisher information in an EWC-style penalty (Elastic Weight Consolidation, a continual learning technique that counters catastrophic forgetting by protecting mature connections). Well-established knowledge becomes harder to overwrite, but it is not locked.
#F — Context-Adaptive Information Bottleneck Budget MemFly, February 2026 (Information Bottleneck)
Information Bottleneck theory gives us a formal way to decide what to compress: retain if I(Z;Y) × β > I(X;Z). The β parameter controls the relevance/compression tradeoff.
We made β context-dependent:
| Context | β | Philosophy |
|---|---|---|
| Work | 0.8 | Retain anything potentially relevant |
| Learning | 0.6 | Balanced — compression creates abstraction |
| Personal | 0.4 | Forgetting irrelevant data is a feature |
| Creative | 0.3 | Maximum compression to pure concepts |
#I — Dual-Process CoT Consolidation arXiv July 2025 (Dual-Process Compositional Learning)
Chain-of-Thought reasoning produces valuable intermediate steps that are usually discarded after the response. We formalized the path from CoT to persistent knowledge:
- Phase 1 (Hippocampal): successful reasoning chains → episodic memory (high fidelity, exact)
- Phase 2 (Cortical, during sleep): abstract successful chains → schema nodes in the Knowledge Graph
- Failed chains remain episodic for potential replay and learning (see #C)
This implements the hippocampus-to-cortex transfer model: fast binding first, slow cortical consolidation later.
#E — Spectral KG Health Monitor Algebraic graph theory (Fiedler value)
After each sleep cycle, we check: did consolidation make the Knowledge Graph healthier or more fragmented? We use the algebraic connectivity (Fiedler value, λ₂) of the Graph Laplacian L = D - A.
Rising λ₂ after sleep = successful consolidation (graph is better connected). Falling λ₂ = fragmentation alert — the system over-pruned or created disconnected components. This gives us an objective, mathematically-grounded quality metric for memory health.
How It All Fits Together
Conversation
├── #A vmPFC-FSRS → when to review this memory
├── #B Compositional → which context subspace
├── #G iMAD → is debate needed?
└── #H HyperAgent → bounded self-improvement
Night (Sleep Pipeline)
├── Stage 1: #C Simulate + select replays
├── Stage 2: #D Two-factor synaptic consolidation
├── Stage 3: #F IB Budget filter per context
├── Stage 4: #I Abstract CoT chains to KG schemas
└── Stage 5: #E Spectral health check (Fiedler value)
Every algorithm is registered in an ablation toggle registry for controlled experiments. Each can be independently disabled to measure its contribution — a requirement for any rigorous benchmark publication.
What Makes This Different
Idle-time consolidation is pursued elsewhere too, for example as “dreaming” in Letta Code. In ZenBrain the work splits across four levels:
- Encoding: the MemoryCoordinator picks the layer on store by content, emotional weight and confidence
- Consolidation:
consolidate()turns emotionally weighted episodes into facts, once each; replay and two-factor edges are functions in@zensation/algorithms - Retrieval: recall searches up to five layers, by vector similarity with an embedding provider and lexically without one
- Forgetting: on request with
forget(); the retention budget and decay curves are functions in the library
Controlled forgetting is not a weakness. It's the feature that makes the rest work.
Open Source
ZenBrain is Apache-2.0-licensed and published on npm; @zensation/algorithms has no runtime dependencies, the storage adapters bring their database driver:
npm install @zensation/algorithms @zensation/core
# PostgreSQL adapter
npm install @zensation/adapter-postgres
# SQLite (zero-config)
npm install @zensation/adapter-sqlite
- GitHub: github.com/zensation-ai/zenbrain
- Zenodo DOI (citable): 10.5281/zenodo.19353663
- HuggingFace: huggingface.co/zensation-ai/zenbrain
The paper is on arXiv and Zenodo; five of the nine algorithms are implemented in the repository (packages/algorithms). We're building in public. Questions, critiques, and collaboration welcome.
Update April 2026 — Addendum: how the paper counts. When this post was written, the 9 foundational algorithms described the full stack. In the ZenBrain paper we added a second wave: the Predictive Memory Architecture (PMA) with 6 additional components — NeuromodulatorEngine (DA / NE / 5-HT / ACh dynamics), ReconsolidationEngine (PE-gated memory updates with rollback), TripleCopyMemory (Fast / Medium / Deep divergent decay), PriorityMap (amygdala fast-path), StabilityProtector (NogoA / HDAC3 analog), MetacognitiveMonitor (bias detection). The nine methods in this post are not the same as the paper's nine foundational algorithms (the paper's nine include FSRS-style scheduling, Hebbian learning, sleep consolidation and Bayesian confidence). The six PMA components are described in the paper and are not part of the open-source packages. A dedicated post: Predictive Memory Architecture.
Want to go deeper? Read our post on the 7-Layer Memory Architecture or the Science Behind ZenBrain.