Autonomous learning and improvement system that continuously evolves agent behavior based on interaction patterns, feedback, and outcomes.
text
Experience → Pattern Detection → Learning → Validation → Integration
↑ ↓
└────────────────── Feedback Loop ←───────────────────────┘
ComponentPurposeFrequencyObserverCapture interaction patternsContinuousAnalyzerIdentify improvement opportunitiesDailyLearnerExtract actionable rulesOn triggerValidatorTest changes in isolationBefore integrationIntegratorUpdate behavioral filesAfter validation
bash
# Analyze recent interactions
python3 {baseDir}/scripts/evolution.py --analyze --days 7
# Extract patterns from memory files
python3 {baseDir}/scripts/evolution.py --extract-patterns
# Run self-assessment
python3 {baseDir}/scripts/evolution.py --self-assess
# Generate evolution report
python3 {baseDir}/scripts/evolution.py --report --output evolution-report.md
Sources of experience data:
.learnings/ - Errors, corrections, feature requestsmemory/YYYY-MM-DD.md - Daily interaction logsMEMORY.md - Long-term memory updatesIdentify recurring patterns:
bash
# Find repeated error patterns
python3 {baseDir}/scripts/evolution.py --pattern errors --threshold 3
# Find successful workflows
python3 {baseDir}/scripts/evolution.py --pattern successes --min-occurrences 5
# Find optimization opportunities
python3 {baseDir}/scripts/evolution.py --pattern inefficiencies
Pattern categories:
Transform patterns into actionable rules:
bash
# Auto-extract learnings
python3 {baseDir}/scripts/evolution.py --learn --auto
# Interactive learning session
python3 {baseDir}/scripts/evolution.py --learn --interactive
Output: Candidate rules for behavioral files
Test proposed changes:
bash
# Validate a proposed change
python3 {baseDir}/scripts/evolution.py --validate --rule "Always use git status before commit"
# Simulate behavior change
python3 {baseDir}/scripts/evolution.py --simulate --file SOUL.md --change "Be more concise"
Apply validated changes:
bash
# Apply to behavioral files
python3 {baseDir}/scripts/evolution.py --integrate --target SOUL.md
# Update workflow rules
python3 {baseDir}/scripts/evolution.py --integrate --target AGENTS.md
Evolution triggers:
Example evolutions:
markdown
# Before
"Be helpful and thorough"
# After (evolved)
"Be concise and direct. Skip disclaimers. Act, don't explain."
Evolution triggers:
Example evolutions:
markdown
# Before
"Check files before editing"
# After (evolved)
"Always read file first. Use edit tool only after confirming structure.
For files >500 lines, read in chunks with offset/limit."
Evolution triggers:
Example evolutions:
markdown
# Added after learning
### agent-browser
- Always use `--json` for parsing
- Wait 2s after navigation before snapshot
- Close browser after each session to prevent memory leak
bash
# Find recurring errors
python3 {baseDir}/scripts/evolution.py \
--analyze errors \
--source .learnings/ERRORS.md \
--threshold 3 \
--output patterns/errors.json
Example pattern:
json
{
"pattern_id": "ERR-PATTERN-001",
"description": "File not found errors when using relative paths",
"occurrences": 5,
"first_seen": "2025-01-10",
"last_seen": "2025-01-20",
"suggested_rule": "Always resolve paths relative to workspace root",
"target_file": "AGENTS.md"
}
bash
# Find successful workflows
python3 {baseDir}/scripts/evolution.py \
--analyze successes \
--source memory/ \
--min-effectiveness 0.8
bash
# Extract user preferences from corrections
python3 {baseDir}/scripts/evolution.py \
--analyze preferences \
--source .learnings/LEARNINGS.md \
--category correction
Track evolution effectiveness:
bash
# Generate metrics
python3 {baseDir}/scripts/evolution.py --metrics --period 30d
# Output
MetricDescriptionTargetError Reduction Rate% decrease in recurring errors>50%Rule Adoption Rate% of proposed rules integrated>70%User Satisfaction TrendPositive feedback ratio>0.8Efficiency GainTime saved per interactionMeasurableLearning VelocityNew rules per weekSustainable
Add to heartbeat or cron:
bash
# Weekly self-assessment
python3 {baseDir}/scripts/evolution.py --self-assess --auto-evolve
# Output to evolution log
python3 {baseDir}/scripts/evolution.py --self-assess --log evolution-log.md
This skill builds on self-improvement:
self-improvement logs individual learningsself-evolution analyzes patterns across learningsself-evolution proposes behavioral changesself-improvement tracks the change as a learningWorkflow:
bash
# Log a learning (self-improvement)
# → .learnings/LEARNINGS.md
# Pattern detection (self-evolution)
python3 {baseDir}/scripts/evolution.py --analyze --source .learnings/
# Proposed change appears
# → "Pattern: 5 occurrences of 'forgot to read file first'"
# Validate and integrate
python3 {baseDir}/scripts/evolution.py --integrate --approve
# → AGENTS.md updated
# Track as learning (self-improvement)
# → "Promoted rule: Always read before edit"
Trigger evolution when:
SignalThresholdActionSame error 3+ timesPattern detectedCreate prevention ruleUser correction pattern2+ similar correctionsUpdate behaviorWorkflow optimization20%+ efficiency gainUpdate workflowTool discoveryNew capability foundUpdate TOOLS.mdPreference patternConsistent user preferenceUpdate SOUL.md
FileEvolution TypeFrequencySOUL.mdPersonality, principlesRarelyAGENTS.mdWorkflows, rulesOftenTOOLS.mdTool knowledgeAs discoveredMEMORY.mdKey factsContinuously
Before any evolution:
bash
# Create backup before evolution
python3 {baseDir}/scripts/evolution.py --backup
# Rollback if needed
python3 {baseDir}/scripts/evolution.py --rollback --to "2025-01-20"
bash
# Generate comprehensive report
python3 {baseDir}/scripts/evolution.py --report --full
# Output
markdown
# Evolution Report: 2025-01-20
## Patterns Detected
- 3 error patterns (2 addressed)
- 5 success patterns (3 documented)
- 2 preference patterns (integrated)
## Rules Proposed
1. "Always read file before editing" → AGENTS.md
2. "Prefer concise over thorough" → SOUL.md
## Metrics
- Error reduction: 45%
- User satisfaction: 0.85
- Efficiency gain: 12%
## Next Actions
- Validate rule #1
- Review preference pattern #2
bash
# Show what changed over time
python3 {baseDir}/scripts/evolution.py --diff --since "30 days ago"
Create custom detectors in scripts/detectors/:
python
# scripts/detectors/custom_detector.py
def detect_pattern(entries):
"""Custom pattern detection logic"""
# Return list of detected patterns
pass
Register:
bash
python3 {baseDir}/scripts/evolution.py \
--register-detector custom_detector \
--path scripts/detectors/custom_detector.py
Trigger evolution on specific events:
yaml
# hooks/evolution-hooks.yaml
on_error:
- pattern: "file not found"
action: "analyze"
threshold: 3
on_user_correction:
- action: "learn_preference"
immediate: true
on_workflow_success:
- action: "document_pattern"
min_repetitions: 3
bash
# Use memory context for evolution
python3 {baseDir}/scripts/evolution.py --analyze --with-memory
# Propose rules based on memory patterns
python3 {baseDir}/scripts/evolution.py --extract-patterns --source MEMORY.md
bash
# Feed patterns to self-improvement
python3 {baseDir}/scripts/evolution.py --feed-to self-improvement
# Use learnings as evolution source
python3 {baseDir}/scripts/evolution.py --analyze --source .learnings/