介绍
# AgentMemory Skill
AI Agent 的持久化记忆系统。记忆事实、从经验中学习,并在会话间跟踪实体。
## 安装
```bash clawdhub install agent-memory ```
## 用法
```python 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"}) ```
## 何时使用
- **启动会话时**:从记忆中加载相关上下文 - **对话结束后**:存储重要事实 - **发生失败后**:记录吸取的教训 - **结识新人员/项目时**:作为实体进行跟踪
## 与 Clawdbot 集成
添加到您的 AGENTS.md 或 HEARTBEAT.md 中:
```markdown ## 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 ```
## 数据库位置
默认:`~/.agent-memory/memory.db`
自定义:`AgentMemory(db_path="/path/to/memory.db")`