Install
openclaw skills install self-evolution-engineAutonomous self-improvement engine that learns from interactions, identifies patterns, and evolves behavior over time. Use when: (1) Analyzing interaction patterns for improvement, (2) Running periodic self-assessment, (3) Extracting reusable patterns from workflows, (4) Optimizing decision-making processes, (5) Integrating feedback into behavioral changes. Triggers on '自我进化', 'self-evolution', '自我改进', '学习模式', 'pattern analysis', 'optimize behavior'.
openclaw skills install self-evolution-engineAutonomous learning and improvement system that continuously evolves agent behavior based on interaction patterns, feedback, and outcomes.
Experience → Pattern Detection → Learning → Validation → Integration
↑ ↓
└────────────────── Feedback Loop ←───────────────────────┘
| Component | Purpose | Frequency |
|---|---|---|
| Observer | Capture interaction patterns | Continuous |
| Analyzer | Identify improvement opportunities | Daily |
| Learner | Extract actionable rules | On trigger |
| Validator | Test changes in isolation | Before integration |
| Integrator | Update behavioral files | After validation |
# 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:
# 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:
# 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:
# 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:
# 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:
# Before
"Be helpful and thorough"
# After (evolved)
"Be concise and direct. Skip disclaimers. Act, don't explain."
Evolution triggers:
Example evolutions:
# 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:
# 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
# Find recurring errors
python3 {baseDir}/scripts/evolution.py \
--analyze errors \
--source .learnings/ERRORS.md \
--threshold 3 \
--output patterns/errors.json
Example pattern:
{
"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"
}
# Find successful workflows
python3 {baseDir}/scripts/evolution.py \
--analyze successes \
--source memory/ \
--min-effectiveness 0.8
# Extract user preferences from corrections
python3 {baseDir}/scripts/evolution.py \
--analyze preferences \
--source .learnings/LEARNINGS.md \
--category correction
Track evolution effectiveness:
# Generate metrics
python3 {baseDir}/scripts/evolution.py --metrics --period 30d
# Output
| Metric | Description | Target |
|---|---|---|
| Error Reduction Rate | % decrease in recurring errors | >50% |
| Rule Adoption Rate | % of proposed rules integrated | >70% |
| User Satisfaction Trend | Positive feedback ratio | >0.8 |
| Efficiency Gain | Time saved per interaction | Measurable |
| Learning Velocity | New rules per week | Sustainable |
Add to heartbeat or cron:
# 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:
# 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:
| Signal | Threshold | Action |
|---|---|---|
| Same error 3+ times | Pattern detected | Create prevention rule |
| User correction pattern | 2+ similar corrections | Update behavior |
| Workflow optimization | 20%+ efficiency gain | Update workflow |
| Tool discovery | New capability found | Update TOOLS.md |
| Preference pattern | Consistent user preference | Update SOUL.md |
| File | Evolution Type | Frequency |
|---|---|---|
| SOUL.md | Personality, principles | Rarely |
| AGENTS.md | Workflows, rules | Often |
| TOOLS.md | Tool knowledge | As discovered |
| MEMORY.md | Key facts | Continuously |
Before any evolution:
# Create backup before evolution
python3 {baseDir}/scripts/evolution.py --backup
# Rollback if needed
python3 {baseDir}/scripts/evolution.py --rollback --to "2025-01-20"
# Generate comprehensive report
python3 {baseDir}/scripts/evolution.py --report --full
# Output
# 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
# Show what changed over time
python3 {baseDir}/scripts/evolution.py --diff --since "30 days ago"
Create custom detectors in scripts/detectors/:
# scripts/detectors/custom_detector.py
def detect_pattern(entries):
"""Custom pattern detection logic"""
# Return list of detected patterns
pass
Register:
python3 {baseDir}/scripts/evolution.py \
--register-detector custom_detector \
--path scripts/detectors/custom_detector.py
Trigger evolution on specific events:
# 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
# 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
# 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/