Files
nexus/wiki/concepts/Agent-Memory.md
2026-04-22 16:03:25 +08:00

50 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "Agent-Memory"
type: concept
tags: [OpenClaw, Agent, Memory, Long-Term]
sources: [万字讲透openclaw-workspace深度解析-2026-03-21]
last_updated: 2026-03-21
---
## Definition
**Agent-Memory** 是 OpenClaw 通过 workspace 文件体系实现的**跨会话长期记忆**机制。核心洞察:对 Agent 来说,真正算数的长期记忆,是 workspace 里那些 Markdown 文件,不是什么看不见摸不着的黑盒数据库。
## 记忆机制
OpenClaw 支持两种记忆方案:
- **builtin**(默认):原始记忆还是 Markdown 文件,系统维护本地索引方便检索
- **qmd**:换了一套更强的检索/索引方式来辅助"想起来"
## 工作流程
```
对话发生
Agent 通过普通文件工具把重要信息写入 `memory/` 或 `MEMORY.md`
下次对话开始
Agent 通过 `memory_search` / `memory_get` 检索相关记忆
相关记忆被注入到当前对话的上下文里
Agent 表现出"我记得你说过……"的能力
```
## 为什么重要
默认情况下LLM 对话是无状态的——每次新开会话,什么都不记得。对持续工作的 Agent 来说很伤:
- 每次都要重新解释项目背景
- Agent 无法在多个会话之间积累对工作的理解
- 花了时间告诉它的偏好和经验,换个会话就白费了
## Related Concepts
- [[MEMORY.md]] — 长期知识总表,与 memory/ 目录共同构成记忆层
- [[Workspace]] — Agent-Memory 的载体
- [[OpenClaw]] — 实现 Agent-Memory 的框架