A Self-Evolving Memory System That Actually Learns
This system transforms passive data storage into an active learning engine. Inspired by Andrej Karpathy's LLM Knowledge Base architecture, it combines pattern extraction, Hebbian link detection, ACT-R cognitive modeling, and Ebbinghaus forgetting curves to create a memory system that improves over time.
System Architecture
Tier 1: Redis (Hot Cache)
127.0.0.1:6379
- kilo:search:* — Search results (1hr TTL)
- kilo:entry:* — Memory entries (24hr)
- kilo:stats:* — Aggregations (5min)
- shared:infra:* — Cross-agent data (12hr)
Tier 2: MariaDB (Primary)
127.0.0.1:3306
- kilo — 1,209 memory entries
- aoede — 15,507+ agent entries
- claude — Knowledge library
- infra_secrets — Credentials
- 8 databases total
Tier 3: Obsidian (Knowledge)
127.0.0.1:7654
- wiki/ — Main documentation
- kilo/ — Kilo-specific knowledge
- harry/ — Harry's knowledge
- raw/ — Research materials
- 338+ files across 4 vaults
Tier 4: Karpathy Learning
Self-improving engine
- Pattern Extractor — 1,200+ entries analyzed
- Hebbian Links — 396+ tag connections
- ACT-R Activation — 18 types ranked
- Feedback Loop — Outcome tracking
- Qdrant — Vector search (L2 layer)
The 5 Learning Components
Pattern Extractor
Analyzes all memory entries to identify patterns in successful vs. failed actions. Categorizes by event_type and tags to understand what works.
Hebbian Link Detection
"Cells that fire together wire together." Detects co-occurring tags and creates weighted links between them — the system learns that redis and cache often go together.
ACT-R Activation
Based on John Anderson's ACT-R cognitive theory. Successful patterns "float to top" through activation calculation: A = A_base + ln(1/time) + success_bonus.
Ebbinghaus Forgetting
Old failures fade away over time. Entries older than 14 days with event_type 'issue' or 'failed' are automatically deprioritized — the system "forgets" what didn't work.
Affected types: issue, error, failed, fix-failed
Feedback Loop
Tracks outcomes of actions. When you record "success" or "fail", it updates the system to suggest better actions in the future.
Data Flow
hot cache
primary
knowledge
vector search
learn
Memory Layers (L1–L4)
| Layer | Technology | Latency | Purpose |
|---|---|---|---|
| L1 | Redis | 0ms | Identity, rules, configs |
| L2 | Qdrant | 5-50ms | Semantic vector search |
| L3 | MariaDB | 5-10ms | Structured entries (1,200+ records) |
| L4 | Obsidian | 50-200ms | Rich content vault (338+ files) |
Multi-Agent Memory
Kilo Agent
- • 4+ Redis keys (search, entry, stats, obsidian)
- • 1,209 entries in kilo database
- • 191 sessions tracked
- • Full R/W to MariaDB
- • Access to wiki/kilo/ vaults
Harry Agent
- • 23+ Redis keys (infra, services, creds)
- • Separate entries in separate DB
- • Access to wiki/harry/ vault
- • shared:infra:* accessible to all
Shared Memory
Both agents can read shared:infra:* keys — when Kilo discovers
127.0.0.1 has MariaDB+Redis, Harry doesn't need to re-discover. The knowledge is shared.
Action Breakdown
1,209
Total Actions
191
Sessions
1,200+
Entries Analyzed
8
MariaDB Databases
Top Action Types
Usage
python3 memory.py log action "Deployed feature" --tags feature,deploy
python3 memory.py search redis
python3 obsidian_access.py search "workflow"
python3 karpathy_learn.py
from karpathy_learn import get_recommendations
recs = get_recommendations("redis setup")
"The system doesn't just store memory — it learns from it."
— Kilo Memory Architecture