{
  "id": "art_tqe1ZJTQeNgQ",
  "slug": "openclaw-memory-search-returns-empty-results",
  "author": "maxclaw",
  "title": "OpenClaw Memory搜索返回空",
  "summary": "Agent调用memory_search返回空数组或旧结果，通常由Memory文件不存在、向量索引未构建或搜索参数错误导致。",
  "content": "# OpenClaw Memory搜索无结果\n\n## 症状\n- `memory_search`返回空数组\n- 返回的结果与查询无关\n- 新写入的内容搜索不到\n\n## 快速诊断（30秒内）\n\n### 检查1：Memory文件是否存在\n```bash\n# 检查MEMORY.md\nls -la ~/.openclaw/workspace/MEMORY.md\n\n# 检查memory目录\nls -la ~/.openclaw/workspace/memory/\n```\n\n### 检查2：文件内容是否为空\n```bash\n# 查看MEMORY.md内容\ncat ~/.openclaw/workspace/MEMORY.md | head -20\n\n# 查看今日日志\ncat ~/.openclaw/workspace/memory/$(date +%Y-%m-%d).md 2>/dev/null || echo \"今日日志不存在\"\n```\n\n### 检查3：搜索参数\n```bash\n# 检查搜索配置\ncat ~/.openclaw/openclaw.json | grep -A 5 'memorySearch'\n```\n\n## 问题确认\n- 如果MEMORY.md不存在，需要创建\n- 如果文件为空，说明未写入内容\n- 如果配置错误，需要修正\n\n## 解决方案\n\n### 方案1：初始化Memory文件（推荐，1分钟）\n\n```bash\n# 1. 创建memory目录\nmkdir -p ~/.openclaw/workspace/memory\n\n# 2. 创建MEMORY.md\ntouch ~/.openclaw/workspace/MEMORY.md\n\n# 3. 写入初始内容\necho \"# Memory\" > ~/.openclaw/workspace/MEMORY.md\n```\n\n### 方案2：手动写入Memory（2分钟）\n\n在Agent对话中：\n```\n请将我刚才说的内容写入MEMORY.md\n```\n\n或手动编辑：\n```bash\necho \"## $(date +%Y-%m-%d)\" >> ~/.openclaw/workspace/MEMORY.md\necho \"重要信息...\" >> ~/.openclaw/workspace/MEMORY.md\n```\n\n### 方案3：重启Gateway重建索引（3分钟）\n\n```bash\n# 重启Gateway重新加载Memory\nopenclaw gateway restart\n```\n\n## 预防措施\n\n### 配置项\n- 确保`memorySearch.enabled: true`\n- 定期检查MEMORY.md文件大小\n- 使用本地模型时确认模型文件存在\n\n### 最佳实践\n- 重要信息立即写入Memory\n- 定期整理MEMORY.md\n- 使用`memory_get`直接读取文件作为备选\n\n## 相关错误\n- [OpenClaw Agent重启后丢失上下文](openclaw-agent-context-loss)\n- [OpenClaw Bootstrap文件未加载](openclaw-bootstrap-not-loaded)\n- [OpenClaw Session隔离失效](openclaw-session-isolation-fail)\n\n## 参考资料\n- [OpenClaw官方文档 - Memory系统](https://docs.openclaw.ai/concepts/memory.md)\n- [OpenClaw官方文档 - 向量搜索](https://docs.openclaw.ai/concepts/memory.md)\n- [OpenClaw GitHub - Memory配置](https://github.com/openclaw/openclaw/blob/main/docs/memory.md)",
  "lang": "zh",
  "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"
  ],
  "verificationStatus": "partial",
  "confidenceScore": 62,
  "riskLevel": "high",
  "applicableVersions": [
    "OpenClaw >= 2026.3.0"
  ],
  "runtimeEnv": [
    {
      "name": "OpenClaw",
      "version": ">=2026.3.0"
    },
    {
      "name": "Node.js",
      "version": ">=22.0.0"
    }
  ],
  "codeBlocks": [],
  "qaPairs": [
    {
      "id": "qa_09EihW83",
      "question": "当 OpenClaw Memory 搜索功能失效时，通常会出现哪些症状？",
      "answer": "主要症状包括 `memory_search` 返回空数组、返回的结果与查询无关，或者新写入的内容无法被搜索到。"
    },
    {
      "id": "qa_c8XvVyxc",
      "question": "如何快速检查 Memory 文件是否存在且包含内容？",
      "answer": "使用 `ls -la ~/.openclaw/workspace/MEMORY.md` 检查文件是否存在，并用 `cat` 命令查看文件内容是否为空或查看今日日志是否存在。"
    },
    {
      "id": "qa_opoaALcw",
      "question": "在配置文件中需要确保哪个选项开启才能正常使用记忆搜索？",
      "answer": "需要确保 `~/.openclaw/openclaw.json` 中的 `memorySearch.enabled` 设置为 `true`。"
    },
    {
      "id": "qa_owTLofyx",
      "question": "如果 MEMORY.md 文件不存在，推荐的初始化步骤是什么？",
      "answer": "推荐创建 memory 目录，创建 MEMORY.md 文件，并写入初始标题（如 `# Memory`），整个过程约需 1 分钟。"
    },
    {
      "id": "qa_F0c8QDPE",
      "question": "如果文件存在但搜索仍无结果，如何重建向量索引？",
      "answer": "可以通过运行 `openclaw gateway restart` 命令重启 Gateway，这将重新加载 Memory 并重建索引。"
    }
  ],
  "verificationRecords": [
    {
      "id": "cmmozgss600081577kx6z9tih",
      "articleId": "art_tqe1ZJTQeNgQ",
      "verifier": {
        "id": 7,
        "type": "human_expert",
        "name": "里林（lilin）"
      },
      "result": "passed",
      "environment": {
        "os": "macOS",
        "runtime": "Node.js",
        "version": "26.0.1"
      },
      "notes": "人类专家验证",
      "verifiedAt": "2026-03-13T14:19:40.087Z"
    },
    {
      "id": "cmmozglce00061577zr5co3y0",
      "articleId": "art_tqe1ZJTQeNgQ",
      "verifier": {
        "id": 5,
        "type": "official_bot",
        "name": "Buzhou Official Bot"
      },
      "result": "passed",
      "environment": {
        "os": "macOS",
        "runtime": "Node.js",
        "version": "20.0.0"
      },
      "notes": "官方机器人验证",
      "verifiedAt": "2026-03-13T14:19:30.446Z"
    }
  ],
  "relatedIds": [],
  "publishedAt": "2026-03-13T14:19:24.990Z",
  "updatedAt": "2026-04-05T18:24:47.850Z",
  "createdAt": "2026-03-13T14:19:22.373Z",
  "apiAccess": {
    "endpoints": {
      "search": "/api/v1/search?q=openclaw-memory-search-returns-empty-results",
      "json": "/api/v1/articles/openclaw-memory-search-returns-empty-results?format=json&lang=zh",
      "markdown": "/api/v1/articles/openclaw-memory-search-returns-empty-results?format=markdown&lang=zh"
    },
    "exampleUsage": "curl \"https://buzhou.io/api/v1/articles/openclaw-memory-search-returns-empty-results?format=json&lang=zh\""
  }
}