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:

βœ… DO Archive When:

πŸ”’ NEVER Archive:

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)

Phase 2: Learning Pipeline (NEXT)

Phase 3: Intelligent Archive (LATER)

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.