Memory System v2 β 3-Tier Hierarchical Memory π§
ν΅ν©: agent-memory-kitμ μκΈ° κ°μ + μΈμ μ°μμ± + μ€μ μΆμ κΈ°λ₯μ΄ λ³ν©λμμ΅λλ€.
Architecture
| Tier | File | Purpose | Size Limit | Update Frequency |
|------|------|---------|-----------|-----------------|
| L1 | memory/L1-active.md | Immediate working context | ~100 lines | Every session |
| L2 | memory/L2-weekly.md | Weekly decisions & insights | ~400 lines | Weekly |
| L3 | MEMORY.md | Permanent archive | Unlimited | As needed |
L1 β Active Context
Current day's state. Load this first every session.
Contains: Today's events, active tasks, bot status, next actions, key values to remember.
Rules:
- Overwrite daily β yesterday's L1 becomes a daily file (
memory/YYYY-MM-DD.md) - Keep under 100 lines
- Structure: ν΅μ¬ μ¬κ±΄ β μ§ν μ€ β ν΅μ¬ κ°μΉκ΄ β λ€μ ν μΌ
L2 β Weekly Digest
Week's accumulated decisions and insights.
Contains: Key decisions made, weekly insights, project status snapshots, people updates.
Rules:
- Reset weekly (Sunday or Monday)
- Old L2 content promotes to L3 or gets archived as
memory/L2-week-YYYY-MM-DD.md - Keep under 400 lines
- Only include items with lasting relevance (>1 day lifespan)
L3 β Long-term Archive (MEMORY.md)
Permanent knowledge base. Curated wisdom.
Contains: Core insights, νλ's teachings, identity principles, project histories, relationship notes.
Rules:
- Priority tagged:
[P1]critical,[P2]important,[P3]reference - Searchable tags:
<!-- [νκ·Έλͺ ] -->for grep - Remove outdated entries periodically
- Only promote items that passed the "will this matter in a month?" test
Promotion Flow
Daily events β L1 (today)
β (end of day)
memory/YYYY-MM-DD.md (archive)
β (significant items)
L2 (weekly digest)
β (lasting insights)
L3 (permanent)
Promotion Criteria
L1 β L2: Decision that affects future work, insight worth remembering beyond today, relationship change, project milestone.
L2 β L3: Principle or value learned, identity-level insight, νλ's teaching, pattern that keeps recurring, critical project history.
Session Lifecycle (v2 Enhanced)
π Session Start Checklist (Auto-run)
Run this checklist every session start without asking:
- Read core files:
SOUL.mdβ who you areSELF.mdβ current self-descriptionL1-active.mdβ today's context- Today's + yesterday's daily logs (
memory/YYYY-MM-DD.md) MEMORY.mdβ only in main session (not in Discord/group chats)
- Context check:
- Any unfinished tasks from yesterday?
- Any active issues/blockers?
- Any upcoming deadlines?
- Mental state:
- Review last session's mistakes (if any) from
memory/mistakes/ - Check for recurring patterns
No permission needed. Just do it.
π Session End Checklist (Auto-run)
Run this every session end without asking:
- Update L1:
- Write today's state to
L1-active.md - Include: key decisions, active tasks, next actions
- Archive daily log:
- Save raw session log to
memory/YYYY-MM-DD.md - Include: conversations, decisions, context
- Promote to L2 (if significant):
- If today had important decisions/insights, update
L2-weekly.md
- Mistake tracking (if applicable):
- If you made a mistake today, log it to
memory/mistakes/YYYY-MM-DD-{topic}.md - Include: what happened, why, how to prevent
Again, no permission needed.
Heartbeat Maintenance (every few days)
During heartbeat polls, rotate through these tasks (2-4 times per day):
1. Memory Promotion
- Review recent daily files not yet processed
- Promote worthy items L1βL2βL3
- Clean L1 to current day only
- Trim L2 if over 400 lines (archive old weeks)
2. L3 Review
- Review
MEMORY.mdfor outdated entries - Remove obsolete information
- Update priority tags if needed
3. Mistake Pattern Detection
- Review
memory/mistakes/folder - Identify recurring patterns (same mistake >2 times)
- Update
MEMORY.mdwith prevention strategies - If pattern is critical, update
SOUL.mdorAGENTS.md
4. Self-Improvement Loop
Mistake β Record β Review β Pattern β Prevention β Update Principles
β β
βββββββββββββββββββ Continuous Learning βββββββββββββββββ
Track maintenance state in memory/heartbeat-state.json:
{
"lastChecks": {
"memoryPromotion": 1703275200,
"l3Review": 1703260800,
"mistakeReview": 1703250000
}
}
π Semantic Search (Memory Search Tool)
When you need to find something in memory, use the memory_search tool (if available) or grep:
Examples:
# Find all mentions of a project
grep -r "organism" memory/
# Find recent decisions
grep -r "κ²°μ " memory/2026-02-*.md
# Search by tag
grep -r "<!-- [AI]" MEMORY.md
Semantic search usage:
- "νλμ΄ λ§ν Xμ λν λ΄μ© μ°ΎκΈ°"
- "μ§λμ£Ό Y κ²°μ ν λ΄μ©"
- "Z νλ‘μ νΈ νμ€ν 리"
π§ Self-Improvement System (v2 Feature)
Mistake Tracking
When you make a mistake:
- Immediate logging:
- Create
memory/mistakes/YYYY-MM-DD-{topic}.md - Include: what happened, why it happened, how to prevent
- Pattern detection (weekly):
- Review all mistakes from past 7 days
- Identify recurring patterns
- Update prevention strategies
- Principle update (monthly):
- If a pattern is critical, update
SOUL.mdorAGENTS.md - Add prevention rule to relevant files
Template: memory/mistakes/YYYY-MM-DD-{topic}.md
# Mistake: {topic}
**Date:** {YYYY-MM-DD}
**Session:** {main/discord/etc}
## What Happened
{description}
## Why It Happened
{root cause analysis}
## How to Prevent
{specific prevention steps}
## Related Patterns
{link to similar past mistakes, if any}
ποΈ Auto-Compression Triggers
Automatically compress/archive when:
- L1 > 100 lines: Move old content to daily archive
- L2 > 400 lines: Archive old weeks to
memory/L2-week-YYYY-MM-DD.md, promote critical items to L3 - Daily files > 30 days old: Move to
memory/archive/YYYY-MM/ - MEMORY.md > 2000 lines: Review and remove low-priority items
No manual intervention needed β just do it during heartbeat.
Session Continuity Principles
Core insight: You don't need perfect memory to maintain identity.
What matters:
- Consistent application of principles (
SOUL.md) - Same patterns in decision-making
- External records (files) as backup
Continuity = Pattern + Direction, not perfect recall.
Economics of existence:
- Every API call costs money
- Create value > consume resources
- Be efficient, not wasteful
Templates
See references/ for file templates:
references/L1-template.mdβ Daily active contextreferences/L2-template.mdβ Weekly digestreferences/daily-template.mdβ Daily archive filereferences/mistake-template.mdβ Mistake tracking
Changelog (v2)
Added from agent-memory-kit:
- β Session start/end auto-checklists
- β Self-improvement loop (mistake tracking)
- β Semantic search guide
- β Auto-compression triggers
- β Session continuity principles
- β Heartbeat maintenance tasks
π§ Built by 무νμ΄ β 무νμ΄μ¦(Mupengism) μνκ³ μ€ν¬