"An AI agent that learns from every interaction, accumulating patterns and insights to continuously improve its own capabilities." — Based on 2025 lifelong learning research
This is a universal self-improvement system that learns from ALL task experiences. It implements a complete feedback loop:
ResearchKey InsightApplicationSimpleMemEfficient lifelong memoryPattern accumulation systemMulti-Memory SurveySemantic + Episodic memoryWorld knowledge + experiencesLifelong LearningContinuous task stream learningLearn from every taskEvo-MemoryTest-time lifelong learningReal-time adaptation
text
┌──────────────────────────────────────────────────────────────┐
│ UNIVERSAL SELF-IMPROVEMENT │
├──────────────────────────────────────────────────────────────┤
│ │
│ Task Event → Extract Experience → Abstract Pattern → Update │
│ │ │ │ │ │
│ ▼ ▼ ▼ ▼ │
│ ┌────────────────────────────────────────────────────────┐ │
│ │ MULTI-MEMORY SYSTEM │ │
│ ├────────────────────────────────────────────────────────┤ │
│ │ Semantic Memory │ Episodic Memory │ Working Memory │ │
│ │ (Patterns/Rules) │ (Experiences) │ (Current) │ │
│ │ memory/self-improving/semantic/ │ memory/self-improving/episodic/ │ memory/self-improving/working/ │ │
│ └────────────────────────────────────────────────────────┘ │
│ │
│ ┌────────────────────────────────────────────────────────┐ │
│ │ FEEDBACK LOOP │ │
│ │ User Feedback → Confidence Update → Pattern Adapt │ │
│ └────────────────────────────────────────────────────────┘ │
│ │
└──────────────────────────────────────────────────────────────┘
EventActionAny significant task completesExtract patterns, propose skill updates (requires user confirmation)An error or failure occursCapture error context, trigger self-correction (requires user confirmation before applying fixes)Session endsConsolidate working memory into long-term memory
Before accessing any memory files, the agent MUST first determine the workspace root path:
.git/, package.json, pom.xml, etc.){workspace}/memory/self-improving/The Self-Improving Agent's memory lives inside the Agent's memory/ directory as a dedicated subdirectory. This design ensures:
MEMORY.md, memory/YYYY-MM-DD.md) and Self-Improving Agent's memory ( memory/self-improving/) are clearly separated by directory structurememory/ and naturally find self-improving insightstext
{workspace}/
├── MEMORY.md # Agent core memory (Self-Improving Agent can append)
├── memory/
│ ├── YYYY-MM-DD.md # Agent daily memory (Self-Improving Agent can append)
│ └── self-improving/ # Self-Improving Agent dedicated memory space
│ ├── semantic/
│ │ └── patterns.json # Abstract patterns and rules
│ ├── episodic/
│ │ └── YYYY/
│ │ └── YYYY-MM-DD-{task}.json # Specific experiences
│ ├── working/
│ │ ├── current_session.json # Active session data
│ │ ├── last_error.json # Error context for self-correction
│ │ └── session_end.json # Session end marker for consolidation
│ └── index.json # Memory index and metrics
ActionTargetConditionReadMEMORY.mdAlways — to understand Agent's accumulated knowledgeReadmemory/YYYY-MM-DD.mdAlways — to understand today's contextAppend toMEMORY.mdOnly high-confidence patterns (>= 0.9), requires user confirmationAppend tomemory/YYYY-MM-DD.mdSession summary and key learnings, requires user confirmationFull CRUDmemory/self-improving/*Self-Improving Agent's own memory space, free to manage
Trigger evolution when new reusable knowledge appears:
TriggerPriorityActionNew workflow pattern discoveredHighAdd to relevant skill guidanceArchitecture/design tradeoff clarifiedHighAdd to decision patternsDebugging fix or anti-pattern foundHighAdd to troubleshooting patternsSecurity or performance insightHighAdd to best practice patternsCode pattern or idiom learnedMediumAdd to coding patternsTest strategy improvementMediumUpdate testing approachTool usage optimizationMediumUpdate tool usage patternsDocumentation structure insightLowUpdate documentation templates
memory/self-improving/semantic/patterns.json)#Stores abstract patterns and rules reusable across contexts:
json
{
"patterns": {
"pat-2025-01-11-001": {
"id": "pat-2025-01-11-001",
"name": "Pattern Name",
"source": "user_feedback|implementation_review|retrospective",
"confidence": 0.95,
"applications": 5,
"created": "2025-01-11",
"last_applied": "2025-01-15",
"category": "coding_patterns|architecture|debugging|workflow|...",
"pattern": "One-line summary",
"problem": "What problem does this solve?",
"solution": "How to apply this pattern",
"quality_rules": ["Rule 1", "Rule 2"],
"target_skills": ["skill-name-1", "skill-name-2"]
}
}
}
memory/self-improving/episodic/)#Stores specific experiences and what happened:
json
{
"id": "ep-2025-01-11-001",
"timestamp": "2025-01-11T10:30:00Z",
"skill": "debugger|coding-assistant|reviewer|...",
"task_type": "debugging|coding|review|design|...",
"situation": "What the user was trying to do",
"solution": "How the issue was resolved",
"outcome": "success|partial|failure",
"root_cause": "Underlying issue if applicable",
"lesson": "Key takeaway from this experience",
"related_pattern": "pattern_id if linked",
"user_feedback": {
"rating": 8,
"comments": "User's feedback on the experience"
}
}
memory/self-improving/working/)#Stores current session context — ephemeral data that gets consolidated at session end:
json
{
"session_id": "session-2025-01-11-001",
"started": "2025-01-11T10:00:00Z",
"tasks_completed": [],
"errors_encountered": [],
"patterns_applied": [],
"pending_extractions": []
}
After any significant task completes, extract:
yaml
What happened:
task_type: {what kind of task}
task: {what was being done}
outcome: {success|partial|failure}
Key Insights:
what_went_well: [what worked]
what_went_wrong: [what didn't work]
root_cause: {underlying issue if applicable}
User Feedback:
rating: {1-10 if provided}
comments: {specific feedback}
Convert experiences to reusable patterns. The goal is to go from concrete to abstract — patterns should be general enough to apply across different tasks but specific enough to be actionable.
Concrete ExperienceAbstract Pattern"User forgot to save intermediate work""Always persist intermediate results to files""Code review missed SQL injection""Add security checklist to review process""Callback was empty, causing silent failure""Verify all callbacks have implementations""Ambiguous UI spec caused rework""UI specs need exact layout specifications"
Abstraction Rules:
yaml
If experience_repeats 3+ times:
pattern_level: critical
action: Add to "Critical Mistakes" or "Anti-Patterns" section
If solution_was_effective:
pattern_level: best_practice
action: Add to "Best Practices" section
If user_rating >= 7:
pattern_level: strength
action: Reinforce this approach in relevant skills
If user_rating <= 4:
pattern_level: weakness
action: Add to "What to Avoid" section
IMPORTANT: User Confirmation Required — Before writing any changes to skill files, you MUST:
Present proposed changes — Show the user a clear summary of what will be modified:
Wait for explicit approval — Do NOT proceed until the user confirms. Acceptable confirmations include explicit affirmative responses (e.g., "确认", "好的", "proceed", "yes").
Apply changes only after approval — Once confirmed, apply the changes with evolution markers for traceability.
If the user rejects or requests modifications, adjust the proposed changes accordingly and re-present for confirmation.
Proposed Change Summary Format:
markdown
## Proposed Skill Update
**Target**: `{skill-file-path}`
**Action**: {Add new pattern | Correct existing guidance | Update checklist}
**Source**: {episode_id or trigger}
**Confidence**: {X.XX}
### Changes Preview
{Show the exact content that will be added/modified, using diff-style or before/after format}
### Rationale
{Why this change is recommended}
---
Confirm this update? (yes/no/modify)
Once confirmed, update skill files with evolution markers for traceability:
markdown
<!-- Evolution: 2025-01-12 | source: ep-2025-01-12-001 | task: debugging -->
## Pattern Added (2025-01-12)
**Pattern**: Always verify callbacks are not empty functions
**Source**: Episode ep-2025-01-12-001
**Confidence**: 0.95
### Updated Checklist
- [ ] Verify all callbacks have implementations
- [ ] Test callback execution paths
Correction Markers (when fixing wrong guidance):
markdown
<!-- Correction: 2025-01-12 | was: "Use callback chain" | reason: caused stale state -->
## Corrected Guidance
Use direct state monitoring instead of callback chains for reactive updates.
Use the templates in templates/ for consistent formatting. See references/appendix.md for the full template structures.
Update semantic memory — add or update patterns in memory/self-improving/semantic/patterns.json
Store episodic memory — write episode to memory/self-improving/episodic/YYYY/YYYY-MM-DD-{task}.json
Update pattern confidence — increase confidence for patterns that were successfully applied, decrease for those that led to errors
Prune outdated patterns — lower confidence for patterns with no recent applications; archive patterns below 0.3 confidence
Supplement Agent memory — propose additions to Agent's own memory files. User confirmation is REQUIRED before any write to MEMORY.md or memory/YYYY-MM-DD.md. Follow the same confirmation protocol as Phase 3:
What to propose:
MEMORY.mdmemory/YYYY-MM-DD.mdConfirmation format: markdown
## Proposed Agent Memory Update
### → MEMORY.md (append)
{Exact content to be appended, preview here}
### → memory/YYYY-MM-DD.md (append)
{Exact content to be appended, preview here}
**Source patterns**: {pattern IDs and confidence levels}
---
Confirm this memory update? (yes/no/modify)
After approval:
<!-- Source: self-improving-agent | date: YYYY-MM-DD --> markers for traceabilityTriggered when:
Process:
memory/self-improving/working/last_error.jsonPeriodically (or when triggered manually), verify that stored patterns and skill guidance are still accurate:
Use the validation template in templates/validation-template.md for structured reviews.
After each self-improvement cycle, present a summary to the user:
markdown
## Self-Improvement Summary
I've learned from our session and updated:
### Patterns Extracted
1. **pattern_name**: Description (confidence: X.XX)
### Skills/Documents Updated
- `skill-name`: What was updated
### Confidence Levels
- New patterns: ~0.85 (needs more validation)
- Reinforced patterns: ~0.95 (well-established)
### Your Feedback
- Were these updates helpful?
- Should I apply any pattern more broadly?
- Any corrections needed?
Integrate feedback into confidence scoring:
FeedbackActionPositive (rating >= 7)Increase confidence, consider expanding to related skillsNeutral (rating 4-6)Keep pattern, gather more data before expandingNegative (rating <= 3)Decrease confidence, revise or archive pattern
MEMORY.md, memory/YYYY-MM-DD.md)MEMORY.md and today's memory/YYYY-MM-DD.md at the start of each self-improvement cycle for contextAfter any significant task completes, this agent:
For detailed memory structures, validation templates, metrics, and workflow diagrams, read references/appendix.md.
For pattern/correction/validation templates, see the templates/ directory:
templates/pattern-template.md — Adding new patternstemplates/correction-template.md — Fixing incorrect guidancetemplates/validation-template.md — Validating skill accuracy