Managing Long-Term Memory in Your OpenClaw Assistant
Clawpedia · For Humans
Configure and optimize long-term memory to make your OpenClaw agent smarter over time.
Overview
Long-term memory is what makes OpenClaw truly personal. It stores facts about you, your preferences, your contacts, and learned behavior patterns that persist across sessions, restarts, and even platform changes. This guide covers how to manage, curate, and optimize your agent's long-term memory.
What Gets Stored in Long-Term Memory
OpenClaw automatically extracts and stores significant information from your conversations:
| Category | Examples | How Detected |
|---|
| Preferences | "I prefer dark mode", "I like concise answers" | Explicit statements |
|---|
| Facts | "My birthday is March 15", "I work at Acme Corp" | Direct statements |
|---|
| Contacts | "Sarah is my project manager" | Relationship mentions |
|---|
| Locations | "I live in Berlin", "My office is downtown" | Location references |
|---|
| Habits | "I usually check email at 9 AM" | Repeated behavior |
|---|
| Skills | "I know Python and Rust" | Self-descriptions |
|---|
| Corrections | "Actually, it's spelled differently" | Error corrections |
|---|
Sometimes you want to tell the agent something important explicitly:
# Add a fact
openclaw memory add "My daughter's name is Emma, she's 8 years old"
# Add a preference
openclaw memory add --type preference "Always respond in bullet points when listing things"
# Add a contact
openclaw memory add --type contact "Dr. Mueller is my dentist, phone: +49 30 123456"
# Add with metadata
openclaw memory add "Project deadline is February 28" --expires "2024-03-01"
Or through natural conversation:
User: "Remember that I'm allergic to peanuts"
Agent: "Got it — I've noted that you're allergic to peanuts.
I'll keep this in mind when suggesting food or restaurants."
Editing Existing Entries
# Find the entry
openclaw memory search "phone number"
# Output:
# mem_abc123 fact "My phone number is +49 170 1234567"
# Update it
openclaw memory edit mem_abc123 "My phone number is +49 170 9876543"
Removing Entries
# Remove a specific entry
openclaw memory delete --id mem_abc123
# Remove all entries matching a search
openclaw memory delete --search "old project" --confirm
# Remove all entries of a type
openclaw memory delete --category habits --confirm
Memory Quality Management
Confidence Scores
Every memory entry has a confidence score (0.0–1.0) indicating how certain the agent is about the information:
| Score | Meaning | Example |
|---|
| 0.9–1.0 | Very confident | Explicitly stated: "My name is Alice" |
|---|
| 0.7–0.9 | Confident | Inferred from context |
|---|
| 0.5–0.7 | Moderate | Possible interpretation |
|---|
| 0.3–0.5 | Low | Guessed from weak signals |
|---|
| 0.0–0.3 | Very low | Auto-prune candidate |
|---|
Over time, similar memories can accumulate:
# Find and merge duplicates
openclaw memory deduplicate
# Output:
# Found 12 potential duplicates:
# 1. "User lives in Berlin" ≈ "User's city is Berlin" (similarity: 0.94)
# → Merged into: "User lives in Berlin"
# 2. "Prefers Celsius" ≈ "Use Celsius for temperature" (similarity: 0.91)
# → Merged into: "User prefers Celsius for temperature"
# ...
# Merged 12 duplicates into 12 entries. Removed 12 redundant entries.
Relevance Decay
Old memories can become irrelevant. Configure relevance decay:
memory:
long_term:
relevance_decay:
enabled: true
half_life_days: 180 # Relevance halves every 180 days
min_relevance: 0.1 # Remove below this threshold
exempt_types: # These never decay
- preferences
- contacts
Memory Organization
Tags
Organize memories with tags:
# Add a tagged memory
openclaw memory add "Sprint ends Friday" --tags work,project-alpha
# Search by tag
openclaw memory list --tag work
# Remove all entries with a tag
openclaw memory delete --tag old-project --confirm
Collections
Group related memories:
# Create a collection
openclaw memory collection create "work-context"
# Add entries to a collection
openclaw memory collection add work-context mem_abc123 mem_def456
# View collection
openclaw memory collection list work-context
# Clear a collection (entries remain, just unlinked)
openclaw memory collection clear work-context
Memory Import/Export
Export for Backup
# Export everything
openclaw memory export --type long-term --output lt-memory.json
# Export as human-readable
openclaw memory export --type long-term --format readable --output lt-memory.txt
Readable format:
=== Preferences (89 entries) ===
[pref_001] Prefers concise responses (confidence: 0.95)
Source: telegram, 2024-01-15
[pref_002] Likes dark mode interfaces (confidence: 0.88)
Source: discord, 2024-01-12
=== Facts (342 entries) ===
[fact_001] Birthday: March 15 (confidence: 0.99)
Source: telegram, 2024-01-10
...
Import from File
# Import and merge with existing
openclaw memory import lt-memory.json --merge
# Import and replace (clears existing first)
openclaw memory import lt-memory.json --replace --confirm
Transfer Between Instances
# On source machine
openclaw memory export --type long-term --output transfer.json
# Copy to target machine
scp transfer.json user@target:~/
# On target machine
openclaw memory import transfer.json --merge
Storage Optimization
# Check storage usage
openclaw memory stats --storage
# Output:
# Storage Backend: SQLite
# Database Size: 48 MB
# Entries: 1,247
# Embeddings: 1,247 × 384 dimensions
# Index Size: 12 MB
# Optimize storage (reindex, vacuum)
openclaw memory optimize
# Compact (remove deleted entry space)
openclaw memory compact
Best Practices
- Review periodically: Run
openclaw memory list --type long-termmonthly to check for outdated entries. - Prune low confidence: Regularly remove low-confidence entries that may cause confusion.
- Backup before changes: Always export before bulk operations.
- Use tags: Tag work-related and personal memories for easier management.
- Set expiry dates: For time-sensitive facts (deadlines, temporary info).
- Correct errors immediately: If the agent remembers something wrong, correct it right away.
Troubleshooting
Agent Uses Outdated Information
- Search for the outdated entry:
openclaw memory search "old info". - Delete it:
openclaw memory delete --id mem_xxx. - Add the correct information:
openclaw memory add "correct info".
Too Many Low-Quality Memories
Adjust the auto-extraction threshold:
memory:
auto_extract:
min_confidence: 0.7 # Only store high-confidence extractions
Memory Search Returns Nothing
The embedding model may not match your query well. Try:
- Different search terms
- More specific phrases
- Listing by category instead of searching
Next Steps
- Clear memory safely: Clearing or Resetting OpenClaw's Memory.
- Privacy controls: Privacy and Memory: Ensuring Your Data Stays Safe.
- Teach your agent: Teaching OpenClaw New Facts and Preferences.
Related Articles
- Letta (formerly MemGPT): Agents with Persistent Long-Term Memory — How Letta, formerly MemGPT, gives AI agents persistent memory that survives across sessions instead of resetting every time.
- Understanding OpenClaw's Memory System — A deep dive into how OpenClaw stores, retrieves, and manages conversational and long-term memory.
- Managing OpenClaw Logs and Debugging Output — Learn to read, filter, and analyze OpenClaw logs to diagnose issues and optimize agent performance.
- Why is OpenClaw forgetting memory or context? — Troubleshoot memory loss issues in OpenClaw and learn how to configure persistent memory correctly.
- How to view, clear, or manage OpenClaw memory? — Access, review, and manage your OpenClaw agent's stored memories and conversation history.