通過記憶儲存服務,配合OpenClaw與Hermes Agent各自的官方外掛程式,將兩側記憶統一寫入同一個Tablestore執行個體。同一租戶下,任意Agent寫入的記憶均可被其他Agent檢索召回,跨Agent切換無需重複自我介紹。
工作原理
OpenClaw與Hermes Agent各自維護獨立的本地記憶體系,在兩類情境下會帶來困擾:從一個Agent切換到另一個Agent時,過往沉澱的偏好、技術棧、專案背景等記憶無法繼承;同時使用多個Agent協作時,需要反覆向每個Agent重複同樣的自我介紹。
記憶儲存服務為AI Agent提供雲端持久化的語義記憶能力,並為兩側分別提供官方外掛程式(OpenClaw側的@tablestore/openclaw-tablestore-memory與Hermes Agent側的hermes-tablestore-memory),讓兩側將記憶統一寫入同一個Tablestore執行個體。兩側採用同一套Scope模型組織記憶,通過寫入時精確歸屬、檢索時通配展開的機制實現互連。
Scope欄位 | 寫入行為 | 檢索行為 |
| 精確(雙側必須一致) | 精確(決定共用範圍) |
| 精確(由各Agent的runtime決定,區分記憶來源) | 通配 |
| 精確(由當前會話決定) | 通配 |
只要雙側使用同一個Tablestore執行個體,且app_id、tenant_id、memory_store_name三項配置嚴格一致,即可在同一租戶下實現記憶互連。agentId由各自Agent的runtime決定,無需手動設定,自然區分記憶來源。
Hermes Agent外掛程式還提供兩項透明的自動化能力:每輪對話結束後自動將對話要點同步到記憶儲存,下一輪對話前自動檢索相關記憶並注入上下文。整個過程對使用者透明,Agent的回複會自然引用跨Agent沉澱的記憶。
前提條件
已開通Table StoreTablestore服務並建立執行個體,擷取執行個體的Endpoint、執行個體名稱與AccessKey。
說明當前僅支援華北2(北京)地區。
已安裝並完成基礎配置OpenClaw與Hermes Agent。安裝步驟詳見OpenClaw官方安裝文檔與Hermes Agent官方文檔。
配置共用記憶庫
實現跨Agent互連的核心是雙側配置嚴格對齊。兩側必須指向同一Tablestore執行個體,並使用相同的app_id、tenant_id與memory_store_name。
檢查關鍵配置一致性
配置項 | OpenClaw欄位 | Hermes Agent欄位 | 一致性要求 |
Tablestore Endpoint |
|
| 必須一致 |
Tablestore執行個體名 |
|
| 必須一致 |
AccessKey |
|
| 必須一致 |
應用標識 |
|
| 必須一致 |
租戶標識 |
|
| 必須一致 |
記憶庫名稱 |
|
| 必須一致 |
Agent標識 |
|
| 各自獨立,區分來源 |
OpenClaw側配置
執行以下命令安裝@tablestore/openclaw-tablestore-memory外掛程式,詳細說明詳見Tablestore記憶儲存在OpenClaw中的實現。
openclaw plugins install @tablestore/openclaw-tablestore-memory編輯~/.openclaw/openclaw.json,在plugins.entries中加入tablestore-mem配置塊,並將plugins.slots.memory指向tablestore-mem。
{
"plugins": {
"slots": {
"memory": "tablestore-mem"
},
"entries": {
"tablestore-mem": {
"enabled": true,
"config": {
"endpoint": "https://<your-instance>.cn-beijing.ots.aliyuncs.com",
"otsInstanceName": "<your-instance>",
"accessKeyId": "<your-access-key-id>",
"accessKeySecret": "<your-access-key-secret>",
"appId": "shared-agents",
"tenantId": "default-tenant",
"memoryStoreName": "shared_memory",
"autoCreateMemoryStore": true,
"minQueryLength": 0
},
"hooks": {
"allowConversationAccess": true
}
}
}
}
}重啟OpenClaw網關使配置生效,並執行診斷命令驗證串連。
openclaw gateway restart
openclaw tablestore-mem doctor輸出中ok欄位為true、memoryStore.ok為true,即表示OpenClaw側已正確接入Tablestore。
Hermes Agent側配置
執行以下命令安裝hermes-tablestore-memory外掛程式,詳細說明(含SDK依賴安裝與國內網路下的鏡像配置)詳見Tablestore記憶儲存在hermes-agent中的實現。
hermes plugins install --enable https://github.com/aliyun/hermes-tablestore-memory將AccessKey寫入~/.hermes/.env。
echo 'TABLESTORE_MEMORY_AK=<your-access-key-id>' >> ~/.hermes/.env
echo 'TABLESTORE_MEMORY_SK=<your-access-key-secret>' >> ~/.hermes/.env將外掛程式參數寫入~/.hermes/tablestore_memory.json,確保app_id、tenant_id、memory_store_name與OpenClaw側完全一致。
{
"endpoint": "https://<your-instance>.cn-beijing.ots.aliyuncs.com",
"instance_name": "<your-instance>",
"memory_store_name": "shared_memory",
"app_id": "shared-agents",
"tenant_id": "default-tenant",
"enable_rerank": true,
"auto_create_store": true,
"timeout": 30.0
}啟用tablestore-mem為記憶Provider,並執行診斷命令驗證串連。
hermes config set memory.provider tablestore-mem
hermes tablestore-mem doctor輸出中ok欄位為true、checks.initialize.ok、checks.describe_memory_store.ok、checks.list_memories.ok均為true,即表示Hermes Agent側已正確接入Tablestore。
跨Agent記憶互連驗證
通過雙向寫入與召回驗證兩側確實共用同一份記憶。
tablestore-mem add預設非同步寫入,向量化與索引建立通常需要數十秒。驗證寫入效果時建議使用--sync參數(Hermes Agent側)等待索引完成;若剛寫入立即檢索為空白,請稍等30秒後再試。
情境1:OpenClaw寫入,Hermes Agent召回
在OpenClaw中寫入專案偏好類記憶。
openclaw tablestore-mem add "我負責訂單服務模組的開發,使用Java、Spring Boot與MySQL技術棧"切換到Hermes Agent發起新會話,提問與該記憶語義強相關的問題。Hermes Agent會在queue_prefetch()階段自動召回跨Agent的記憶並注入上下文。
hermes -z "我負責什麼模組?技術棧是什嗎?"預期回複中包含"訂單服務模組"與"Java/Spring Boot/MySQL"等事實,證明Hermes Agent成功召回了OpenClaw寫入的記憶。
情境2:Hermes Agent寫入,OpenClaw召回
在Hermes Agent中寫入團隊事實類記憶。
hermes tablestore-mem add --sync "我們團隊的發布視窗是每周二下午14:00"切換到OpenClaw發起新會話,提問與該事實相關的問題,OpenClaw會自動召回跨Agent的記憶。
openclaw agent --agent main --message "我們的發布視窗是什麼時候?"預期回複中包含“每周二”與“14:00”等事實,證明OpenClaw成功召回了Hermes Agent寫入的記憶。
情境3:CLI命令交叉檢索
使用任意一側的CLI命令均可檢索兩側寫入的全部記憶。
openclaw tablestore-mem search "發布視窗"
hermes tablestore-mem search "訂單服務"返回結果中scope.agentId欄位會顯示原始寫入方(如openclaw、hermes、main等),便於追溯記憶來源。
常見問題
雙側的app_id、tenant_id或memory_store_name不一致還能互連嗎?
不能。共用檢索基於Scope匹配(app_id + tenant_id + memory_store_name),三項任一不一致即視為不同的記憶範圍,不會被對方召回。
從OpenClaw遷移到Hermes Agent後,OpenClaw還能繼續使用嗎?
可以。hermes claw migrate是複製操作而非剪下,OpenClaw原有的配置與本機資料不受影響,可雙側同時運行。完整遷移流程詳見Hermes Agent官方遷移指南。
安裝Hermes Agent或下載依賴時網路失敗怎麼辦?
國內網路環境下從GitHub或PyPI直連可能不穩定。建議配置阿里雲PyPI鏡像加速依賴下載,詳見Tablestore記憶儲存在hermes-agent中的實現中的“安裝時git clone失敗或PyPI下載緩慢”小節。