作者:互联网 时间: 2026-07-30 10:20:01
AgentMemory 是一个强大的框架,旨在解决 AI 智能体工作流中的上下文丢失问题。通过提供持久存储层,该工具使 Openclaw Skills 生态系统内的智能体能够保持跨时间的连续性。它允许存储结构化事实、行为教训和特定实体的元数据,确保每个会话都建立在之前的基础之上,而不是从零开始。
这种能力对于构建需要深入了解历史交互和项目特定细微差别的复杂、长期运行的智能体系统至关重要。使用像 AgentMemory 这样的 Openclaw Skills 工具,可以将无状态智能体转变为一个随着您的开发过程不断进化的知识渊博的助手。
下载入口:https://github.com/openclaw/skills/tree/main/skills/dennis-da-menace/agent-memory
从源直接安装技能的最快方式。
npx clawhub@latest install agent-memory
将技能文件夹复制到以下位置之一
全局模式~/.openclaw/skills/
工作区
<project>/skills/
优先级:工作区 > 本地 > 内置
将此提示词复制到 OpenClaw 即可自动安装。
请帮我使用 Clawhub 安装 agent-memory。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。
要开始使用 Openclaw Skills 库中的此条目,请通过 CLI 安装包:
clawdhub install agent-memory
然后,在您的 Python 脚本中初始化记忆:
from src.memory import AgentMemory
mem = AgentMemory()
默认情况下,数据存储在 ~/.agent-memory/memory.db,但您可以在初始化期间指定自定义路径:AgentMemory(db_path="/path/to/memory.db")。
AgentMemory 在 SQLite 数据库中将信息组织为几个关键部分:
| 组件 | 用途 |
|---|---|
| 事实 (Facts) | 存储通用信息,并附带用于语义检索的关联标签。 |
| 教训 (Lessons) | 跟踪行动、上下文、结果(正面/负面)以及衍生的见解。 |
| 实体 (Entities) | 使用灵活的元数据 JSON 管理特定名称(人员、项目)的配置文件。 |
| 元数据 (Metadata) | 跟踪每个条目的时间戳和源会话标识符。 |
Persistent memory system for AI agents. Remember facts, learn from experience, and track entities across sessions.
clawdhub install agent-memory
from src.memory import AgentMemory
mem = AgentMemory()
# Remember facts
mem.remember("Important information", tags=["category"])
# Learn from experience
mem.learn(
action="What was done",
context="situation",
outcome="positive", # or "negative"
insight="What was learned"
)
# Recall memories
facts = mem.recall("search query")
lessons = mem.get_lessons(context="topic")
# Track entities
mem.track_entity("Name", "person", {"role": "engineer"})
Add to your AGENTS.md or HEARTBEAT.md:
## Memory Protocol
On session start:
1. Load recent lessons: `mem.get_lessons(limit=5)`
2. Check entity context for current task
3. Recall relevant facts
On session end:
1. Extract durable facts from conversation
2. Record any lessons learned
3. Update entity information
Default: ~/.agent-memory/memory.db
Custom: AgentMemory(db_path="/path/to/memory.db")