通过 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>"
}
}
}
}
}可选配置
参数 | 默认值 | 说明 |
|
| 应用标识。 |
| 从会话用户信息推导 | 租户或用户标识。 |
|
| 记忆库名称。 |
|
| 记忆库不存在时自动创建。 |
|
| 是否在对话结束后写回。 |
|
| 检索返回数量。 |
|
| 是否启用 Rerank。 |
Scope 映射
OpenClaw 插件写入时使用当前运行时身份:
{
"appId": "openclaw",
"tenantId": "<current-user>",
"agentId": "<runtime-agent>",
"runId": "<runtime-session>"
}检索时使用租户维度的跨 Agent、跨会话范围,agentId 和 runId 通配为 *:
{
"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 teaHermes 插件
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
}默认值
参数 | 默认值 | 说明 |
|
| 记忆库名称。 |
|
| 应用标识。 |
| 空字符串 | 为空时从会话上下文或 |
|
| 是否启用 Rerank。 |
|
| 记忆库不存在时自动创建。 |
|
| 请求超时时间,单位为秒。 |
Scope 映射
Hermes 插件按以下规则填充 Scope 4 段:
字段 | 来源 |
|
|
| 优先取 Hermes 会话 |
| Hermes 会话身份,默认 |
| 优先取 |
写入时使用当前会话的精确 Scope;检索时使用当前租户下的跨 Agent、跨会话范围,即 agentId=""、runId=""。
提供的工具
工具 | 说明 |
| 查看当前 Scope 下的记忆。 |
| 检索长期记忆。 |
| 写入一条长期记忆。 |
| 删除一条长期记忆。 |
插件还会在每轮对话完成后自动同步用户和助手消息,并在下一轮对话前预取相关记忆。
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 实例,
appId、tenantId和memoryStoreName在双侧精确一致;agentId由各 Agent runtime 决定,检索时通配为*。