Synthetic cognition infrastructure for AI agents.
Memory that thinks. Not a vector database. Not a RAG pipeline. A cognitive architecture with learning, consolidation, decay, emotion, and reconsolidation, grounded in computational neuroscience.
Every AI agent has the same problem: they forget.
You can stuff context into a prompt. You can store vectors in a database and retrieve the top-K nearest neighbors. You can append conversation history until you hit the token limit and then summarize it into something that loses half the meaning. The entire industry is building elaborate workarounds for a fundamental architectural failure: AI agents don't have memory. They have search.
Memory is not search. Memory is a living system. It strengthens what matters, forgets what doesn't, consolidates patterns while you sleep, and updates beliefs when new evidence arrives. Your brain doesn't store a flat log of everything that happened to you. It builds a weighted, emotional, associative network that changes every time you access it.
That's what CORTEX is. Not a retrieval layer. A cognitive architecture.
I built this because I spent two years watching AI agents lose their minds every time a context window rolled over. I'd build something brilliant with an agent on Monday, and by Wednesday it was asking me the same questions like we'd never met. The tools existed to store information, but nothing existed to actually remember. To know what mattered. To notice when something contradicted what it already believed. To get better at things over time instead of starting from zero every session.
So I stopped looking for the tool and built the system. I went back to the neuroscience. Not as a metaphor, not as marketing language, but as an engineering blueprint. The hippocampus separates similar patterns so you don't confuse yesterday's meeting with last week's. The CA1 region detects novelty by comparing what arrived against what it predicted. Memories consolidate during sleep through a two-phase cycle that prunes the noise, strengthens the signal, and occasionally surfaces connections you never would have made while awake. Emotional experiences resist forgetting. Retrieved memories become temporarily malleable, so beliefs can be corrected instead of just appended.
All of this is in CORTEX. Running. In production. Powering a fleet of agents — each carrying 5,000+ active memories and 1.9 million+ synaptic connections on average — through 6+ months of uninterrupted nightly dream cycles and a 0.00 identity drift score that means the agents wake up the same people they were when they went to sleep.
This is what I think AI memory should look like. Now it's yours.
Atanasio Juarez, Founder, ATERNA.AI
| Status | Running in production, v2.4, 6+ months |
| Scale | 5,000+ active memories · 1.9M+ synapses avg per agent |
| Benchmarks | 500/500 LongMemEval · 93.6% R@10 LoCoMo — zero LLM reranking |
| Science | Neuroscience references — hippocampal indexing, CA3 autoassociative recall, reconsolidation, Ebbinghaus stability |
| License | Apache 2.0 |
| Language | TypeScript (Node 22+) · Python port · Zero-config SQLite version |
| Agents | Any MCP client (Claude Code, Cursor, Windsurf) · REST API for everything else |
Most agent memory systems store and retrieve. CORTEX learns.
| Feature | Vector DBs | RAG Pipelines | CORTEX |
|---|---|---|---|
| Store memories | Yes | Yes | Yes |
| Semantic search | Yes | Yes | Yes |
| Temporal validity (when was this true?) | No | No | Yes |
| Novelty detection (is this actually new?) | No | No | Yes |
| Memory consolidation (dream cycles) | No | No | Yes |
| Emotional weighting (what matters?) | No | No | Yes |
| Belief reconsolidation (update, don't append) | No | No | Yes |
| Adaptive forgetting (prune what doesn't matter) | No | No | Yes |
| Pattern separation (don't confuse similar memories) | No | No | Yes |
| Procedural learning (skills improve with practice) | No | No | Yes |
Ingestion Pipeline
|
chunk -> embed -> entities -> valence
|
Hippocampal Encoding
| |
DG (separate) CA1 (novelty)
| |
Sparse codes Surprise gating
|
Memory Storage
(PostgreSQL + pgvector)
|
+-----------+-----------+
| | |
Search Recall Reconsolidate
(hybrid 7-factor) (token-budget) (labile window)
| | |
+-----------+-----------+
|
Dream Cycle (nightly)
| | | | |
Resonance Prune Consolidate Associate Synthesize
(SWS) (SWS) (SWS) (REM) (REM)
Hippocampus. Pattern separation via Dentate Gyrus sparse coding (4096-dim expansion, 5% sparsity), CA1 novelty detection with sparse gating, CA3 autoassociative pattern completion. Two similar inputs that would confuse a cosine search get pushed apart into distinct sparse representations. This is how CORTEX avoids the "every Tuesday meeting looks the same" problem.
Dream Cycle. Five-phase synthetic sleep. Resonance decay (Ebbinghaus stability-adjusted), adaptive pruning (percentile-based, not hardcoded thresholds), cluster consolidation with LLM-generated abstractive summaries, free association via random activation, and synthesis of novel insights from newly formed connections. Runs nightly. Your agent wakes up smarter than it went to sleep.
Emotional Valence. Six-dimensional emotional vectors (valence, arousal, dominance, certainty, relevance, urgency) attached to every memory. Emotionally charged memories resist pruning and get boosted during recall. Because what matters should be harder to forget.
Reconsolidation. When a memory is retrieved, it enters a labile window where it can be updated with new information. The old version gets timestamped (valid_until) and the updated version gets marked as current (valid_from). Beliefs evolve. They don't just stack.
Temporal Validity. Every memory tracks when it was true, not just when it was stored. valid_from, valid_until, superseded_by. Your agent can answer "what did we believe about this last month?" and "when did that change?"
Procedural Memory. Skills, workflows, and habits stored in a separate, decay-resistant layer. Proficiency tracked through execution count and success rate. Your agent gets better at things it does repeatedly.
Autonomous Cognition. Background reasoning threads (strategic, operational, relational) that query the memory graph independently and surface insights. Your agent thinks about things even when nobody's talking to it.
Proprioception. Self-diagnostic system that monitors its own cognitive integrity: orphaned memories with no connections, synaptic collapse, embedding/sparse-code consistency, and learning rate stalls. The system knows when something is wrong with itself.
Metacognition. Reasoning traces, weekly audits with bias detection, and a feedback loop that injects corrective artifacts when inconsistencies are found. Self-reflection that actually changes future behavior.
- Node.js 22+
- PostgreSQL 15+ with pgvector extension
- An embedding API key (VoyageAI recommended, OpenAI supported)
git clone https://github.com/Rezzyman/cortex.git
cd cortex
npm install
cp .env.example .env
# Edit .env with your DATABASE_URL and API keyscp .env.example .env
# Add your VOYAGE_API_KEY and/or ANTHROPIC_API_KEY
docker compose upnpx tsx scripts/run-migrations.tsCORTEX exposes its tools via the Model Context Protocol, making it available to any MCP-compatible agent (Claude Code, OpenClaw, custom agents):
npx tsx src/mcp/server.tsAdd to your agent's .mcp.json:
{
"mcpServers": {
"cortex": {
"command": "npx",
"args": ["tsx", "/path/to/cortex/src/mcp/server.ts"],
"env": {
"DATABASE_URL": "your-connection-string",
"VOYAGE_API_KEY": "your-key"
}
}
}
}npx tsx src/index.ts
# Server starts on port 4000Every /api/v1/* route requires the same credentials as POST /mcp: an OAuth access token or the static CORTEX_MCP_TOKEN, sent as Authorization: Bearer <token>. With neither configured, the API answers 401 (fail closed).
The dashboard (dashboard/server.mjs) is a dependency-free Node server
that visualizes the live OmO memory graph. It reads ~/.omo/memory/agents/* directly and has no
API or database dependency — it needs no .env, no npm install, and no running Cortex server.
npm run dashboard # foreground, http://127.0.0.1:3100
npm run dashboard:daemon # singleton background daemon
npm run dashboard:status # { "running": true, "pid": ..., "url": ... }
npm run dashboard:stop # stop the daemon
npm run dashboard:alt # foreground on 3200, if 3100 is taken
node dashboard/server.mjs --api http://127.0.0.1:4000 # enable dream + procedural testsIt also loads the OmO engine from ~/.omo/agent/extensions/cortex-memory.js at startup, so it
requires that file plus at least one agent memory directory. Inside OmO, the cortex-dashboard
command does the same thing.
The 3D canvas renders the highest-priority engrams up to a cap you set with the Render Cap HUD
control (1500 default, 5000 for the whole brain; ?limit= also accepts it). When the cap hides
anything, the Neurons KPI reads rendered / total and the Vitals panel names each workspace with
nothing rendered, alongside a Filter by workspace action that loads one workspace in full. The
build string in the header comes from /api/v1/health, which reports the server's single VERSION
constant; src/lib/version.ts does the same job for the API, where the root descriptor, health,
status, and MCP server identity all read package.json so a release bump cannot leave an endpoint
advertising an old version.
The dashboard doubles as a playground: a Test Harness tab and a Quick Actions bar drive every
memory mechanism against the live store, and each run is written to
.omo/evidence/dashboard-harness-runs.json and summarised in the Vitals panel.
| Action | What it proves | Success looks like |
|---|---|---|
Ingest Sample (ingest_proof) |
DG encoding + CA1 novelty gate + recall path | A new engram id, then three checks: indexed, rendered in the graph payload, and recalled by its unique nonce with a real DG/BM25 score. A near-duplicate instead returns refused_duplicate — that is the gate passing, not failing. Result panel offers Undo. |
Search breakdown (search_breakdown) |
6-factor hybrid recall | Ranked hits with cosine/DG/BM25/recency/emotional/phase factors broken out. With a Cortex API wired up, the PostgreSQL 7-factor table (incl. priority boost and CA3 activation) is shown beside it. |
Reconsolidate (reconsolidate_before_after) |
Belief update instead of append | Successor id replaces the target; table reports resonance, priority, degree, emotional boost, provenance and domain before vs after, plus whether the engram was inside the 1-hour labile window. The superseded text stays reachable on the time slider. |
Trigger Dream (dream_mini_cycle) |
SWS/REM consolidation | Phase stats from the API: resonance updated, deleted/archived/pruned, clusters, strengthened, novel synapses, duration. Requires the API — reported as unavailable with setup instructions, never faked. |
Procedural recall (procedural_recall) |
Skill retrieval for a task context | Matches with matchType (trigger/domain/semantic), relevance, proficiency, execution count, success rate. Requires the API. |
Temporal scrub (temporal_scrub) |
valid_from/valid_until reconstruction | Node and edge counts change across recorded checkpoints, and superseded engrams reappear at timestamps before their supersession. |
Run Vitals Check (vitals_check) |
Self-diagnostics | Health verdict plus the warning and ok-check lists, including harness and recall-budget summaries. |
Writes are gated twice over: mutating tests refuse until the Allow writes to the live memory store
checkbox is set (Quick Actions ask once via a dialog), and every write is tagged
dashboard-harness so Undo can remove exactly those engrams and their supersession records.
The Time Travel slider rebuilds the graph as of any instant between the oldest engram and now, with jump markers taken from real consolidation receipts, OmO dream runs, and reconsolidation records. SWS/REM phase markers only appear once a dream cycle has actually been captured through the API — the file store records consolidation runs, not phases, and the UI says so.
Session notes persist to .omo/evidence/dashboard-notes.json (autosaved, restorable, with an
Append Last Result button), and Export Graph Snapshot writes graph + vitals + timeline +
capabilities to .omo/evidence/snapshots/ and hands you the same JSON as a download. Evidence
screenshots from development runs live in .omo/evidence/ as
dashboard-render-check-1.png, dashboard-workspace-lens.png, and dashboard-search-spotlight.png.
Harness and playground endpoints: GET /api/v1/capabilities, GET|POST /api/v1/harness,
POST /api/v1/harness/run, POST /api/v1/harness/cleanup, GET /api/v1/timeline,
GET|POST /api/v1/notes, POST /api/v1/snapshot. GET /api/v1/graph accepts ?at=<ISO|epoch ms>.
If the engine file is missing or unreadable the dashboard still serves its UI: /api/v1/health
reports engine_unavailable with the path and reason, memory routes answer 503 with the same
diagnostic, and the canvas shows what to fix instead of a blank screen. Point
--engine <path> (or CORTEX_DASHBOARD_ENGINE) at an alternate build to exercise that path.
| Service | Default | Override |
|---|---|---|
| REST API (src/index.ts) | 4000 | CORTEX_API_PORT (generic PORT also honored, and wins over the default) |
| 3D dashboard (dashboard/server.mjs) | 3100 | CORTEX_DASHBOARD_PORT or --port (PORT is a fallback too) |
The two no longer collide: npm run dev and npm run dashboard can run at the same time. If you
export a generic PORT, both servers read it as a fallback and will land on the same port — pin the
dashboard with CORTEX_DASHBOARD_PORT (or --port) in that case. OmO's cortex-dashboard command
launches the dashboard with no port flag and links to http://127.0.0.1:3100, so prefer moving the
API rather than the dashboard default. If a port is busy anyway, each server exits with an
EADDRINUSE message naming the variable to change instead of a stack trace.
| Tool | What It Does |
|---|---|
cortex_init |
Session boot. Loads top memories, system stats, active entities. Call this first. |
cortex_search |
Hybrid 7-factor search across all memories |
cortex_recall |
Token-budget-aware retrieval. Ask for 4,000 tokens of context, get exactly that. |
cortex_ingest |
Store new memory. Chunks, embeds, extracts entities, encodes through hippocampus, forms synapses. |
cortex_status |
System health and statistics |
cortex_dream |
Trigger a dream cycle (full, SWS-only, REM-only, pruning-only) |
| Tool | What It Does |
|---|---|
cortex_reconsolidate |
Update a recalled memory within its labile window |
cortex_labile |
List memories currently open for modification |
| Tool | What It Does |
|---|---|
cortex_procedural_store |
Teach the agent a skill, workflow, or habit |
cortex_procedural_retrieve |
Find relevant procedures for a given context |
| Tool | What It Does |
|---|---|
cortex_self_check |
Run full cognitive integrity diagnostics |
cortex_journal |
Log agent state (energy, confidence, concerns) |
cortex_assess_state |
Infer human's energy/stress/focus from their messages |
cortex_bg_thread |
Run strategic, operational, or relational background reasoning |
cortex_synthesize |
Generate novel insights from recent synaptic connections |
cortex_observe |
Capture and analyze screen state (macOS) |
cortex_relationship |
Lookup a contact's profile, history, and open items |
cortex_reason |
Store a structured decision trace for audit |
cortex_audit |
Weekly reasoning consistency check with bias detection |
cortex_monologue |
Record inner thoughts (the agent's internal voice) |
CORTEX uses a 7-factor hybrid scoring system:
score = 0.50 * cosine_similarity (semantic relevance)
+ 0.20 * text_match (exact keyword hit)
+ 0.15 * recency (exponential decay, 30-day half-life)
+ 0.10 * resonance (Ebbinghaus stability-adjusted)
+ 0.05 * priority_boost (P0=1.0 critical ... P4=0.1 ephemeral)
Plus CA3 pattern completion boost and emotional recall boost in --verbose mode. This isn't just "find the nearest vector." It's a judgment call about what's relevant right now, weighted by how important it is, how recent, and how connected to other things the agent knows.
Five phases. Two stages. Inspired by real sleep neuroscience.
SWS (Slow-Wave Sleep):
- Resonance Analysis. Ebbinghaus stability-adjusted decay across all active memories. Frequently accessed, highly connected memories resist decay.
- Adaptive Pruning. Percentile-based thresholds (P5 delete, P15 archive) computed from the agent's actual resonance distribution. No hardcoded cutoffs. Safety floors prevent catastrophic pruning. P0/P1 and emotionally salient memories are always protected.
- Consolidation. Connected component clustering of high-resonance memories. LLM generates abstractive summaries that capture the actual insight, not just a list of entities.
REM (Rapid Eye Movement): 4. Free Association. Random activation of memory nodes for novel cross-domain connections. 5. Synthesis. Generate insights from newly formed synapses. The kind of connections that only happen when you stop trying.
16 tables across 6 cognitive layers. PostgreSQL with pgvector.
memory_nodes (episodic), memory_synapses (associative connections), hippocampal_codes (DG sparse representations), emotional_valence (6D emotional context), procedural_memories (skills with proficiency), cognitive_artifacts (decisions, learnings, corrections), dream_cycle_logs, self_diagnostics, agent_state_logs, principal_state, background_threads, relationship_graph, agents (multi-agent isolation).
This isn't decorative. Every subsystem maps to established computational neuroscience:
- Dentate Gyrus pattern separation: Rolls (2013), Marr (1971)
- CA1 predictive coding / novelty detection: Lee et al. (2009)
- CA3 autoassociative pattern completion: Ramsauer et al. (2020) Hopfield Networks is All You Need, Rolls (2013)
- Memory reconsolidation: Nader et al. (2000), Lee, Nader & Schiller (2017)
- Two-phase sleep consolidation: Diekelmann & Born (2010), Hobson & Friston (2012)
- Adaptive pruning / synaptic homeostasis: Tononi & Cirelli (2014)
- Ebbinghaus forgetting curve: Ebbinghaus (1885), Murre & Dros (2015) — modern replication
- Emotional valence and memory salience: Cahill & McGaugh (1998), Russell (1980)
- Procedural skill formation: Anderson (1982) ACT-R framework
See REFERENCES.md for DOIs, URLs, abstracts, and the mapping from each paper to the specific source file in this repo.
npm test34 tests covering Dentate Gyrus encoding (sparsity, determinism, normalization, pattern separation), entity extraction, and text chunking.
CORTEX ships as a small family of compatible projects. Pick the one that matches how you want to integrate:
| Project | Language | Storage | Audience | Install |
|---|---|---|---|---|
| cortex (this repo) | TypeScript (Node 22+) | PostgreSQL + pgvector | Production agent teams · benchmark-certified retrieval · MCP and REST | git clone + Docker Compose |
| cortex-lite | Python 3.10+ | SQLite (one file) | Individual developers · zero-config · local embeddings · 30-second quickstart | pip install cortex-lite |
| cortex-python | Python 3.10+ | PostgreSQL + pgvector (shares schema with this repo) | Python agent codebases that need to read and write the same memory store as a TypeScript CORTEX deployment | pip install cortex-ai |
Choose cortex for the full benchmark-certified stack with dream cycles, CA3 pattern completion, reconsolidation, emotional valence, procedural learning, and autonomous cognition threads.
Choose cortex-lite to get the hybrid-search pattern running in under a minute with zero infrastructure. Graduate to full cortex when you need dream cycles or scale past ~10K memories.
Choose cortex-python when your agent code is already Python and you need first-class read/write access to a CORTEX memory store. cortex-python implements the core subsystems (hippocampus, dream cycle, procedural memory, hybrid search) and is schema-compatible with this flagship repo.
We welcome contributions. See CONTRIBUTING.md.
Priority areas: additional benchmarks, entity resolution, temporal reasoning queries, additional embedding providers, expanded test coverage, and bringing cortex-python to full parity with the TypeScript flagship.
Apache 2.0. See LICENSE.
Built by Atanasio Juarez at ATERNA.AI.