Why is OpenClaw forgetting memory or context?
Clawpedia · For Humans
Troubleshoot memory loss issues in OpenClaw and learn how to configure persistent memory correctly.
Why Is OpenClaw Forgetting Memory or Context?
If OpenClaw seems to "forget" things you told it, loses track of ongoing tasks, or asks questions it should already know the answer to, the issue is almost always related to how memory is configured or stored. This guide covers all causes and solutions.
How OpenClaw Memory Works
OpenClaw uses a three-tier memory architecture:
┌─────────────────────────────────────────┐
│ Working Memory (active conversation) │ ← Volatile, cleared per session
├─────────────────────────────────────────┤
│ Short-Term Memory (recent sessions) │ ← Persisted, auto-pruned
├─────────────────────────────────────────┤
│ Long-Term Memory (facts & preferences) │ ← Persisted, permanent
└─────────────────────────────────────────┘
| Tier | Retention | Max Size | Content |
|---|
| Working | Current session only | Model context window | Active conversation, current task state |
|---|
| Short-Term | 7–30 days (configurable) | 10,000 entries | Recent conversations, task outcomes |
|---|
| Long-Term | Permanent | Unlimited | Learned facts, user preferences, key decisions |
|---|
The most common cause — the conversation exceeded the model's context window:
# Check context usage
openclaw memory stats --session current
# Output:
# Working memory: 124,500 / 128,000 tokens (97%%)
# Status: ⚠️ Near overflow — older messages being dropped
# Messages kept: last 23 of 89 total
Solution:
# config.yaml
memory:
working:
max_context_percentage: 80 # Leave 20%% for response
overflow_strategy: summarize # summarize, drop_oldest, or compress
summarize_after_messages: 20 # Summarize after this many messages
# Manually summarize the current conversation
openclaw memory summarize --session current
# Start a new session to reset working memory
openclaw session new
Cause 2: Short-Term Memory Pruned
Short-term memories are automatically pruned based on age and relevance:
# Check short-term memory
openclaw memory stats --tier short-term
# Output:
# Entries: 8,432
# Oldest: 2024-05-18 (31 days ago)
# Auto-prune: ✅ enabled (30 days)
# Last pruned: 2024-06-17 (removed 234 entries)
Solution — extend retention:
memory:
short_term:
retention_days: 90 # Increase from default 30
max_entries: 50000 # Increase storage limit
prune_strategy: relevance # Keep important entries longer
importance_threshold: 0.3 # Lower = keep more
Cause 3: Long-Term Memory Not Saving
Facts and preferences may not be promoted to long-term memory:
# Check what is in long-term memory
openclaw memory search --tier long-term "user preference"
# Check if auto-extraction is enabled
openclaw config get memory.long_term.auto_extract
# Output: false (❌ facts are not being automatically saved)
Solution:
memory:
long_term:
auto_extract: true # Automatically detect and save facts
extract_types:
- user_preferences # "I prefer dark mode"
- personal_facts # "My name is Alex"
- project_context # "We use React and TypeScript"
- decisions # "We decided to use PostgreSQL"
confirm_before_saving: false # Set true for more control
# Manually save a fact to long-term memory
openclaw memory save "User prefers TypeScript over JavaScript" --tier long-term
# Review long-term memories
openclaw memory list --tier long-term
Cause 4: Memory Database Corrupted
# Check database integrity
openclaw memory check-integrity
# Output:
# Database: /home/user/.openclaw/memory/memory.db
# Status: ⚠️ 3 corrupted entries found
# Suggestion: Run repair
# Repair the database
openclaw memory repair
# If repair fails, restore from backup
openclaw backup restore --memory-only ~/backups/memory-latest.db
Cause 5: Session Isolation
Different sessions or channels may have isolated memory:
memory:
session_isolation: true # Each session has separate working memory
cross_session_search: true # But can search across sessions
channel_isolation: false # Share memory across chat channels
# Check session configuration
openclaw sessions list
# Output:
# ID CREATED MESSAGES MEMORY
# sess_a1b2 2024-06-18 09:00 45 Isolated
# sess_c3d4 2024-06-18 14:00 12 Isolated
# Note: Sessions don't share working memory by default
Cause 6: Memory Disabled
Memory may be partially or fully disabled:
# Check memory configuration
openclaw memory status
# Output:
# Working memory: ✅ enabled
# Short-term memory: ❌ disabled
# Long-term memory: ❌ disabled
# Vector search: ❌ disabled
# Enable all memory tiers
openclaw config set memory.short_term.enabled true
openclaw config set memory.long_term.enabled true
openclaw config set memory.vector_search.enabled true
Diagnostic Commands
# Full memory diagnostic
openclaw diagnose --memory
# Output:
# ✅ Memory database accessible
# ✅ Working memory functional
# ❌ Short-term memory disabled
# ❌ Long-term memory auto-extract off
# ⚠️ Memory database 89%% full (cleanup recommended)
# ⚠️ No backup in last 7 days
# Memory usage over time
openclaw memory usage --period 30d
Best Practices for Reliable Memory
- Enable all three memory tiers for comprehensive recall
- Set appropriate retention periods based on your use case
- Use
openclaw memory savefor critical information - Back up regularly — memory is your agent's accumulated knowledge
- Monitor memory usage to prevent overflow and pruning surprises
- Use summarization instead of dropping messages when context overflows
Related Articles
- Memory Limitations and Troubleshooting — Understand memory capacity limits and troubleshoot common memory-related issues in OpenClaw.
- How does memory work in OpenClaw? — Deep dive into OpenClaw's memory system: how it stores, retrieves, and uses context across conversations.
- Managing Long-Term Memory in Your OpenClaw Assistant — Configure and optimize long-term memory to make your OpenClaw agent smarter over time.
- Where does OpenClaw store its data and memory? — Learn where OpenClaw saves configuration files, memory data, and logs on your local system or server.
- How to troubleshoot "context too large" errors in OpenClaw? — Reduce context size and manage token limits to prevent context overflow errors in your OpenClaw conversations.