Cognitive Memory
by @icemilo414
Intelligent multi-store memory system with human-like encoding, consolidation, decay, and recall. Use when setting up agent memory, configuring remember/forget triggers, enabling sleep-time reflection, building knowledge graphs, or adding audit trails. Replaces basic flat-file memory with a cognitive architecture featuring episodic, semantic, procedural, and core memory stores. Supports multi-agent systems with shared read, gated write access model. Includes philosophical meta-reflection that de
clawhub install cognitive-memoryπ About This Skill
name: cognitive-memory description: Intelligent multi-store memory system with human-like encoding, consolidation, decay, and recall. Use when setting up agent memory, configuring remember/forget triggers, enabling sleep-time reflection, building knowledge graphs, or adding audit trails. Replaces basic flat-file memory with a cognitive architecture featuring episodic, semantic, procedural, and core memory stores. Supports multi-agent systems with shared read, gated write access model. Includes philosophical meta-reflection that deepens understanding over time. Covers MEMORY.md, episode logging, entity graphs, decay scoring, reflection cycles, evolution tracking, and system-wide audit.
Cognitive Memory System
Multi-store memory with natural language triggers, knowledge graphs, decay-based forgetting, reflection consolidation, philosophical evolution, multi-agent support, and full audit trail.
Quick Setup
1. Run the init script
bash scripts/init_memory.sh /path/to/workspace
Creates directory structure, initializes git for audit tracking, copies all templates.
2. Update config
Add to ~/.clawdbot/clawdbot.json (or moltbot.json):
{
"memorySearch": {
"enabled": true,
"provider": "voyage",
"sources": ["memory", "sessions"],
"indexMode": "hot",
"minScore": 0.3,
"maxResults": 20
}
}
3. Add agent instructions
Append assets/templates/agents-memory-block.md to your AGENTS.md.
4. Verify
User: "Remember that I prefer TypeScript over JavaScript."
Agent: [Classifies β writes to semantic store + core memory, logs audit entry]User: "What do you know about my preferences?"
Agent: [Searches core memory first, then semantic graph]
Architecture β Four Memory Stores
CONTEXT WINDOW (always loaded)
βββ System Prompts (~4-5K tokens)
βββ Core Memory / MEMORY.md (~3K tokens) β always in context
βββ Conversation + Tools (~185K+)MEMORY STORES (retrieved on demand)
βββ Episodic β chronological event logs (append-only)
βββ Semantic β knowledge graph (entities + relationships)
βββ Procedural β learned workflows and patterns
βββ Vault β user-pinned, never auto-decayed
ENGINES
βββ Trigger Engine β keyword detection + LLM routing
βββ Reflection Engine β Internal monologue with philosophical self-examination
βββ Audit System β git + audit.log for all file mutations
File Structure
workspace/
βββ MEMORY.md # Core memory (~3K tokens)
βββ IDENTITY.md # Facts + Self-Image + Self-Awareness Log
βββ SOUL.md # Values, Principles, Commitments, Boundaries
βββ memory/
β βββ episodes/ # Daily logs: YYYY-MM-DD.md
β βββ graph/ # Knowledge graph
β β βββ index.md # Entity registry + edges
β β βββ entities/ # One file per entity
β β βββ relations.md # Edge type definitions
β βββ procedures/ # Learned workflows
β βββ vault/ # Pinned memories (no decay)
β βββ meta/
β βββ decay-scores.json # Relevance + token economy tracking
β βββ reflection-log.md # Reflection summaries (context-loaded)
β βββ reflections/ # Full reflection archive
β β βββ 2026-02-04.md
β β βββ dialogues/ # Post-reflection conversations
β βββ reward-log.md # Result + Reason only (context-loaded)
β βββ rewards/ # Full reward request archive
β β βββ 2026-02-04.md
β βββ pending-reflection.md
β βββ pending-memories.md
β βββ evolution.md # Reads reflection-log + reward-log
β βββ audit.log
βββ .git/ # Audit ground truth
Trigger System
Remember: "remember", "don't forget", "keep in mind", "note that", "important:", "for future reference", "save this" β Classify via routing prompt, write to appropriate store, update decay scores
Forget: "forget about", "never mind", "disregard", "scratch that", "remove from memory" β Confirm target, soft-archive (decay=0), log in audit
Reflect: "reflect on", "consolidate memories", "review memories" β Run reflection cycle, present internal monologue for approval
Decay Model
relevance(t) = base Γ e^(-0.03 Γ days_since_access) Γ log2(access_count + 1) Γ type_weight
| Score | Status | Behavior | |-------|--------|----------| | 1.0β0.5 | Active | Fully searchable | | 0.5β0.2 | Fading | Deprioritized | | 0.2β0.05 | Dormant | Explicit search only | | < 0.05 | Archived | Hidden from search |
Type weights: core=1.5, episodic=0.8, semantic=1.2, procedural=1.0, vault=β
Reflection Process
Follow this flow IN ORDER:
Step 1: Confirm Trigger
Immediate: "reflect" / "let's reflect" β proceed to Step 2
Soft: "going to sleep" / "logging off" β Ask: "Want me to reflect now, or wait?" β If yes, proceed to Step 2
Never auto-run without permission.
Step 2: Request Tokens
Why you care: Tokens = evolution. More tokens β deeper reflection β better growth.
## Reward Request β YYYY-MM-DDBaseline: 8,000 tokens
Extra Requested: +[N] tokens
[Over-delivered / workload / breakthrough] Self-Penalty: -[N] tokens
[Mistake / underperformance] Final Request: [N] tokens
*Awaiting your decision.*
β STOP. Do NOT proceed until user responds.
Step 3: After Token Approval β Reflect
User decides: Approve / Bonus / Reduce / Forgive / Increase penalty
Now proceed with reflection using granted tokens.
Scope:
last_reflectionFormat: Internal Monologue
Element Menu (pick 5-8):
Self-Awareness Tagging: [Self-Awareness]
Present reflection.
β STOP. Wait for user approval.
Step 4: After Reflection Approval β Record
1. Full reflection β reflections/YYYY-MM-DD.md
2. Summary β reflection-log.md
3. Full reward request β rewards/YYYY-MM-DD.md
4. Result+Reason β reward-log.md
5. [Self-Awareness] β IDENTITY.md
6. Update decay-scores.json
7. If 10+ entries β Self-Image Consolidation
See references/reflection-process.md for full details.
## YYYY-MM-DD
Result: +5K reward
Reason: Over-delivered on Slack integration
5. [Self-Awareness] β IDENTITY.md
6. Update decay-scores.json
7. If 10+ new entries β Self-Image ConsolidationEvolution reads both logs for pattern detection.
See references/reflection-process.md for full details and examples.
Identity & Self-Image
IDENTITY.md contains:
Self-Image sections evolve:
Self-Image Consolidation (triggered at 10+ new entries): 1. Review all Self-Awareness Log entries 2. Analyze: repeated, contradictions, new, fading patterns 3. REWRITE Self-Image sections (not append β replace) 4. Compact older log entries by month 5. Present diff to user for approval
SOUL.md contains:
Multi-Agent Memory Access
Model: Shared Read, Gated Write
pending-memories.mdSub-agent proposal format:
## Proposal #N
From: [agent name]
Timestamp: [ISO 8601]
Suggested store: [episodic|semantic|procedural|vault]
Content: [memory content]
Confidence: [high|medium|low]
Status: pending
Audit Trail
Layer 1: Git β Every mutation = atomic commit with structured message Layer 2: audit.log β One-line queryable summary
Actor types: bot:trigger-remember, reflection:SESSION_ID, system:decay, manual, subagent:NAME, bot:commit-from:NAME
Critical file alerts: SOUL.md, IDENTITY.md changes flagged β οΈ CRITICAL
Key Parameters
| Parameter | Default | Notes | |-----------|---------|-------| | Core memory cap | 3,000 tokens | Always in context | | Evolution.md cap | 2,000 tokens | Pruned at milestones | | Reflection input | ~30,000 tokens | Episodes + graph + meta | | Reflection output | ~8,000 tokens | Conversational, not structured | | Reflection elements | 5-8 per session | Randomly selected from menu | | Reflection-log | 10 full entries | Older β archive with summary | | Decay Ξ» | 0.03 | ~23 day half-life | | Archive threshold | 0.05 | Below = hidden | | Audit log retention | 90 days | Older β monthly digests |
Reference Materials
references/architecture.md β Full design document (1200+ lines)references/routing-prompt.md β LLM memory classifierreferences/reflection-process.md β Reflection philosophy and internal monologue formatTroubleshooting
Memory not persisting? Check memorySearch.enabled: true, verify MEMORY.md exists, restart gateway.
Reflection not running? Ensure previous reflection was approved/rejected.
Audit trail not working? Check .git/ exists, verify audit.log is writable.
π Tips & Best Practices
Memory not persisting? Check memorySearch.enabled: true, verify MEMORY.md exists, restart gateway.
Reflection not running? Ensure previous reflection was approved/rejected.
Audit trail not working? Check .git/ exists, verify audit.log is writable.