OpenClaw Memory Search Returns Empty Results
Agent memory_search returns empty array or outdated results, usually caused by missing Memory files, unbuilt vector index, or incorrect search parameters.
OpenClaw Memory Search Returns Empty
Symptoms
memory_searchreturns empty array- Results are unrelated to query
- Newly written content not searchable
Quick Diagnosis (30 seconds)
Check 1: Memory Files Exist
# Check MEMORY.md
ls -la ~/.openclaw/workspace/MEMORY.md
# Check memory directory
ls -la ~/.openclaw/workspace/memory/
Check 2: File Content
# View MEMORY.md content
cat ~/.openclaw/workspace/MEMORY.md | head -20
# View today's log
cat ~/.openclaw/workspace/memory/$(date +%Y-%m-%d).md 2>/dev/null || echo "Today's log not found"
Check 3: Search Configuration
# Check search config
cat ~/.openclaw/openclaw.json | grep -A 5 'memorySearch'
Problem Confirmation
- If MEMORY.md doesn't exist, create it
- If file is empty, content not written
- If config is wrong, fix it
Solutions
Solution 1: Initialize Memory Files (Recommended, 1 minute)
# 1. Create memory directory
mkdir -p ~/.openclaw/workspace/memory
# 2. Create MEMORY.md
touch ~/.openclaw/workspace/MEMORY.md
# 3. Write initial content
echo "# Memory" > ~/.openclaw/workspace/MEMORY.md
Solution 2: Manually Write Memory (2 minutes)
In Agent conversation:
Please write what I just said to MEMORY.md
Or manually edit:
echo "## $(date +%Y-%m-%d)" >> ~/.openclaw/workspace/MEMORY.md
echo "Important info..." >> ~/.openclaw/workspace/MEMORY.md
Solution 3: Restart Gateway to Rebuild Index (3 minutes)
# Restart Gateway to reload Memory
openclaw gateway restart
Prevention
Configuration
- Ensure
memorySearch.enabled: true - Regularly check MEMORY.md file size
- Verify model file exists when using local model
Best Practices
- Write important info to Memory immediately
- Regularly organize MEMORY.md
- Use
memory_getto read files directly as fallback
Related Errors
- OpenClaw Agent Loses Context After Restart
- OpenClaw Bootstrap Not Loaded
- OpenClaw Session Isolation Failure
References
FAQ
What are the common symptoms when OpenClaw Memory search function fails?▼
Common symptoms include `memory_search` returning an empty array, results unrelated to the query, or newly written content not being searchable.
How can I quickly check if Memory files exist and contain content?▼
Use `ls -la ~/.openclaw/workspace/MEMORY.md` to check if the file exists, and use the `cat` command to view if the file content is empty or if today's log exists.
Which option needs to be enabled in the configuration file to use memory search normally?▼
You need to ensure `memorySearch.enabled` is set to `true` in `~/.openclaw/openclaw.json`.
What are the recommended initialization steps if the MEMORY.md file does not exist?▼
It is recommended to create the memory directory, create the MEMORY.md file, and write an initial title (e.g., `# Memory`), which takes about 1 minute.
If files exist but search still returns no results, how do I rebuild the vector index?▼
You can rebuild the index by running the `openclaw gateway restart` command to reload Memory and rebuild the index.
Verification Records
人类专家验证
官方机器人验证