全部产品
Search
文档中心

表格存储:Agent 生态集成

更新时间:May 21, 2026

通过 OpenClaw 和 Hermes 官方插件接入记忆服务,对话前自动检索相关长期记忆并注入上下文,对话结束后自动写回。

OpenClaw 插件

openclaw-tablestore-memory 是面向 OpenClaw 的记忆插件,基于表格存储 Node.js SDK 调用记忆服务。

安装

openclaw plugins install @tablestore/openclaw-tablestore-memory

配置

最小配置如下:

{
  "plugins": {
    "slots": {
      "memory": "tablestore-mem"
    },
    "entries": {
      "tablestore-mem": {
        "enabled": true,
        "config": {
          "endpoint": "https://<instance>.cn-beijing.ots.aliyuncs.com",
          "otsInstanceName": "<instance-name>",
          "accessKeyId": "<AccessKey ID>",
          "accessKeySecret": "<AccessKey Secret>"
        }
      }
    }
  }
}

可选配置

参数

默认值

说明

appId

openclaw

应用标识。

tenantId

从会话用户信息推导

租户或用户标识。

memoryStoreName

openclaw_mem

记忆库名称。

autoCreateMemoryStore

true

记忆库不存在时自动创建。

writebackEnabled

true

是否在对话结束后写回。

searchTopK

5

检索返回数量。

enableRerank

true

是否启用 Rerank。

Scope 映射

OpenClaw 插件写入时使用当前运行时身份:

{
  "appId": "openclaw",
  "tenantId": "<current-user>",
  "agentId": "<runtime-agent>",
  "runId": "<runtime-session>"
}

检索时使用租户维度的跨 Agent、跨会话范围,agentIdrunId 通配为 *

{
  "appId": "openclaw",
  "tenantId": "<current-user>",
  "agentId": "*",
  "runId": "*"
}

运行行为

  • before_prompt_build 阶段检索相关长期记忆。

  • 将检索到的记忆注入隐藏上下文,不直接写入可见会话记录。

  • agent_end 阶段收集本轮用户和助手消息。

  • 默认以异步方式调用 AddMemories 写回记忆库。

CLI 和 Slash 命令

OpenClaw 插件提供调试命令:

openclaw tablestore-mem add "Alice likes jasmine tea" --uid alice
openclaw tablestore-mem search "what does Alice like" --uid alice

在 OpenClaw 会话内可使用:

/tablestore-mem-add Alice likes jasmine tea
/tablestore-mem-search jasmine tea

Hermes 插件

hermes-tablestore-memory 是面向 Hermes Agent 的外接记忆提供器,基于表格存储 Python SDK 调用记忆服务。

安装

hermes plugins install https://github.com/aliyun/hermes-tablestore-memory
hermes memory setup

hermes memory setup 中选择 tablestore-mem

插件依赖 tablestore>=6.4.5。如果 Hermes 使用的 Python 环境未安装该依赖,需要将 SDK 安装到 Hermes 实际使用的 Python 环境中。

配置密钥

密钥建议写入 ~/.hermes/.env

TABLESTORE_MEMORY_AK=<AccessKey ID>
TABLESTORE_MEMORY_SK=<AccessKey Secret>

配置记忆服务

非敏感配置写入 $HERMES_HOME/tablestore_memory.json

{
  "endpoint": "https://<instance>.cn-beijing.ots.aliyuncs.com",
  "instance_name": "<instance-name>",
  "memory_store_name": "hermes_mem",
  "description": "",
  "app_id": "hermes",
  "tenant_id": "",
  "enable_rerank": true,
  "auto_create_store": true,
  "timeout": 30
}

默认值

参数

默认值

说明

memory_store_name

hermes_mem

记忆库名称。

app_id

hermes

应用标识。

tenant_id

空字符串

为空时从会话上下文或 __default__ 推导。

enable_rerank

true

是否启用 Rerank。

auto_create_store

true

记忆库不存在时自动创建。

timeout

30

请求超时时间,单位为秒。

Scope 映射

Hermes 插件按以下规则填充 Scope 4 段:

字段

来源

appId

tablestore_memory.json 中的 app_id,默认 hermes

tenantId

优先取 Hermes 会话 user_id,其次取配置中的 tenant_id,最后回退到 __default__

agentId

Hermes 会话身份,默认 hermes

runId

优先取 gateway_session_keysession_titlesession_id,最后回退到 __default__

写入时使用当前会话的精确 Scope;检索时使用当前租户下的跨 Agent、跨会话范围,即 agentId=""runId=""

提供的工具

工具

说明

tablestore_profile

查看当前 Scope 下的记忆。

tablestore_search

检索长期记忆。

tablestore_remember

写入一条长期记忆。

tablestore_forget

删除一条长期记忆。

插件还会在每轮对话完成后自动同步用户和助手消息,并在下一轮对话前预取相关记忆。

Hermes CLI 命令

memory.provider 设置为 tablestore-mem 后,可使用:

hermes tablestore-mem add "用户偏好简洁回答"
hermes tablestore-mem add "用户喜欢 Rust" --metadata source=manual --metadata topic=preferences
hermes tablestore-mem add "同步写入这条记忆" --sync
hermes tablestore-mem search "简洁回答"
hermes tablestore-mem search "Rust" --top-k 10

接入建议

  • 应用已使用 OpenClaw 或 Hermes,优先选择对应官方插件接入。

  • 需要自定义记忆写入策略、检索策略或上下文拼接方式时,直接使用 SDK,详见 Python SDK 使用介绍Node.js SDK 使用介绍

  • 插件默认在同一租户下跨 Agent、跨会话检索长期记忆,适合多数个人助理与业务助手场景。

  • 业务需要严格按会话隔离检索时,使用 SDK 自行指定完整 Scope,字段语义参见 API 接口介绍

  • 双侧 Agent 共享记忆时,使用同一 Tablestore 实例,appIdtenantIdmemoryStoreName 在双侧精确一致;agentId 由各 Agent runtime 决定,检索时通配为 *