Skip to main content

Memory Architecture Overview

The AgentOS memory system is a composable, SQLite-first architecture that layers cognitive-science-inspired memory management atop a single-file brain database. Three progressive API tiers let you choose the right abstraction for your use case.


The Three Layers

AgentOS memory ships as three concentric API tiers. Each tier wraps the one below it and adds its own concerns:

┌─────────────────────────────────────────────────────────────────────┐
│ Wunderland CLI Layer │
│ wunderland memory export/import/consolidate/health │
│ (CLI flags, agent.config.json auto-wiring, preset skills) │
└──┬──────────────────────────────────────────────────────────────────┘

┌──▼──────────────────────────────────────────────────────────────────┐
│ AgentCognitiveMemory Layer │
│ CognitiveMemoryManager + AgentMemory facade │
│ (HEXACO encoding, PAD mood, Ebbinghaus decay, observer/reflector, │
│ Baddeley working memory, spreading activation, prospective mem) │
└──┬──────────────────────────────────────────────────────────────────┘

┌──▼──────────────────────────────────────────────────────────────────┐
│ Memory Facade Layer │
│ new Memory({ store: 'sqlite', path: './brain.sqlite' }) │
│ (remember, recall, ingest, export, import, consolidate, tools) │
│ │
│ Composes: │
│ SqliteBrain → SqliteKnowledgeGraph → SqliteMemoryGraph │
│ LoaderRegistry → FolderScanner → ChunkingEngine │
│ RetrievalFeedbackSignal → ConsolidationLoop │
│ I/O exporters/importers (JSON, Markdown, Obsidian, SQLite, etc.) │
└─────────────────────────────────────────────────────────────────────┘

When to Use Each Layer

LayerImportBest ForLLM Required
Memorynew Memory(config)Any TypeScript app, CLI tools, scripts, ingestion pipelinesNo
AgentCognitiveMemoryCognitiveMemoryManager or AgentMemory.wrap()Agents with HEXACO personality, PAD mood, observer/reflectorOptional (Batch 2)
Wunderland CLIwunderland memory <cmd>End-user interaction, shell scripts, CI pipelinesNo

Memory Facade Composition

The Memory class is the primary standalone entry point. It wires together every subsystem at construction time:

import { Memory } from '@framers/agentos';

const mem = new Memory({
store: 'sqlite',
path: './brain.sqlite',
graph: true,
selfImprove: true,
});

Subsystem Wiring

StepSubsystem CreatedPurpose
1SqliteBrain(path)Single WAL-mode SQLite connection, 12-table schema
2SqliteKnowledgeGraph(brain)Entity and relationship store for knowledge graph
3SqliteMemoryGraph(brain)Memory association graph with spreading activation
4LoaderRegistry()File-type detection and document parsing
5FolderScanner(registry)Recursive directory walking with glob filters
6ChunkingEngine()Four chunking strategies (fixed, semantic, hierarchical, layout)
7RetrievalFeedbackSignal(brain)Used/ignored detection for Hebbian reinforcement
8ConsolidationLoop(brain, graph)6-step self-improving consolidation pipeline

When selfImprove is false, steps 7 and 8 are skipped and the feedback/consolidation subsystems are set to null.

Data Flow

Input (text / file / URL / folder)


┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ LoaderRegistry │───▶│ ChunkingEngine │───▶│ SqliteBrain │
│ (parse to text) │ │ (split chunks) │ │ (store traces) │
└──────────────────┘ └──────────────────┘ └────────┬─────────┘

┌──────────────────────────────────────────────────────┘

▼ ▼ ▼
┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ FTS5 Index │ │ KnowledgeGraph │ │ MemoryGraph │
│ (BM25 search) │ │ (entities/edges)│ │ (associations) │
└──────────────────┘ └──────────────────┘ └──────────────────┘
│ │ │
└────────────────┬────────┘─────────────────────────┘

┌──────────────────┐
│ recall() result │
│ (scored traces) │
└──────────────────┘


┌──────────────────┐
│ Feedback Signal │
│ (used/ignored) │
└──────────────────┘


┌──────────────────┐
│ ConsolidationLoop│
│ (prune/merge/...) │
└──────────────────┘

AgentCognitiveMemory Layer

The CognitiveMemoryManager adds personality-modulated cognition on top of the base Memory. When used inside AgentOS, it powers the full per-turn memory pipeline:

// Inside AgentOS turn loop:
// 1. encode() → Create MemoryTrace (personality-modulated strength)
// 2. retrieve() → Query vector store + 6-signal composite scoring
// 3. assembleForPrompt → Token-budgeted context assembly → system prompt
// 4. [LLM generates response]
// 5. observe() → Feed response to observer buffer
// 6. checkProspective → Check time/event/context triggers
// 7. runConsolidation → Periodic background sweep

Key additions over the standalone Memory facade:

FeatureDescription
HEXACO encodingPersonality traits modulate attention weights and encoding strength
PAD mood stateCurrent valence/arousal/dominance affects encoding and retrieval
Ebbinghaus decayExponential forgetting curve with spaced repetition reinforcement
Baddeley working memorySlot-based capacity (7 plus/minus 2), activation decay per turn
Spreading activationACT-R-style graph traversal from seed nodes
Observer/ReflectorLLM-backed observation compression (3-10x) and reflection
Prospective memoryTime, event, and context-based future-intention triggers
6-signal retrievalStrength + similarity + recency + emotion + graph + importance

See Cognitive Memory for the full technical reference.


Cognitive Science Foundations

The memory system is grounded in established cognitive science models rather than ad-hoc engineering:

ModelYearApplication in AgentOS
Atkinson-Shiffrin (1968)1968Sensory input -> working memory -> long-term memory pipeline
Baddeley & Hitch (1974)1974Slot-based working memory with capacity limits
Tulving's LTM taxonomy (1972)1972Episodic, semantic, procedural, prospective memory types
Ebbinghaus forgetting curve (1885)1885Exponential strength decay: S(t) = S0 * e^(-dt / stability)
Yerkes-Dodson law (1908)1908Encoding quality peaks at moderate arousal (inverted U)
Brown & Kulik flashbulb memories (1977)1977High-emotion events create vivid, persistent traces (2x strength, 5x stability)
Mood-congruent encoding (Bower, 1981)1981Content matching current mood valence is encoded more strongly
Anderson's ACT-R (1983)1983Spreading activation through associative memory graph
Hebbian learning (1949)1949Co-retrieved memories strengthen associative edges
HEXACO personality model (2004)2004Trait-driven attention weights and capacity modulation
Collins & Quillian (1969)1969Semantic network structure for knowledge nodes/edges

Comparison with Competitors

FeatureAgentOS Memorymem0CogneeLetta (MemGPT)Mastra
StorageSingle SQLite file per agentQdrant/Chroma/PostgresNeo4j + vectorPostgres + ChromaPostgres + Pinecone
Personality modulationHEXACO 6-trait encoding biasNoneNoneNoneNone
Forgetting curveEbbinghaus exponential decayNoneNoneNoneNone
Spaced repetitionInterval doubling with desirable difficultyNoneNoneNoneNone
Working memoryBaddeley slots (5-9, personality-modulated)NoneNoneFIFO context windowFixed sliding window
Mood-aware retrievalPAD mood congruence (0.15 weight)NoneNoneNoneNone
Memory graphSQLite-backed with spreading activationSimple key-valueNeo4j graphNoneNone
Self-improvement6-step consolidation (prune/merge/strengthen/derive/compact/reindex)Manual CRUDBatch re-processingEdit-basedNone
Retrieval signals6-signal composite (strength, similarity, recency, emotion, graph, importance)Cosine similarityCosine + graphCosine similarityCosine similarity
Document ingestion3-tier PDF, DOCX, HTML, Markdown, CSV, JSON, URLsText onlyPDF, textText onlyText only
Import/ExportSQLite, JSON, Markdown, Obsidian, ChatGPT, CSVJSONNoneJSONNone
Offline-firstZero network calls requiredRequires vector DBRequires Neo4jRequires serverRequires cloud
Provenance trackingFull source type, confidence, verification countNoneBasicNoneNone

Key differentiators:

  1. Zero-dependency local operation --- A single SQLite file contains everything (traces, graph, embeddings, FTS5 index, feedback signals, consolidation log). No external vector database, graph database, or cloud service required.

  2. Cognitive science grounding --- Rather than treating memory as a flat key-value store, every operation is modulated by established cognitive models (encoding strength, forgetting curves, mood congruence, personality bias).

  3. Progressive complexity --- The standalone Memory facade works with zero LLM calls. Cognitive features (observer, reflector, derive) activate only when an LLM invoker is provided.


Source File Map

PathModule
memory/facade/Memory.tsStandalone Memory facade
memory/facade/types.tsPublic API types
memory/store/SqliteBrain.tsSQLite connection manager (12-table DDL)
memory/store/SqliteKnowledgeGraph.tsIKnowledgeGraph over SQLite
memory/store/SqliteMemoryGraph.tsIMemoryGraph with spreading activation
memory/ingestion/LoaderRegistry, FolderScanner, ChunkingEngine, loaders
memory/feedback/RetrievalFeedbackSignal.tsUsed/ignored detection
memory/consolidation/ConsolidationLoop.ts6-step consolidation pipeline
memory/io/JSON, Markdown, Obsidian, SQLite, ChatGPT, CSV importers/exporters
memory/tools/6 agent-facing ITool implementations
memory/observation/ObservationCompressor, ObservationReflector, temporal
memory/encoding/EncodingModel, ContentFeatureDetector
memory/decay/DecayModel, RetrievalPriorityScorer
memory/working/CognitiveWorkingMemory (Baddeley)
memory/graph/IMemoryGraph, SpreadingActivation, GraphologyMemoryGraph
memory/prospective/ProspectiveMemoryManager
memory/consolidation/ConsolidationPipeline
memory/prompt/MemoryPromptAssembler, MemoryFormatters