350 lines
16 KiB
Markdown
350 lines
16 KiB
Markdown
# AgentDB Learning: Visual Guide
|
|
|
|
**Purpose**: Visual diagrams and flow charts showing exactly how AgentDB learns and improves skill creation.
|
|
|
|
---
|
|
|
|
## 🔄 **The Complete Learning Loop (Visual)**
|
|
|
|
### **Macro Level: Creation → Learning → Improvement**
|
|
|
|
```
|
|
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
|
|
│ User Request │───▶│ Agent Creator │───▶│ Skill Created │
|
|
│ │ │ │ │ │
|
|
│ "Create agent │ │ Uses: │ │ Functional code │
|
|
│ for stocks" │ │ • /references │ │ • Documentation │
|
|
└─────────────────┘ │ • AgentDB data │ │ • Tests │
|
|
└──────────────────┘ └─────────────────┘
|
|
│ │
|
|
▼ ▼
|
|
┌──────────────────┐ ┌─────────────────┐
|
|
│ Store in AgentDB│───▶│ Deploy Skill │
|
|
│ │ │ │
|
|
│ • Episodes │ • User starts │
|
|
│ • Causal edges │ • using skill │
|
|
│ • Success data │ • Provides feedback│
|
|
└──────────────────┘ └─────────────────┘
|
|
│ │
|
|
▼ ▼
|
|
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
|
|
│ Future User │◀───│ AgentDB Query │◀───│ Learning Data │
|
|
│ Request │ │ │ │ Accumulated │
|
|
│ │ • Similar past │ │ │
|
|
│ "Create agent │ • Success rates │ • Better patterns│
|
|
│ for crypto" │ • Proven templates │ • Higher success │
|
|
└─────────────────┘ └──────────────────┘ └─────────────────┘
|
|
```
|
|
|
|
---
|
|
|
|
## 📊 **Data Storage Structure (Visual)**
|
|
|
|
### **What Gets Stored Where in AgentDB**
|
|
|
|
```
|
|
AgentDB Database
|
|
├── 📚 Episodes (Reflexion Store)
|
|
│ ├── Episode #1
|
|
│ │ ├── session_id: "creation-20251024-103406"
|
|
│ │ ├── task: "agent_creation_decision"
|
|
│ │ ├── input: "Create financial analysis agent..."
|
|
│ │ ├── reward: 85.0
|
|
│ │ ├── success: true
|
|
│ │ └── template_used: "financial-analysis-template"
|
|
│ │
|
|
│ ├── Episode #2
|
|
│ │ ├── session_id: "creation-20251024-103456"
|
|
│ │ ├── task: "agent_creation_decision"
|
|
│ │ ├── input: "Build climate analysis tool..."
|
|
│ │ ├── reward: 0.0
|
|
│ │ ├── success: false
|
|
│ │ └── template_used: "climate-analysis-template"
|
|
│ │
|
|
│ └── ... (one episode per creation)
|
|
│
|
|
├── 🔗 Causal Edges
|
|
│ ├── Edge #1
|
|
│ │ ├── cause: "finance_domain_request"
|
|
│ │ ├── effect: "financial_template_selected"
|
|
│ │ ├── uplift: 0.25
|
|
│ │ ├── confidence: 0.85
|
|
│ │ └── sample_size: 12
|
|
│ │
|
|
│ ├── Edge #2
|
|
│ │ ├── cause: "climate_domain_request"
|
|
│ │ ├── effect: "climate_template_selected"
|
|
│ │ ├── uplift: 0.30
|
|
│ │ ├── confidence: 0.90
|
|
│ │ └── sample_size: 8
|
|
│ │
|
|
│ └── ... (learned cause→effect relationships)
|
|
│
|
|
└── 🛠️ Skills Database
|
|
├── Skill #1
|
|
│ ├── name: "financial-pattern-skill"
|
|
│ ├── description: "Common patterns for finance agents"
|
|
│ ├── success_rate: 0.82
|
|
│ ├── uses: 15
|
|
│ └── learned_features: ["RSI", "MACD", "volume"]
|
|
│
|
|
└── ... (extracted patterns from successful episodes)
|
|
```
|
|
|
|
---
|
|
|
|
## 🔍 **Query Process (Step-by-Step Visual)**
|
|
|
|
### **When User Requests: "Create financial analysis agent"**
|
|
|
|
```
|
|
Step 1: Input Analysis
|
|
┌─────────────────────────────────────┐
|
|
│ User Input: "Create financial │
|
|
│ analysis agent for stocks" │
|
|
│ │
|
|
│ → Extract domain: "finance" │
|
|
│ → Extract features: "analysis", │
|
|
│ "stocks" │
|
|
│ → Generate search queries │
|
|
└─────────────────────────────────────┘
|
|
│
|
|
▼
|
|
Step 2: AgentDB Queries
|
|
┌─────────────────────────────────────┐
|
|
│ Query 1: Episodes │
|
|
│ agentdb reflexion retrieve │
|
|
│ "financial analysis" 5 0.6 │
|
|
│ │
|
|
│ Query 2: Causal Effects │
|
|
│ agentdb causal query │
|
|
│ "use_finance_template" "" 0.7 │
|
|
│ │
|
|
│ Query 3: Skills Search │
|
|
│ agentdb skill search │
|
|
│ "financial analysis" 5 │
|
|
└─────────────────────────────────────┘
|
|
│
|
|
▼
|
|
Step 3: Data Analysis
|
|
┌─────────────────────────────────────┐
|
|
│ Episodes Retrieved: │
|
|
│ ┌─ Episode A: Success=True │
|
|
│ │ Template: financial-template │
|
|
│ │ Reward: 85.0 │
|
|
│ └─ Episode B: Success=False │
|
|
│ Template: generic-template │
|
|
│ Reward: 0.0 │
|
|
│ │
|
|
│ Success Rate: 50% (1/2) │
|
|
│ │
|
|
│ Causal Effects Found: │
|
|
│ ┌─ financial-template: uplift=0.25 │
|
|
│ └─ generic-template: uplift=0.10 │
|
|
└─────────────────────────────────────┘
|
|
│
|
|
▼
|
|
Step 4: Decision Making
|
|
┌─────────────────────────────────────┐
|
|
│ Decision Factors: │
|
|
│ ✓ 25% uplift for financial-template │
|
|
│ ✓ 50% historical success rate │
|
|
│ ✓ Domain match: "finance" │
|
|
│ │
|
|
│ Enhanced Decision: │
|
|
│ → Template: financial-template │
|
|
│ → Confidence: 0.50 │
|
|
│ → Proof: "Causal uplift: 25%" │
|
|
│ → Features: ["RSI", "MACD"] │
|
|
└─────────────────────────────────────┘
|
|
```
|
|
|
|
---
|
|
|
|
## 📈 **Learning Progression (Visual Timeline)**
|
|
|
|
### **How the System Gets Smarter Over Time**
|
|
|
|
```
|
|
Month 1: Initial Learning
|
|
┌─────────────────────────────────────┐
|
|
│ Creations: 5 │
|
|
│ Episodes: 5 │
|
|
│ Success Rate: Unknown │
|
|
│ Templates: Static from /references │
|
|
│ Learning: Basic pattern recording │
|
|
└─────────────────────────────────────┘
|
|
|
|
Month 3: Pattern Recognition
|
|
┌─────────────────────────────────────┐
|
|
│ Creations: 25 │
|
|
│ Episodes: 25 │
|
|
│ Success Rates: Emerging │
|
|
│ Templates: Domain-specific patterns │
|
|
│ Learning: Success rate calculation │
|
|
└─────────────────────────────────────┘
|
|
|
|
Month 6: Intelligent Recommendations
|
|
┌─────────────────────────────────────┐
|
|
│ Creations: 100 │
|
|
│ Episodes: 100 │
|
|
│ Success Rates: Reliable (>10 samples)│
|
|
│ Templates: Optimized per domain │
|
|
│ Learning: Causal relationship mapping│
|
|
└─────────────────────────────────────┘
|
|
|
|
Month 12: Expert System
|
|
┌─────────────────────────────────────┐
|
|
│ Creations: 500+ │
|
|
│ Episodes: 500+ │
|
|
│ Success Rates: Highly accurate │
|
|
│ Templates: Self-optimizing │
|
|
│ Learning: Predictive recommendations │
|
|
└─────────────────────────────────────┘
|
|
```
|
|
|
|
---
|
|
|
|
## 🎯 **Real Example: From First to Tenth Creation**
|
|
|
|
### **Creation #1: No Learning Data**
|
|
|
|
```
|
|
User: "Create financial analysis agent"
|
|
|
|
Process:
|
|
┌─ Query episodes: 0 results
|
|
├─ Query causal: 0 results
|
|
├─ Query skills: 0 results
|
|
└─ Decision: Use /references guidelines
|
|
|
|
Result:
|
|
┌─ Template: financial-analysis (from /references)
|
|
├─ Confidence: 0.8 (base rate)
|
|
├─ Features: Standard set
|
|
└─ Storage: Episode + Causal edge recorded
|
|
```
|
|
|
|
### **Creation #10: Rich Learning Data**
|
|
|
|
```
|
|
User: "Create financial analysis agent for crypto"
|
|
|
|
Process:
|
|
┌─ Query episodes: 8 similar results
|
|
│ ├─ Success: 6/8 = 75% success rate
|
|
│ └─ Common features: ["RSI", "volume", "volatility"]
|
|
│
|
|
├─ Query causal: 5 relevant edges
|
|
│ ├─ financial-template: uplift=0.25
|
|
│ ├─ crypto-specific: uplift=0.15
|
|
│ └─ volatility-analysis: uplift=0.10
|
|
│
|
|
└─ Query skills: 3 relevant skills
|
|
├─ crypto-analysis-skill: success_rate=0.82
|
|
├─ technical-indicators-skill: success_rate=0.78
|
|
└─ market-data-skill: success_rate=0.85
|
|
|
|
Result:
|
|
┌─ Template: financial-analysis-enhanced
|
|
├─ Confidence: 0.75 (from historical data)
|
|
├─ Features: ["RSI", "MACD", "volatility", "crypto-specific"]
|
|
├─ Proof: "Causal uplift: 25% + crypto patterns: 15%"
|
|
└─ Storage: New episode + refined causal edges
|
|
```
|
|
|
|
---
|
|
|
|
## 🔧 **Technical Flow Diagram**
|
|
|
|
### **Code-Level Data Flow**
|
|
|
|
```
|
|
enhance_agent_creation(user_input, domain)
|
|
│
|
|
▼
|
|
┌─────────────────────────────────────────┐
|
|
│ Step 1: Query Historical Episodes │
|
|
│ episodes = query_similar_episodes(input)│
|
|
│ │
|
|
│ SQL equivalent: │
|
|
│ SELECT * FROM episodes │
|
|
│ WHERE similarity(input, task) > 0.6 │
|
|
│ ORDER BY similarity DESC │
|
|
│ LIMIT 3 │
|
|
└─────────────────────────────────────────┘
|
|
│
|
|
▼
|
|
┌─────────────────────────────────────────┐
|
|
│ Step 2: Calculate Success Patterns │
|
|
│ success_rate = successful/total │
|
|
│ │
|
|
│ if success_rate > 0.7: │
|
|
│ prefer_this_pattern = True │
|
|
└─────────────────────────────────────────┘
|
|
│
|
|
▼
|
|
┌─────────────────────────────────────────┐
|
|
│ Step 3: Query Causal Relationships │
|
|
│ effects = query_causal_effects(domain) │
|
|
│ │
|
|
│ SQL equivalent: │
|
|
│ SELECT * FROM causal_edges │
|
|
│ WHERE cause LIKE '%domain%' │
|
|
│ AND uplift > 0.1 │
|
|
│ ORDER BY uplift DESC │
|
|
└─────────────────────────────────────────┘
|
|
│
|
|
▼
|
|
┌─────────────────────────────────────────┐
|
|
│ Step 4: Search Learned Skills │
|
|
│ skills = search_relevant_skills(input) │
|
|
│ │
|
|
│ SQL equivalent: │
|
|
│ SELECT * FROM skills │
|
|
│ WHERE similarity(description, query) > 0.7│
|
|
│ AND success_rate > 0.6 │
|
|
└─────────────────────────────────────────┘
|
|
│
|
|
▼
|
|
┌─────────────────────────────────────────┐
|
|
│ Step 5: Make Enhanced Decision │
|
|
│ intelligence = AgentDBIntelligence( │
|
|
│ template_choice=best_template, │
|
|
│ success_probability=success_rate, │
|
|
│ learned_improvements=extract_features(skills),│
|
|
│ mathematical_proof=causal_proof │
|
|
│ ) │
|
|
└─────────────────────────────────────────┘
|
|
│
|
|
▼
|
|
┌─────────────────────────────────────────┐
|
|
│ Step 6: Store for Future Learning │
|
|
│ store_creation_decision(input, intelligence)│
|
|
│ │
|
|
│ SQL equivalent: │
|
|
│ INSERT INTO episodes VALUES (...) │
|
|
│ INSERT INTO causal_edges VALUES (...) │
|
|
└─────────────────────────────────────────┘
|
|
```
|
|
|
|
---
|
|
|
|
## 🎉 **Key Takeaways (Visual Summary)**
|
|
|
|
```
|
|
┌─────────────────────────────────────────┐
|
|
│ AgentDB Learning Magic │
|
|
│ │
|
|
│ 📚 Store Every Decision │
|
|
│ 🔍 Find Similar Past Decisions │
|
|
│ 📊 Calculate Success Patterns │
|
|
│ 🎯 Make Enhanced Recommendations │
|
|
│ 🔄 Continuously Improve │
|
|
│ │
|
|
│ Result: System gets smarter with │
|
|
│ every skill created! │
|
|
└─────────────────────────────────────────┘
|
|
```
|
|
|
|
**From "nebulous magic" to "understandable process" - AgentDB turns Agent Creator into a learning system that accumulates expertise with every interaction!** |