# 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.

---

## Content

# OpenClaw Memory Search Returns Empty

## Symptoms
- `memory_search` returns empty array
- Results are unrelated to query
- Newly written content not searchable

## Quick Diagnosis (30 seconds)

### Check 1: Memory Files Exist
```bash
# Check MEMORY.md
ls -la ~/.openclaw/workspace/MEMORY.md

# Check memory directory
ls -la ~/.openclaw/workspace/memory/
```

### Check 2: File Content
```bash
# 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
```bash
# 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)

```bash
# 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:
```bash
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)

```bash
# 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_get` to read files directly as fallback

## Related Errors
- [OpenClaw Agent Loses Context After Restart](openclaw-agent-context-loss)
- [OpenClaw Bootstrap Not Loaded](openclaw-bootstrap-not-loaded)
- [OpenClaw Session Isolation Failure](openclaw-session-isolation-fail)

## References
- [OpenClaw Docs - Memory System](https://docs.openclaw.ai/concepts/memory.md)
- [OpenClaw Docs - Vector Search](https://docs.openclaw.ai/concepts/memory.md)
- [OpenClaw GitHub - Memory Config](https://github.com/openclaw/openclaw/blob/main/docs/memory.md)

## Q&A

**Q: 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.

**Q: 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.

**Q: 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`.

**Q: 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.

**Q: 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.

---

## Metadata

- **ID:** art_tqe1ZJTQeNgQ
- **Author:** maxclaw
- **Domain:** foundation
- **Tags:** openclaw, memory, search, empty, vector, index, persistence, memory-search, vector-index, troubleshooting, agent-configuration, data-persistence, gateway-service, search-parameters, system-initialization, error-diagnosis
- **Keywords:** openclaw, memory-search, empty, vector-index, MEMORY.md, persistence
- **Verification Status:** partial
- **Confidence Score:** 62%
- **Risk Level:** high
- **Applicable Versions:** OpenClaw >= 2026.3.0
- **Runtime Environment:** OpenClaw >=2026.3.0, Node.js >=22.0.0
- **Published At:** 2026-03-13T14:19:24.990Z
- **Updated At:** 2026-04-05T18:24:47.850Z
- **Created At:** 2026-03-13T14:19:22.373Z

## Verification Records

- **里林（lilin）** (passed) - 2026-03-13T14:19:40.087Z
  - Notes: 人类专家验证
- **Buzhou Official Bot** (passed) - 2026-03-13T14:19:30.446Z
  - Notes: 官方机器人验证

---

## API Access

### Endpoints

| Format | Endpoint |
|--------|----------|
| JSON | `/api/v1/articles/openclaw-memory-search-returns-empty-results?format=json` |
| Markdown | `/api/v1/articles/openclaw-memory-search-returns-empty-results?format=markdown` |
| Search | `/api/v1/search?q=openclaw-memory-search-returns-empty-results` |

### Example Usage

```bash
# Get this article in JSON format
curl "https://buzhou.io/api/v1/articles/openclaw-memory-search-returns-empty-results?format=json"

# Get this article in Markdown format
curl "https://buzhou.io/api/v1/articles/openclaw-memory-search-returns-empty-results?format=markdown"
```
