Agent Learning Loop
Track task outcomes, accumulate experience, and improve execution over time. Turns every task into a learning opportunity.
Commands
Run via: python3 scripts/agent-learning-loop.py
Core Commands
record --task— Record a task execution and its outcome--approach --outcome [--duration ] [--notes ] suggest --task— Get the best known approach for a task type (based on history)patterns— Analyze and display discovered task patternsstats— Show overall learning metrics (success rate, improvement trend, top patterns)review --days— Review recent task history for learning opportunitiesprune --older-than— Archive old entries, keeping distilled learnings
Options
--category— Task category (coding, research, writing, ops, finance, etc.)--json— JSON output--min-confidence <0-100>— Minimum confidence for suggestions (default: 60)
How It Works
1. Record Phase
After each significant task, record what was done and how it went:
agent-learning-loop.py record \
--task "Deploy Cloudflare Pages site" \
--approach "wrangler pages deploy with --commit-dirty flag" \
--outcome success \
--duration 45 \
--category ops
2. Pattern Recognition
The system clusters similar tasks and identifies:
- Winning approaches — What works consistently for this task type
- Failure modes — Common reasons tasks fail
- Time patterns — How long similar tasks typically take
- Category trends — Which categories are improving
3. Suggestion Phase
Before starting a familiar task, ask for the best approach:
agent-learning-loop.py suggest --task "Deploy website to Cloudflare"
Returns the highest-scoring approach with confidence level.
Data Storage
memory/learning-loop.json— Task history and pattern databasememory/learning-patterns.json— Extracted patterns and winning approaches
Pattern Matching
Tasks are matched using:
1. Keyword overlap — Shared significant words between task descriptions
2. Category match — Same category boosts match score
3. Outcome weighting — Recent successes weighted higher than old ones
4. Decay — Older entries contribute less (30-day half-life)
Cron Integration
Schedule a daily review to extract patterns:
agent-learning-loop.py review --days 1
References
- See
references/pattern-extraction.mdfor the pattern matching algorithm details