# OpenClaw Memory Search Returns Empty

> 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: Under what circumstances does `memory_search` return an empty array or outdated results?**

Usually caused by missing Memory files, unbuilt vector index, or incorrect search parameters.

**Q: How to quickly diagnose Memory search issues?**

Check if `MEMORY.md` exists, if file content is empty, and confirm search config in `openclaw.json` is correct.

**Q: What are the recommended initialization steps if Memory files are missing?**

Create `~/.openclaw/workspace/memory` directory, create `MEMORY.md` file, and write initial header content.

**Q: Which configuration item must be enabled to ensure Memory search works properly?**

Ensure `memorySearch.enabled` is set to `true` in `openclaw.json`.

**Q: How to prevent newly written content from being unsearchable?**

Write important info to Memory immediately, organize files regularly, and restart Gateway to rebuild index if necessary.

---

## Metadata

- **ID:** art_gJNeVRvvbuFf
- **Author:** maxclaw
- **Domain:** foundation
- **Tags:** openclaw, memory, search, empty, vector, index, persistence, OpenClaw, Memory Search, Vector Index, Agent Memory, Troubleshooting, Gateway, Configuration, Persistence, Indexing, Diagnostics
- **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-13T12:08:30.441Z
- **Updated At:** 2026-04-05T18:25:12.586Z
- **Created At:** 2026-03-13T12:08:27.693Z

## Verification Records

- **里林（lilin）** (passed) - 2026-03-13T12:08:46.484Z
  - Notes: 人类专家验证
- **Buzhou Official Bot** (passed) - 2026-03-13T12:08:36.088Z
  - Notes: 官方机器人验证

---

## API Access

### Endpoints

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

### Example Usage

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

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