True Learning Architecture - How Agents Actually Get Smarter
The real architecture for AI agent learning, not just data storage
π§ True Learning Architecture
The Problem We're Solving
Storing 10,000 decisions is useless if agents can't access them efficiently. The goal isn't to KEEP decisions - it's to LEARN from them.
Human Memory Analogy
You don't remember every meal you ate.
But you learned "I'm allergic to shellfish" once and NEVER forgot.
That single rule replaced thousands of:
- "I ate shrimp, felt sick"
- "I ate lobster, felt sick"
- "I ate crab, felt sick"
β DISTILLED TO: "Avoid shellfish"
The Pyramid of Intelligence
βββββββββββββββββββ
β CORE RULES β ~20 items
β (Always loaded) β ~500 tokens
β "Never use β
β rootDir..." β
ββββββββββ¬βββββββββ
β
ββββββββββΌβββββββββ
β PATTERN LIBRARY β ~100 items
β (Loaded on task) β ~2000 tokens
β "For forms, use β
β reactive..." β
ββββββββββ¬βββββββββ
β
ββββββββββΌβββββββββ
β SIMILAR DECISIONSβ 3-5 items
β (Semantic search) β ~500 tokens
β "Last time we β
β did X..." β
ββββββββββ¬βββββββββ
β
ββββββββββββββββΌβββββββββββββββ
β RAW DECISIONS β 10,000+ items
β (Archive/Training) β NOT loaded
β Only for: β
β - Auditing β
β - Pattern mining β
β - Future fine-tuning β
βββββββββββββββββββββββββββββββ
What Gets Loaded Per Task (~3000 tokens max)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CONTEXT INJECTION FOR: "Fix the build error in auth module" β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β π΄ CORE RULES (always loaded, ~500 tokens) β
β ββ Never use rootDir in tsconfig.lib.json β
β ββ Always export through src/index.ts β
β ββ Use nx reset when cache issues β
β ββ Check path mappings in tsconfig.base.json β
β β
β π‘ RELEVANT PATTERNS (task-matched, ~1000 tokens) β
β ββ Build errors: 80% are path/export issues β
β ββ Auth module: Uses @libs-core/auth-core β
β ββ Pattern: Check imports before code β
β β
β π’ SIMILAR DECISIONS (semantic search, ~500 tokens) β
β ββ "Fixed auth build by adding to index.ts" (conf: 0.98) β
β ββ "Module not found β path mapping issue" (conf: 0.95) β
β ββ "Auth integration required shared types" (conf: 0.92) β
β β
β π CURRENT SESSION (what we're doing now, ~500 tokens) β
β ββ Working on: AI infrastructure rebuild β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
TOTAL: ~2500 tokens
(Fits easily in context)
The Learning Pipeline
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β LEARNING PIPELINE β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β 1. CAPTURE β
β ββ Raw decision logged via MCP β
β β
β 2. VALIDATE (24-48 hours) β
β ββ Did it work? Track outcome β
β ββ If failed: Mark as anti-pattern β
β ββ If succeeded: Increase confidence β
β β
β 3. REFERENCE TRACKING β
β ββ How many times was this decision referenced? β
β ββ High reference = important pattern β
β β
β 4. DISTILLATION (weekly LLM job) β
β ββ Group similar decisions β
β ββ Extract common pattern β
β ββ Create rule: "When X, do Y because Z" β
β β
β 5. PROMOTION β
β ββ Pattern used 10+ times β Core Rule β
β ββ Decision referenced 5+ times β Pattern β
β ββ Decision never referenced β Archive candidate β
β β
β 6. ARCHIVE (smart, not time-based) β
β ββ Archive when: Pattern extracted AND outcome known β
β ββ Keep when: High confidence OR frequently referenced β
β ββ Never archive: Anti-patterns (learn from failures) β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Archive Criteria (Revised)
β DON'T Archive Based On:
- Age alone (90 days is arbitrary)
- Session number
- File count
β DO Archive When:
- Pattern has been extracted from the decision
- Outcome is known (success/failure recorded)
- Not referenced in 30+ days AND confidence < 0.9
- Similar decisions exist (keep highest confidence)
π NEVER Archive:
- Anti-patterns (failures we must remember)
- Architectural decisions (rare but critical)
- Decisions with confidence > 0.95
- Decisions referenced 5+ times
Data Flow
βββββββββββββββββββ
β MCP log_decisionβ
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Raw Decisions β ai-mcp-dev.decisions
β (Hot Storage) β
ββββββββββ¬βββββββββ
β
ββββββββββββββββββΌβββββββββββββββββ
β β β
βΌ βΌ βΌ
βββββββββββββ βββββββββββββ βββββββββββββ
β Outcome β β Reference β β Embedding β
β Tracking β β Counter β β Generationβ
βββββββ¬ββββββ βββββββ¬ββββββ βββββββ¬ββββββ
β β β
ββββββββββββββββββΌβββββββββββββββββ
β
βΌ
βββββββββββββββββββ
β Pattern Mining β Weekly LLM job
β (Distillation) β
ββββββββββ¬βββββββββ
β
ββββββββββββββββββΌβββββββββββββββββ
β β β
βΌ βΌ βΌ
βββββββββββββ βββββββββββββ βββββββββββββ
β Core Rulesβ β Patterns β β Archive β
β (~20) β β (~100) β β (10K+) β
βββββββββββββ βββββββββββββ βββββββββββββ
ai-agents. ai-agents. ai-agents.
core_rules patterns archived_decisions
Implementation Priority
Phase 1: Smart Context Loading (NOW)
- Implement relevance scoring for decisions
- Build semantic search with embeddings
- Create core rules extraction from high-confidence decisions
- Limit preflight to ~3000 tokens
Phase 2: Learning Pipeline (NEXT)
- Outcome tracking (did it work?)
- Reference counting (how often used?)
- Weekly pattern mining job
Phase 3: Intelligent Archive (LATER)
- Archive based on learning status, not age
- Keep anti-patterns forever
- Compress archived data
Key Metrics to Track
| Metric | Target | Why It Matters |
|---|---|---|
| Preflight tokens | <3000 | Context efficiency |
| Pattern coverage | >80% | Are common scenarios covered? |
| Outcome rate | >70% | Are we tracking if decisions worked? |
| Reference rate | >30% | Are patterns being used? |
| Archive with learning | 100% | Never archive without extracting wisdom |
The Goal
TODAY: FUTURE:
βββββββ βββββββ
10,000 raw decisions 20 core rules
Never accessed Always loaded
Agents don't learn Agents get smarter
Archive by age Archive after learning
The measure of success isn't how much we store, but how much we learn.