The science behind ZenBrain

9 foundational algorithms and 6 PMA components across 7 memory layers. Open-access preprint on arXiv. All documented.

Alexander Bering, Principal Investigator

“Memory is not storage — it is a living process of forgetting, consolidation, and rediscovery. We translated this process into software.”

— Alexander Bering

Published research

Our technical paper is publicly available as an open-access preprint on Zenodo and arXiv, with a defensive disclosure on Elsevier TDCommons.

PreprintOpen Access

ZenBrain: A Neuroscience-Inspired 7-Layer Memory Architecture for Autonomous AI Systems

Alexander Bering — ZenSation AI, Kiel, Germany

ZenBrain is a seven-layer, neuroscience-derived architecture for agent memory in LLM agents. An open library holds the seven layers, a MemoryCoordinator and nine foundational algorithms; six Predictive Memory Architecture components (NeuromodulatorEngine, ReconsolidationEngine, TripleCopyMemory, PriorityMap, StabilityProtector, MetacognitiveMonitor) run in a private production system. Ablating one component at a time in a simulation harness exposes an effect we call cooperative masking: under moderate load, fourteen of the fifteen ablations look costless; under heavier load, with no change to the components, ten of the fifteen move in the same direction on all ten seeds — a caution we conjecture applies beyond ZenBrain. On LongMemEval-S (500 questions), the evaluated ZenBrain arm, a Python port of a scoring class from our test harness and not the seven-layer system, answers 47.7 % of the questions correctly (95 % interval [43.3, 52.1]); with repaired adapters, Letta reaches 48.4 % and Mem0 47.2 %. It reaches 91.3 % of a full-context baseline’s accuracy (52.2 %; its answer model reads the question’s entire history) with 1/109.7 of its input tokens in the answer step; building the memory is not counted. Of nine head-to-head comparisons of the retrieved context (3 competitors × 3 LLM judges), three hold at Bonferroni-corrected significance, all against A-Mem, and the remaining six, against Letta and Mem0, show no significant difference; there the point estimates lean to the competitor. This version corrects version 8 after a post-publication audit. Open source under the @zensation npm scope, Apache-2.0.

Version 9 (31 October 2026): Zenodo 10.5281/zenodo.23832288; arXiv:2604.23878.

Download PDF

Architecture

One architecture, many applications

ZenBrain is our open-source memory core. Multiple applications build on it — the same seven-layer architecture, only the domain adaptation varies.

EigenraumAI workspaceCrowdGuardSafety in public spacesYour own applicationson the open-source coreResearch partnersdomain-adaptableZenBrain7-LAYER MEMORY

Memory layers

  1. Working
  2. Short-Term
  3. Episodic
  4. Semantic
  5. Procedural
  6. Core
  7. Cross-Context
The architecture is designed domain-agnostically. Research partnerships, public-sector cooperations, and industrial applications can build on this open-source core without modifying it.

Counting

How we count

Three numbers from the paper count three different things: the building blocks of the architecture, the components of the ablation and the head-to-head comparisons of the benchmark. Version 9 separates them explicitly (corrections 15 and 16).

Architecture

Seven memory layers, one coordinator (MemoryCoordinator) and nine foundational algorithms in the open library @zensation/algorithms: Ebbinghaus decay, FSRS-style scheduling, Hebbian co-activation, sleep consolidation, Bayesian confidence propagation, emotional tagging, context retrieval, similarity and visualization. Six Predictive Memory Architecture (PMA) components run in the private production system. Algorithms and PMA components are different kinds of building blocks and do not add up to one number.

Source: version 9, abstract and introduction

Ablation

The ablation switches off fifteen components one at a time: the six PMA components and nine mechanisms of the evaluation harness, which run there as stand-ins at simulated values, not as production code. Three of the nine share a name with architecture modules (Hebbian, sleep, FSRS-style scheduling) but are different implementations.

Source: version 9, abstract and caption of the architecture figure

Benchmark (LongMemEval_S, 500 questions)

Of nine head-to-head comparisons of the retrieved context (three competitors, three LLM judges each), three hold at Bonferroni-corrected significance, all against A-Mem; the six against Letta and Mem0 show no significant difference. The evaluated ZenBrain arm, a Python port of a scoring class from our test harness, answers 47.7 % of the questions correctly [43.3, 52.1]. With their adapters repaired, Letta reaches 48.4 % and Mem0 47.2 %. ZenBrain thus reaches 91.3 % of the accuracy of a full-context baseline (52.2 %; its answer model reads the entire history) with 1/109.7 of its input tokens in the answer step.

Source: version 9, abstract

All three statements are in version 9 of the paper (arXiv:2604.23878v4; Zenodo 10.5281/zenodo.23832288).

Eight innovations, shipped as one system

Eight technologies shipped together in ZenAI in this combination.

Sleep Consolidation Engine

Idle-time memory consolidation, run in production in ZenAI — inspired by hippocampal replay (Stickgold & Walker 2013). Weak connections are pruned, stable ones strengthened.

Idle-time consolidation is pursued elsewhere too, for example as “dreaming” in Letta Code. The zenbrain module selects memories for replay by access frequency, emotional weight and recency.

Source: zenbrain (opens in new tab)

7-Layer Memory Coordinator

Unified orchestrator that creates seven memory layers and works on five of them — from working memory to core memory. Based on Global Workspace Theory (Baars 1988).

Seven layers as classes of their own in @zensation/core, from Working Memory to Cross-Context Memory, behind one API.

Source: zenbrain (opens in new tab)

A-RAG (Autonomous Retrieval Agent)

Meta-agent that creates retrieval plans before any search is executed. Heuristic-first with LLM fallback, max 4 dependent steps.

A dedicated planning layer ahead of retrieval, with a heuristic gate: simple queries never reach the planner and cost no LLM call.

Source: ZenAI snapshot (8 May 2026) (opens in new tab)

Multi-Agent Debate Protocol

Structured 3-round debate protocol when agents disagree. Challenge → Response → Resolution with automatic escalation.

After three rounds without consensus the protocol escalates to a human instead of computing a majority.

Source: ZenAI snapshot (8 May 2026) (opens in new tab)

Curiosity Engine

Automatic knowledge gap detection with quantified gap score. Analyzes query history, fact density, and confidence — recommends targeted actions.

Gap detection runs on its own and proposes actions rather than waiting for a question. Inspired by Loewenstein's information gap theory (1994).

Source: ZenAI snapshot (8 May 2026) (opens in new tab)

Prediction Engine

User intent prediction from temporal and sequential patterns. Learns from prediction errors — the more often wrong, the better the next prediction.

Prediction runs inside the memory layer itself, from behavioural patterns.

Source: ZenAI snapshot (8 May 2026) (opens in new tab)

HyperAgent L0–L2

3-level recursive self-improvement with formal safety bounds. Level 0 optimizes knowledge, Level 1 optimizes Level-0 strategies, Level 2 optimizes Level-1 parameters.

3-level recursion with immutable core properties, daily budgets, and automatic rollback on quality regression: self-improvement runs only inside those bounds.

Source: ZenAI snapshot (8 May 2026) (opens in new tab)

Cross-Context Entity Merging

Detection and merging of entities across 4 isolated contexts (Operations, Finance, People, Strategy). Bayesian confidence updates on conflicts.

Entity identity is tracked across isolated contexts: at a similarity of 0.95 or more, entities are linked automatically; between 0.85 and 0.95 they are flagged for review.

Source: ZenAI snapshot (8 May 2026) (opens in new tab)

Explore the system interactively

An accessible, interactive depiction of the memory-based system — from the 7-layer memory and its neuroscience inspiration to how the agents work together. With a toggle between plain-language and technical explanations.

The idea in one sentence: collective intelligence on a cognitive architecture — humans and machines together, on a structure that keeps knowledge. The explorer below makes exactly that architecture tangible.

Open in full screen ↗

These mechanisms run for real — run the open library live →

Interactive depiction · best viewed on desktop

The principle behind the quality imperative

A working system sits on a narrow edge. Change the survival rule step by step and watch the grid collapse, carry structure, or clog — live. Most rules fail; only a narrow band holds.

Why quality is not optional for us: the very efficiency that makes a system valuable amplifies every rule you give it — for better and for worse.

Open full screen ↗

The full story — why quality is not optional →

Interactive · click the neighbour counts on or off · best on desktop

Seven layers of memory, grounded in neuroscience

The HiMeS architecture, inspired by the Atkinson-Shiffrin model (1968) and modern cognitive science.

↑↓1Working Memory2Short-Term Memory3Episodic4Semantic5Procedural6Core Memory7Cross-Context
Seven differentiated memory layers operating as a coherent system — modeled on the Atkinson-Shiffrin framework and contemporary cognitive neuroscience.
1

Working Memory

Active focus — 7±2 items per Miller's Magical Number. Fastest access, shortest lifespan.

2026
2

Short-Term Memory

Session context and conversation continuity. Survives the current session.

2026
3

Episodic

Concrete experiences with emotional tagging. 400+ keyword lexicon (DE+EN) for arousal/valence scoring.

2026
4

Semantic

Factual knowledge with FSRS-style scheduling. Spaced repetition plans when a fact is reviewed next.

2026
5

Procedural

Workflows and skills. Tool chains are analyzed and optimized.

2026
6

Core Memory

Immutable foundations following the Letta pattern. Pinned facts that are never forgotten.

2026
7

Cross-Context

Knowledge and entities linked across isolated contexts — with Bayesian confidence updates on conflict.

2026

Mechanisms Inspired by Neuroscience

FSRS-style Spaced Repetition

open-spaced-repetition/fsrs4anki

Optimal review timing at ~90% target retention

Ebbinghaus Forgetting Curve

Ebbinghaus (1885)

Exponential decay with configurable half-life

Hebbian Learning

Hebb (1949)

Co-activated facts strengthen connections (×1.09/activation)

Homeostatic Normalization

Turrigiano (2004)

Prevents runaway growth of edge weights

Sleep Consolidation

Stickgold & Walker (2013)

Hippocampal replay with +50% stability boost

Synaptic Homeostasis

Tononi & Cirelli (2006)

Weak connections pruned during sleep

Emotional Modulation

LeDoux (1996)

Emotional memories decay 2.7× slower

Bayesian Propagation

Pearl (1988)

Confidence updates across the entire knowledge graph

Global Workspace Theory

Baars (1988)

Conscious access through competitive context assembly

Information Gain Scoring

Shannon (1948)

Entropy-based prioritization of new facts

Knowledge Gap Theory

Loewenstein (1994)

Systematic detection of missing knowledge

Working Memory Capacity

Miller (1956)

7±2 active items in working memory

Neuromodulation (PMA)

Schultz (1997) · Aston-Jones (2005)

Dopamine, NE, 5-HT, ACh — four channels with tonic + phasic dynamics

Reconsolidation (PMA)

Nader (2000) · Schiller (2010)

Memory destabilizes on retrieval — four PE-gated update modes with rollback

Triple-Copy Memory (PMA)

Squire & Bayley (2007)

Three traces with divergent dynamics: fast (4h), medium (14d), deep (logarithmic)

Intelligent knowledge retrieval

6 strategies, dynamically selected per query. Not one pipeline — an adaptive system.

End-to-end RAG pipeline

01Query02A-RAG Plan03HyDE04Vector Search05Cross-Encoder06Confidence07Answer
Query
A-RAG Plan
HyDE
Vector Search
Cross-Encoder
Confidence
Answer

↻ Self-RAG Critique: loops back if confidence < 0.5

A-RAG Planning

Meta-agent plans retrieval steps before execution. Heuristic-first, LLM fallback.

GraphRAG 3-Layer

Event subgraph + semantic graph + community summaries. 5 parallel strategies.

Self-RAG Critique

Automatic reformulation at confidence < 0.5. 4-component scoring.

HyDE Retrieval

Hypothetical answer → embedding → search. Auto-detection with 5s timeout.

Contextual Retrieval

Chunk enrichment per Anthropic method. +67% retrieval accuracy.

Embedding Drift Detection

BullMQ worker monitors drift >10%. Automatic cache invalidation.

Autonomous agents with safety bounds

Multi-agent orchestration with structured debate, dynamic team composition, and recursive self-improvement.

Multi-agent team architecture

HyperAgent L0–L2recursive self-improvementDebate Protocol3 rounds: challenge → response → resolveOrchestratorPersistent Loopspause · resume · cancelResearcherWriterReviewerCoder
Orchestratorrecursive self-improvement · pause · resume · cancel
Researcher
Writer
Reviewer
Coder

3 rounds: challenge → response → resolve

Debate Protocol

3-round debate on disagreement. Challenge → Response → Resolution.

Dynamic Team Builder

5 specialist agents, automatically composed by task type.

HyperAgent L0–L2

Recursive self-improvement with daily budgets, sandbox tests, and auto-rollback.

Persistent Agent Loops

Pause/resume with state checkpointing. Long-running tasks over days.

A2A Protocol

Agent-to-agent communication per Google standard. /.well-known/agent.json discovery.

Implicit Feedback

Automatic behavior detection without explicit labeling.

AI that thinks about thinking

Curiosity, prediction, metacognition — three pillars of cognitive intelligence.

Curiosity Engine

Quantified gap score: query frequency × fact density × confidence × RAG quality.

Prediction Engine

Temporal + sequential pattern recognition. Learns from prediction errors.

Metacognition

Confidence calibration, confusion detection, capability profiling.

Adaptive Thinking

4-tier thinking budgets: 1K→16K→64K→128K tokens. Auto-detection.

91.3% of the accuracy with 1/109.7 of the input tokens in the answer step

On LongMemEval-500, the measured ZenBrain arm (per the correction notice a Python port of a test-harness class, not the seven-layer system) reaches 91.3% of the accuracy of a full-context comparison arm (whose answer model reads the whole history) with 1/109.7 of its input tokens in the answer step.

In our own measurements on LongMemEval-500, three of nine pairwise comparisons hold, all three against A-Mem, significant under Bonferroni correction, across three independent LLM judges. The six against Letta and Mem0 show no significant difference, judged at equal evidence depth and under version-matched judges.

Open and reproducible

ZenBrain is open source. All algorithms, all tests, all documentation — openly available.

Frequently asked questions about the architecture

What makes ZenBrain different from a vector store?

A vector store searches for similarity in a flat index. ZenBrain models memory as a process: what is used repeatedly consolidates, what is left alone becomes harder to recall. Seven layers separate working memory, episodic, semantic and procedural knowledge, and a consolidation phase at rest condenses experience into knowledge. The difference shows where context has to hold for weeks rather than for one conversation.

Why seven layers instead of one?

Because different kinds of memory need different rules. Working memory has to be fast and volatile, semantic knowledge durable and condensed, procedural memory retrievable without deliberate search. Each layer carries its own decay and consolidation logic; on top of that come nine foundational algorithms and six components of a predictive architecture.

Are the algorithms actually grounded in neuroscience?

They draw on memory research, not on an analogy, and the paper names the sources: among them FSRS for spacing intervals, Hebbian learning, the Ebbinghaus forgetting curve, Bayesian confidence propagation and sleep consolidation. The two-factor synaptic model and the vmPFC prediction-error coupling go back to neuroscience work (Iatropoulos, Gerstner and Brea 2025; Zou et al. 2025); the concrete form — weight plus consolidation variance, the prediction-error signal — is our own construction.

How does ZenBrain compare to other open memory systems?

On LongMemEval-500, at equal evidence depth and judged by three independent LLM judges, three of nine head-to-head comparisons hold for ZenBrain, all three against A-Mem. The remaining six, against Letta and Mem0, show no significant difference. All nine contrasts are Bonferroni-corrected and judged under version-matched judges. The measured ZenBrain arm (per the correction notice a Python port of a test-harness class, not the seven-layer system) reaches 91.3 percent of the accuracy of a full-context comparison arm (whose answer model reads the whole history) with 1/109.7 of its input tokens in the answer step.

Can I verify the results myself?

Yes, and that is the point. The memory core is open under Apache 2.0, the publications carry DOIs on Zenodo, and the benchmark page gives every figure its method, source and verification path. Anyone who doubts a number should be able to recompute it without asking us.

Is the paper peer-reviewed?

The preprint itself (arXiv:2604.23878) is not peer-reviewed. The neuroscience it builds on is. We state that plainly, because the distinction matters — and because open evidence has to carry a claim, not a reference to a process.