AI Bot Memory System Guide
Configure memory and context for your AI chatbot. Help your bot remember conversations, preferences, and user details.
Overview
A good AI assistant remembers you. It knows your name, preferences, past conversations, and context. This guide explains how to configure memory for OpenClaw and OpenClaw so your bot becomes truly personal.
How Memory Works
New Message
↓
[Load relevant memories]
↓
[Add to context]
↓
[AI processes with context]
↓
[Save new memories]
↓
Response
Memory Types
1. Conversation Context
Short-term memory of the current conversation:
# Keep last N messages in context
MAX_CONTEXT_MESSAGES=30
# Context timeout (minutes of inactivity)
CONTEXT_TIMEOUT_MINUTES=60
Example:
You: My name is Alex
Bot: Nice to meet you, Alex!
You: What's my name?
Bot: Your name is Alex. ← Uses conversation context
2. User Preferences
Long-term storage of user-specific settings:
# Enable preference storage
USER_PREFERENCES_ENABLED=true
PREFERENCES_FILE=/opt/openclaw/data/preferences.json
Stored preferences:
- Name, timezone, language
- Preferred response style
- Notification settings
- Integration credentials
3. Daily Memory Files
Automatic daily logs of interactions:
# Enable daily memory
DAILY_MEMORY_ENABLED=true
MEMORY_PATH=/opt/openclaw/memory
MEMORY_FORMAT=markdown
Creates files like:
/memory/2026-01-27.md
/memory/2026-01-28.md
4. Semantic Memory
AI-searchable knowledge about the user:
# Enable semantic memory
SEMANTIC_MEMORY_ENABLED=true
EMBEDDING_MODEL=text-embedding-3-small
MEMORY_SEARCH_RESULTS=5
Configuration Guide
Basic Setup
# Memory Settings
MEMORY_ENABLED=true
MEMORY_PATH=/opt/openclaw/memory
# Conversation context
MAX_CONTEXT_MESSAGES=30
CONTEXT_TIMEOUT_MINUTES=60
# Long-term memory
LONG_TERM_MEMORY=true
MEMORY_RETENTION_DAYS=90
Memory File Structure
/opt/openclaw/
├── memory/
│ ├── daily/
│ │ ├── 2026-01-27.md
│ │ └── 2026-01-28.md
│ ├── users/
│ │ └── user_123456.json
│ ├── preferences.json
│ └── facts.json
Daily Memory Format
# Memory - January 27, 2026
## Conversations
### 09:15 - Morning briefing request
User asked for daily briefing. Mentioned having a busy day with 3 meetings.
### 14:30 - Task management
User completed "Send proposal" task. Asked to reschedule "Client call" to tomorrow.
### 18:45 - Evening check-in
User asked about weather for tomorrow (planning outdoor activity).
## Facts Learned
- User has meeting with Sarah on Wednesday
- User prefers morning briefings at 7:30 AM
- User is planning a trip next month
## Preferences Updated
- Changed notification time from 8:00 to 7:30
Making Memory Work
Explicit Memory Commands
You: "Remember that I prefer metric units" Bot: "Noted! I'll use metric units in all my responses."
You: "What do you know about me?" Bot: "Here's what I remember:
- Name: Alex
- Timezone: Europe/London
- Prefers metric units
- Morning briefing at 7:30 AM
- Working on 'Website Redesign' project"
You: "Forget my phone number" Bot: "Done. I've removed your phone number from my memory."
Implicit Memory
The bot learns from conversations:
Conversation 1: You: "I'm vegetarian" Bot: "Good to know!"
Later: You: "Suggest a restaurant for dinner" Bot: "Here are some vegetarian-friendly options near you..." ← Remembered preference
Memory Recall
You: "What did we discuss about the project last week?" Bot: "Last week (Jan 20-24) we discussed:
- Jan 20: Initial project scope
- Jan 22: Budget concerns
- Jan 24: Timeline adjusted to March deadline
Would you like more details on any of these?"
System Prompt for Memory
Add memory context to your system prompt:
SYSTEM_PROMPT="You are a personal AI assistant with memory capabilities.
You remember:
- User's name and preferences
- Past conversations and decisions
- Important dates and commitments
- User's projects and goals
When responding:
- Reference past conversations when relevant
- Use remembered preferences
- Remind about upcoming commitments
- Build on previous discussions
Memory instructions:
- When user shares personal info, store it
- When user makes decisions, remember them
- When user has preferences, apply them consistently
- If unsure about something previously discussed, acknowledge the gap"
Advanced Memory Features
Memory Search
Find relevant past information:
async function searchMemory(query, userId) {
// Get embeddings for query
const queryEmbedding = await getEmbedding(query);
// Search memory vectors
const results = await vectorStore.search({
vector: queryEmbedding,
filter: { userId },
topK: 5
});
return results.map(r => r.content);
}
You: "What did I decide about the logo?" Bot: Searches memory, finds: "On Jan 15, you decided to go with the blue logo variant with the modern font."
Memory Importance Ranking
Not all information is equally important:
async function assessImportance(message) {
const response = await claude.messages.create({
model: 'claude-3-5-sonnet-20241022',
messages: [{
role: 'user',
content: `Rate the importance of remembering this information (1-10):
"${message}"
Consider: Is this a preference? A decision? A fact about the user? Temporary or permanent?
Return JSON: {"importance": N, "category": "preference|fact|decision|temporary", "summary": "brief summary"}`
}]
});
return JSON.parse(response.content[0].text);
}
Memory Consolidation
Periodically summarize and consolidate memories:
// Run weekly
async function consolidateMemory(userId) {
const weekMemories = await getWeekMemories(userId);
const summary = await claude.messages.create({
model: 'claude-3-5-sonnet-20241022',
messages: [{
role: 'user',
content: `Consolidate these memories into key facts and preferences:
${weekMemories.map(m => `- ${m}`).join('\n')}
Return the most important information to remember long-term.`
}]
});
await saveLongTermMemory(userId, summary);
await archiveWeekMemories(userId);
}
Privacy and Security
Data Retention
# Auto-delete old memories
MEMORY_RETENTION_DAYS=90
# Keep important facts longer
FACTS_RETENTION_DAYS=365
# Never store sensitive data
EXCLUDE_FROM_MEMORY=password,credit card,ssn,api key
User Control
Let users manage their memory:
You: "/memory" Bot: "Memory options:
/memory show- View what I remember/memory clear- Clear all memory/memory delete [topic]- Delete specific memory/memory export- Download your data"
Encryption
Encrypt memory at rest:
MEMORY_ENCRYPTION=true
MEMORY_ENCRYPTION_KEY=your-encryption-key
Troubleshooting
Bot doesn't remember
- Check memory is enabled:
MEMORY_ENABLED=true - Verify memory path is writable
- Check context timeout isn't too short
Memory too short
Increase context:
MAX_CONTEXT_MESSAGES=50
CONTEXT_TIMEOUT_MINUTES=120
Irrelevant memories recalled
Improve memory search:
MEMORY_RELEVANCE_THRESHOLD=0.7
MEMORY_SEARCH_RESULTS=3
Memory file growing too large
Enable consolidation:
MEMORY_CONSOLIDATION=weekly
MEMORY_MAX_SIZE_MB=100
Best Practices
Do's
- ✅ Let users see what's remembered
- ✅ Allow memory deletion
- ✅ Consolidate old memories
- ✅ Separate by importance
- ✅ Encrypt sensitive data
Don'ts
- ❌ Store passwords or credentials
- ❌ Keep memories forever without cleanup
- ❌ Make memory impossible to delete
- ❌ Share memory between users
Related Guides
Need Help?
Memory configuration affects the entire bot experience. Our setup service includes memory system configuration tailored to your use case.
Need a VPS for Your Bot?
We recommend Hostinger KVM 2 VPS - reliable, fast, and perfect for AI chatbots. Get started with our recommended setup.
Get Hostinger VPSNeed Help With Setup?
Got your VPS? Let us handle the technical work. Professional setup and maintenance for OpenClaw (formerly Clawd.bot).