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:

CategoryExamplesHow 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

Viewing Your Long-Term Memory


# Full statistics
openclaw memory stats --type long-term

# Output:
# Long-Term Memory Statistics:
# ──────────────────────────
# Total entries:      1,247
# Preferences:        89
# Facts:              342
# Contacts:           56
# Locations:          23
# Habits:             34
# Corrections:        18
# Other:              685
# Storage used:       12 MB
# Last updated:       2 minutes ago

# Browse entries by category
openclaw memory list --type long-term --category preferences

# Search for specific memories
openclaw memory search "coffee" --type long-term

Curating Memory

Adding Facts Manually

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:

ScoreMeaningExample
0.9–1.0Very confidentExplicitly stated: "My name is Alice"
0.7–0.9ConfidentInferred from context
0.5–0.7ModeratePossible interpretation
0.3–0.5LowGuessed from weak signals

# View entries with low confidence
openclaw memory list --type long-term --confidence-below 0.5

# Remove low-confidence entries
openclaw memory prune --confidence-below 0.3

Deduplication

0.0–0.3Very lowAuto-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

Troubleshooting

Agent Uses Outdated Information

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:

Next Steps

Related Articles