← Back to Skills Marketplace
shenmeng

Long-Term Memory Manager

by shenmeng · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ Security Clean
165
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install longterm-memory-manager
Description
Long-term memory management system for maintaining MEMORY.md, consolidating daily memories, and extracting key insights. Use when: (1) Consolidating daily me...
README (SKILL.md)

Long-Term Memory Management

Systematic management of MEMORY.md and daily memory files for persistent knowledge retention.

Memory Architecture

~/.openclaw/workspace/
├── MEMORY.md              # Long-term curated memory (main)
├── memory/                # Daily memory files
│   ├── 2025-01-20.md
│   ├── 2025-01-21.md
│   └── ...
└── .memory-archive/       # Archived memories
    └── 2025-01/
        ├── consolidated.md
        └── raw/

Quick Commands

# Consolidate recent daily memories
python3 {baseDir}/scripts/memory_manager.py --consolidate --days 7

# Archive old memories
python3 {baseDir}/scripts/memory_manager.py --archive --older-than 30

# Extract key facts from MEMORY.md
python3 {baseDir}/scripts/memory_manager.py --extract-facts

# Search memory history
python3 {baseDir}/scripts/memory_manager.py --search "关键词"

# Generate memory summary
python3 {baseDir}/scripts/memory_manager.py --summary --output memory-summary.md

# Health check
python3 {baseDir}/scripts/memory_manager.py --health

MEMORY.md Management

Structure

MEMORY.md should contain distilled, long-term knowledge:

# MEMORY.md - Long-Term Memory

## User Profile
- Name: ...
- Preferences: ...
- Work patterns: ...

## Key Decisions
- [Date] Decision: Reasoning...

## Important Facts
- Account: location...
- Credentials: stored in...
- Recurring tasks: ...

## Lessons Learned
- Pattern: Insight...

## Active Projects
- Project A: Status, next steps...

## Recurring Context
- Weekly meetings: ...
- Regular reports: ...

Consolidation Workflow

  1. Review daily memories (last 7 days)
  2. Extract significant items:
    • User preferences mentioned
    • Important decisions made
    • New facts discovered
    • Lessons learned
    • Active project updates
  3. Update MEMORY.md with distilled content
  4. Archive processed daily files
# Full consolidation workflow
python3 {baseDir}/scripts/memory_manager.py --consolidate --auto-archive

What to Keep in MEMORY.md

Keep Don't Keep
User preferences Temporary states
Key decisions Daily trivia
Important facts Transient data
Lessons learned Detailed logs
Active projects Heartbeat checks
Recurring patterns One-time events
Credentials locations OAuth URLs

Daily Memory Files

Purpose

memory/YYYY-MM-DD.md files capture:

  • What happened today
  • Important conversations
  • Decisions made
  • Tasks completed
  • Context for future reference

Best Practices

DO:

# 2025-01-20

## Key Events
- User asked about X, decided Y
- Set up new integration Z
- Discovered preference for concise responses

## Decisions
- Use tool X instead of Y for Z task (user preference)

## Pending
- Follow up on ...

DON'T:

# 2025-01-20

Got message. Replied HEARTBEAT_OK.
User said hi. Said hi back.
Time is 3pm.

Automatic Extraction

The system can extract valuable content:

# Extract what matters from daily files
python3 {baseDir}/scripts/memory_manager.py --extract --from "2025-01-20.md"

# Output: List of extractable facts

Archival System

Archive Threshold

Default: Archive daily memories older than 30 days

# Archive old memories
python3 {baseDir}/scripts/memory_manager.py --archive --older-than 30

# Archive with consolidation
python3 {baseDir}/scripts/memory_manager.py --archive --older-than 30 --consolidate-first

Archive Structure

.memory-archive/
├── 2025-01/
│   ├── consolidated.md    # Summary of the month
│   └── raw/               # Original daily files
│       ├── 2025-01-01.md
│       └── ...
└── 2025-02/
    └── ...

Retrieval from Archive

# Search archived memories
python3 {baseDir}/scripts/memory_manager.py --search "keyword" --include-archive

# Retrieve specific archived content
python3 {baseDir}/scripts/memory_manager.py --retrieve "2025-01-15"

Memory Compression

What Gets Compressed

Daily memories contain repetition and noise. Compression extracts:

  1. Unique events - Things that happened once
  2. Recurring patterns - Things that repeat
  3. Key decisions - Choices made
  4. Important facts - Persistent information

Compression Rules

# Compress with custom rules
python3 {baseDir}/scripts/memory_manager.py --compress \
  --rules keep-decisions,keep-preferences,keep-facts \
  --remove heartbeets,trivial,transient

Example Compression

Before (daily files, 5000 words):

# 2025-01-20
User asked about API. Looked up docs. Found answer.
User preferred concise response. Noted preference.
...

# 2025-01-21
User asked about API again. Provided concise answer.
User appreciated brevity.
...

After (MEMORY.md, 100 words):

## User Preferences
- Prefers concise responses over detailed explanations

## Knowledge
- API documentation location: ...

## Lessons
- Concise answers are preferred for API questions

Memory Search

Search Commands

# Search all memories
python3 {baseDir}/scripts/memory_manager.py --search "关键词"

# Search specific range
python3 {baseDir}/scripts/memory_manager.py --search "..." --from 2025-01-01 --to 2025-01-31

# Search with context
python3 {baseDir}/scripts/memory_manager.py --search "..." --context 3

# Search archives too
python3 {baseDir}/scripts/memory_manager.py --search "..." --include-archive

Search Output

{
  "query": "关键词",
  "results": [
    {
      "date": "2025-01-20",
      "file": "memory/2025-01-20.md",
      "line": 15,
      "context": "...",
      "relevance": "high"
    }
  ],
  "total": 3
}

Integration with Vector Memory

This skill works alongside vector memory (LanceDB):

System Purpose Retention
MEMORY.md Curated long-term memory Permanent
memory/YYYY-MM-DD.md Daily logs 30 days → archive
Vector memory (LanceDB) Semantic search Variable

Coordination

# Consolidate both systems
python3 {baseDir}/scripts/memory_manager.py --consolidate --sync-vector

# The script will:
# 1. Update MEMORY.md
# 2. Archive old daily files
# 3. Sync key facts to vector memory

Automation

Periodic Consolidation

Add to heartbeat or cron:

# HEARTBEAT.md
- Run memory consolidation weekly
- Archive memories older than 30 days
- Sync to vector memory

Or via cron:

# Weekly consolidation (Sunday 4am)
cron action=add job='{
  "name": "memory-consolidation",
  "schedule": "0 4 * * 0",
  "text": "Consolidate weekly memories: 1) Review memory/ files 2) Update MEMORY.md 3) Archive old files 4) Sync to vector memory"
}'

Automated Extraction

During heartbeats, automatically extract:

python3 {baseDir}/scripts/memory_manager.py --auto-extract --days 1

Memory Health

Health Metrics

Metric Healthy Warning Critical
Daily files count \x3C30 30-60 >60
MEMORY.md size \x3C50KB 50-100KB >100KB
Archive coverage >90% 50-90% \x3C50%
Last consolidation \x3C7 days 7-14 days >14 days

Health Check

python3 {baseDir}/scripts/memory_manager.py --health

# Output
{
  "status": "healthy",
  "metrics": {
    "daily_files": 15,
    "memory_md_size": "12KB",
    "last_consolidation": "2025-01-18",
    "archive_coverage": "95%"
  },
  "recommendations": []
}

Cleanup

# Clean up stale content
python3 {baseDir}/scripts/memory_manager.py --cleanup

# Remove duplicates
python3 {baseDir}/scripts/memory_manager.py --dedupe

# Reorganize structure
python3 {baseDir}/scripts/memory_manager.py --reorganize

Best Practices

Writing to MEMORY.md

  1. Be concise - Distill, don't copy
  2. Use structure - Consistent sections
  3. Date important items - When did this become true?
  4. Review periodically - Remove outdated info
  5. One concept per line - Easy to search

Managing Daily Files

  1. Write daily - Capture what matters
  2. Skip trivial - No heartbeat logs
  3. Link related - Reference other files
  4. Mark important - Use clear headings
  5. Archive promptly - Don't accumulate

Integration with Other Skills

# Use with self-evolution
python3 {baseDir}/scripts/memory_manager.py --consolidate
python3 ../self-evolution/scripts/evolution.py --analyze --with-memory

# Use with self-improvement
# Log a learning, then consolidate
python3 {baseDir}/scripts/memory_manager.py --extract-from .learnings/LEARNINGS.md

Workflow Examples

Weekly Maintenance

# 1. Check health
python3 {baseDir}/scripts/memory_manager.py --health

# 2. Consolidate recent memories
python3 {baseDir}/scripts/memory_manager.py --consolidate --days 7

# 3. Archive old files
python3 {baseDir}/scripts/memory_manager.py --archive --older-than 30

# 4. Sync to vector memory
python3 {baseDir}/scripts/memory_manager.py --sync-vector

# 5. Generate report
python3 {baseDir}/scripts/memory_manager.py --summary

After Important Session

# Extract key facts immediately
python3 {baseDir}/scripts/memory_manager.py --extract --today

# Update MEMORY.md
python3 {baseDir}/scripts/memory_manager.py --update --section "Key Decisions" --add "..."

Research Task

# Search all memories for context
python3 {baseDir}/scripts/memory_manager.py --search "项目名" --include-archive --context 5

# Export relevant memories
python3 {baseDir}/scripts/memory_manager.py --export "项目名" --output project-context.md

Notes

  • MEMORY.md is for main sessions only (not group chats)
  • Daily files should be raw logs, not polished documents
  • Archiving preserves data, just moves it out of active view
  • Consolidation is distillation, not summarization
  • The goal: quick recall of important information
Usage Guidance
This skill appears to do what it says and does not contact external servers or request credentials, but it will aggregate any text in your daily memory files that matches its extraction patterns (including lines mentioning 'account' or 'credential') into a persistent MEMORY.md file. Before installing/running: (1) inspect the script yourself (it's included) and confirm regexes/behavior; (2) avoid putting real secrets in daily memory files or change the script to ignore credential-like lines; (3) run it on a copy/sandbox of your workspace first to observe outputs; (4) tighten filesystem permissions on ~/.openclaw/workspace or enable encryption/backups if MEMORY.md will contain sensitive material; (5) if you want to prevent accidental consolidation of secrets, modify or remove the 'account/credential' extraction rules in extract_facts_from_file.
Capability Analysis
Type: OpenClaw Skill Name: longterm-memory-manager Version: 1.0.0 The skill bundle is a legitimate utility designed to manage an AI agent's long-term memory by consolidating daily logs into a structured MEMORY.md file. The Python script (memory_manager.py) uses standard libraries to perform file operations, regex-based fact extraction, and archival within the local workspace (~/.openclaw/workspace/). While it explicitly organizes sensitive data such as credentials and decisions, it lacks any network capabilities, obfuscation, or unauthorized execution patterns, and its behavior is entirely consistent with its stated purpose.
Capability Assessment
Purpose & Capability
The name/description describe long-term memory consolidation and maintenance. The included script implements consolidation, extraction of facts/preferences/decisions, search, compression, and archiving under ~/.openclaw/workspace. The requested resources (none) and file operations are consistent with the documented purpose.
Instruction Scope
SKILL.md instructs the agent to run the local script with flags that operate only on files under ~/.openclaw/workspace (memory, MEMORY.md, .memory-archive). That scope matches the purpose. Important note: the script's extraction patterns explicitly look for markers like 'account'/'credential' and will add matched content into the Important Facts / MEMORY.md file unencrypted; this can unintentionally consolidate sensitive secrets if they appear in daily memory files.
Install Mechanism
No install spec; the skill is instruction + a local Python script. There are no downloads, package installs, or external binaries referenced. This is low-install risk and easy to audit.
Credentials
The skill requires no environment variables or external credentials (proportional). However, the script will parse and persist any matching text from user memory files (including lines that look like accounts/credentials). That behavior is functionally related to the skill but has privacy/security implications and should be considered by the user.
Persistence & Privilege
always is false and the skill is user-invocable; it does not request elevated platform privileges or modify other skills. It persists data to files inside the user's ~/.openclaw/workspace, which is expected for this functionality.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install longterm-memory-manager
  3. After installation, invoke the skill by name or use /longterm-memory-manager
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
Memory consolidation, archival, and search for maintaining MEMORY.md and daily memory files.
Metadata
Slug longterm-memory-manager
Version 1.0.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is Long-Term Memory Manager?

Long-term memory management system for maintaining MEMORY.md, consolidating daily memories, and extracting key insights. Use when: (1) Consolidating daily me... It is an AI Agent Skill for Claude Code / OpenClaw, with 165 downloads so far.

How do I install Long-Term Memory Manager?

Run "/install longterm-memory-manager" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Long-Term Memory Manager free?

Yes, Long-Term Memory Manager is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Long-Term Memory Manager support?

Long-Term Memory Manager is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Long-Term Memory Manager?

It is built and maintained by shenmeng (@shenmeng); the current version is v1.0.0.

💬 Comments