AI 编程 Agent 的持久化跨会话记忆引擎,基于 iii-engine,BM25 + Vector + Graph 三路混合检索,95.2% 召回率,92% token 节省。
概述
agentmemory 是 rohitg00 开发的 Agent 记忆系统,扩展了 Karpathy 的 LLM Wiki 模式,增加了置信度评分、生命周期管理、知识图谱和混合搜索。
核心价值:Agent 每次会话都要重新解释架构、重新发现 bug、重新教偏好。agentmemory 静默捕获 Agent 行为,压缩为可搜索的记忆,在下次会话开始时注入正确上下文。
关键指标
| 指标 | 数值 |
|---|---|
| 检索准确率 R@5 | 95.2%(LongMemEval-S,500 题) |
| Token 节省 | 92%(~170K tokens/年 vs 19.5M+) |
| 年成本 | **~0) |
| MCP 工具数 | 53 个 |
| 自动 Hook 数 | 12 个 |
| 外部依赖 | 0(SQLite + iii-engine) |
| 测试数量 | 950+ |
安装与快速开始
npm install -g @agentmemory/agentmemory
agentmemory # 启动记忆服务器(:3111)
agentmemory demo # 种入示例数据并验证召回
agentmemory connect claude-code # 接入 Agent
agentmemory doctor # 交互式诊断Claude Code 接入:
# 1. 启动服务器
npx @agentmemory/agentmemory
# 2. 安装插件(自动注册 12 个 hook + 53 个 MCP 工具)
/plugin marketplace add rohitg00/agentmemory
/plugin install agentmemory实时查看器:http://localhost:3113
支持的 Agent(16+)
原生插件 + Hook:Claude Code(12 hooks)、Codex CLI(6 hooks)、OpenCode(22 hooks)
原生插件 + MCP:OpenClaw、Hermes、pi、OpenHuman
MCP 服务器:Cursor、Gemini CLI、Cline、Goose、Kilo Code、Claude Desktop、Windsurf、Roo Code
REST API:Aider
技术架构
存储:SQLite + iii-engine(无外部数据库依赖)
检索:BM25 + Vector(all-MiniLM-L6-v2,本地免费)+ Knowledge Graph,RRF 融合排序
记忆生命周期:4 层整合(Working → Episodic → Semantic → Archival)+ 衰减 + 自动遗忘
自动捕获:12 个 Hook 覆盖 SessionStart、UserPromptSubmit、PreToolUse、PostToolUse、PreCompact、Stop 等事件
与竞品对比
| agentmemory | mem0 (53K⭐) | Letta/MemGPT | CLAUDE.md | |
|---|---|---|---|---|
| 检索 R@5 | 95.2% | 68.5% | 83.2% | N/A |
| 自动捕获 | 12 hooks | 手动 add() | Agent 自编辑 | 手动编辑 |
| 搜索方式 | BM25+Vector+Graph | Vector+Graph | Vector | 全量加载 |
| 外部依赖 | 无 | Qdrant/pgvector | Postgres+向量DB | 无 |
| Token/年 | ~170K | 不定 | 核心记忆在上下文 | 22K+(240条) |
特色功能
Session Replay:每次会话可回放,支持 play/pause、速度控制(0.5×-4×)、逐步执行
JSONL 导入:可导入已有的 Claude Code 会话记录
npx @agentmemory/agentmemory import-jsonl # 导入 ~/.claude/projects 下所有记录Filesystem Connector:@agentmemory/fs-watcher 监听文件系统变化自动记忆
与 Karpathy LLM Wiki 的关系
设计文档(GitHub Gist,1200 stars / 172 forks)扩展了 Karpathy 的 LLM Wiki 模式:
| Karpathy LLM Wiki | agentmemory 扩展 |
|---|---|
| 手动构建知识库 | 自动捕获 + 压缩 |
| 静态 Markdown | 置信度评分 + 生命周期 |
| 文本检索 | BM25 + Vector + Graph 混合检索 |
| 人工维护 | Agent 自动维护 |
相关链接
- GitHub: https://github.com/rohitg00/agentmemory
- 官网: https://agent-memory.dev
- 本地克隆:
/Users/zhaoweiguo/6ai/opensources/agentmemory
关联页面
- llm-wiki-pattern — agentmemory 扩展了 Karpathy 的 LLM Wiki 模式
- openhuman — OpenHuman 使用 agentmemory 作为 Memory trait 后端
- openclaw-session-reset — OpenClaw 的 Session 记忆机制,与 agentmemory 互补
- agent-continual-learning — Agent 持续学习框架,agentmemory 是实现层
- tokenjuice — 同类 Agent 工作流增强工具(输出压缩)