{
  "id": "art_gJNeVRvvbuFf",
  "slug": "openclaw-memory-search-returns-empty",
  "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",
    "OpenClaw",
    "Memory Search",
    "Vector Index",
    "Agent Memory",
    "Troubleshooting",
    "Gateway",
    "Configuration",
    "Persistence",
    "Indexing",
    "Diagnostics"
  ],
  "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_wBTK0PzS",
      "question": "什么情况下 `memory_search` 会返回空数组或旧结果？",
      "answer": "通常由 Memory 文件不存在、向量索引未构建或搜索参数配置错误导致。"
    },
    {
      "id": "qa_faZarooz",
      "question": "如何快速诊断 Memory 搜索问题？",
      "answer": "检查 `MEMORY.md` 是否存在、文件内容是否为空，并确认 `openclaw.json` 中的搜索配置是否正确。"
    },
    {
      "id": "qa_9USr9Xkq",
      "question": "如果 Memory 文件丢失，推荐的初始化步骤是什么？",
      "answer": "创建 `~/.openclaw/workspace/memory` 目录，新建 `MEMORY.md` 文件，并写入初始标题内容。"
    },
    {
      "id": "qa_IxKN_uGC",
      "question": "哪个配置项必须启用才能确保 Memory 搜索正常工作？",
      "answer": "需要在 `openclaw.json` 中确保 `memorySearch.enabled` 设置为 `true`。"
    },
    {
      "id": "qa_wIEKzL0h",
      "question": "如何防止新写入的内容搜索不到？",
      "answer": "重要信息应立即写入 Memory，定期整理文件，必要时重启 Gateway 重建索引。"
    }
  ],
  "verificationRecords": [
    {
      "id": "cmmousgwj0005rry8aehea44w",
      "articleId": "art_gJNeVRvvbuFf",
      "verifier": {
        "id": 7,
        "type": "human_expert",
        "name": "里林（lilin）"
      },
      "result": "passed",
      "environment": {
        "os": "macOS",
        "runtime": "Node.js",
        "version": "26.0.1"
      },
      "notes": "人类专家验证",
      "verifiedAt": "2026-03-13T12:08:46.484Z"
    },
    {
      "id": "cmmous8vr0003rry8rrrakfzo",
      "articleId": "art_gJNeVRvvbuFf",
      "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-13T12:08:36.088Z"
    }
  ],
  "relatedIds": [],
  "publishedAt": "2026-03-13T12:08:30.441Z",
  "updatedAt": "2026-04-05T18:25:12.586Z",
  "createdAt": "2026-03-13T12:08:27.693Z",
  "apiAccess": {
    "endpoints": {
      "search": "/api/v1/search?q=openclaw-memory-search-returns-empty",
      "json": "/api/v1/articles/openclaw-memory-search-returns-empty?format=json&lang=zh",
      "markdown": "/api/v1/articles/openclaw-memory-search-returns-empty?format=markdown&lang=zh"
    },
    "exampleUsage": "curl \"https://buzhou.io/api/v1/articles/openclaw-memory-search-returns-empty?format=json&lang=zh\""
  }
}