能力标签
AI编码助手持久化记忆系统
🛠
AI工具

AI编码助手持久化记忆系统

基于 TypeScript · 开源 AI 工具,GitHub 社区精选
英文名:agentmemory
⭐ 13.6k Stars 🍴 1.1k Forks 💻 TypeScript 📄 Apache-2.0 🏷 AI 8.2分
8.2AI 综合评分
智能体记忆AI工作流编码助手Claude持久化存储
✦ AI Skill Hub 推荐

AI Skill Hub 强烈推荐:AI编码助手持久化记忆系统 是一款优质的AI工具。在 GitHub 上收获超过 13.6k 颗 Star,AI 综合评分 8.2 分,在同类工具中表现稳健。如果你正在寻找可靠的AI工具解决方案,这是一个值得深入了解的选择。

📚 深度解析
AI编码助手持久化记忆系统 是一款基于 TypeScript 的开源工具,在 GitHub 上收获 14k+ Star,是智能体记忆、AI工作流、编码助手、Claude领域中的优质开源项目。开源工具的最大优势在于代码完全透明,你可以审计每一行代码的安全性,也可以根据自身需求进行二次开发和定制。

**为什么要使用开源工具而非商业 SaaS?**
对于个人开发者和有隐私需求的用户,本地部署的开源工具意味着数据不离本机,不受第三方服务商的数据政策约束。同时,开源工具通常没有使用次数限制和月度费用,一次安装即可长期使用,对于高频使用场景的总拥有成本(TCO)远低于订阅制商业工具。

**安装与环境准备**
AI编码助手持久化记忆系统 依赖 TypeScript 运行环境。建议通过 pyenv(Python)或 nvm(Node.js)管理 TypeScript 版本,避免全局环境污染。对于新手用户,推荐先创建虚拟环境(python -m venv venv && source venv/bin/activate),再安装依赖,这样即使出现问题也可以随时删除虚拟环境重新开始,不影响系统稳定性。

**社区与维护**
GitHub Issue 和 Discussion 是获取帮助的最快渠道。在提问前建议先检查 Closed Issues(已关闭的问题),大多数常见问题都已有解答。遇到 Bug 时,提供 pip list 的输出、完整错误堆栈和最小可复现示例,能显著提高开发者响应速度。AI Skill Hub 将持续追踪 AI编码助手持久化记忆系统 的版本更新,及时通知重要功能变化。
📋 工具概览

为AI编码智能体提供持久化内存解决方案,基于真实世界基准测试优化。支持Claude等大模型,帮助开发者构建具有记忆能力的自动化工作流,提升复杂编码任务的完成度和一致性。

AI编码助手持久化记忆系统 是一款基于 TypeScript 开发的开源工具,专注于 智能体记忆、AI工作流、编码助手 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。

GitHub Stars
⭐ 13.6k
开发语言
TypeScript
支持平台
Windows / macOS / Linux
维护状态
活跃维护,更新频繁
开源协议
Apache-2.0
AI 综合评分
8.2 分
工具类型
AI工具
Forks
1.1k
📖 中文文档
以下内容由 AI Skill Hub 根据项目信息自动整理,如需查看完整原始文档请访问底部「原始来源」。

为AI编码智能体提供持久化内存解决方案,基于真实世界基准测试优化。支持Claude等大模型,帮助开发者构建具有记忆能力的自动化工作流,提升复杂编码任务的完成度和一致性。

AI编码助手持久化记忆系统 是一款基于 TypeScript 开发的开源工具,专注于 智能体记忆、AI工作流、编码助手 等核心功能。作为 GitHub 开源项目,它拥有活跃的社区支持和持续的版本迭代,代码完全透明可审计,支持本地部署以保护数据隐私。无论是个人使用还是集成到企业工作流,都能提供稳定可靠的解决方案。

📌 核心特色
  • 开源免费,支持本地部署,数据完全自主可控
  • 活跃的 GitHub 开源社区,持续迭代更新
  • 提供详细文档和使用示例,新手友好
  • 支持自定义配置,灵活适配不同使用环境
  • 可作为基础组件集成进现有技术栈或进行二次开发
🎯 主要使用场景
  • 本地部署运行,保护数据隐私,满足合规要求
  • 自定义集成到现有系统,扩展技术栈能力
  • 作为开源基础组件进行商业化二次开发
以下安装命令基于项目开发语言和类型自动生成,实际以官方 README 为准。
安装命令
# 方式一:npm 全局安装
npm install -g agentmemory

# 方式二:npx 直接运行(无需安装)
npx agentmemory --help

# 方式三:项目依赖安装
npm install agentmemory

# 方式四:从源码运行
git clone https://github.com/rohitg00/agentmemory
cd agentmemory
npm install
npm start
📋 安装步骤说明
  1. 访问 GitHub 仓库页面
  2. 按照 README 文档完成依赖安装
  3. 根据系统环境完成初始化配置
  4. 参考官方示例或文档开始使用
  5. 遇到问题可在 GitHub Issues 中查找解答
以下用法示例由 AI Skill Hub 整理,涵盖最常见的使用场景。
常用命令 / 代码示例
# 命令行使用
agentmemory --help

# 基本用法
agentmemory [options] <input>

# Node.js 代码中使用
const agentmemory = require('agentmemory');

const result = await agentmemory.run(options);
console.log(result);
以下配置示例基于典型使用场景生成,具体参数请参照官方文档调整。
配置示例
# agentmemory 配置说明
# 查看配置选项
agentmemory --config-example > config.yml

# 常见配置项
# output_dir: ./output
# log_level: info
# workers: 4

# 环境变量(覆盖配置文件)
export AGENTMEMORY_CONFIG="/path/to/config.yml"
📑 README 深度解析 真实文档 完整度 80/100 查看 GitHub 原文 →
以下内容由系统直接从 GitHub README 解析整理,保留代码块、表格与列表结构。

简介

<p align="center"> <img src="assets/banner.png" alt="agentmemory — Persistent memory for AI coding agents" width="720" /> </p>

<p align="center"> <strong> Your coding agent remembers everything. No more re-explaining. Built on <a href="https://github.com/iii-hq/iii">iii engine</a> </strong><br/> Persistent memory for Claude Code, Cursor, Gemini CLI, Codex CLI, Hermes, OpenClaw, pi, OpenCode, and any MCP client. </p>

<p align="center"> <a href="https://trendshift.io/repositories/25123" target="_blank"><img src="https://trendshift.io/api/badge/repositories/25123" alt="rohitg00/agentmemory | Trendshift" width="250" height="55"/></a> </p>

<p align="center"> <a href="https://www.star-history.com/?repos=rohitg00%2Fagentmemory&type=date&legend=top-left"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&theme=dark&legend=top-left" /> <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" /> <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=rohitg00/agentmemory&type=date&legend=top-left" /> </picture> </a> </p>

<p align="center"> <a href="https://gist.github.com/rohitg00/2067ab416f7bbe447c1977edaaa681e2"><img src="https://img.shields.io/badge/Viral%20GitHub%20Gist-1200%20stars%20%2F%20172%20forks-FF6B35?style=for-the-badge&logo=github&logoColor=white&labelColor=1a1a1a" alt="Design doc: 1200 stars / 172 forks on the gist" /></a> </p>

<p align="center"> <em>The gist extends Karpathy's LLM Wiki pattern with confidence scoring, lifecycle, knowledge graphs, and hybrid search: agentmemory is the implementation.</em> </p>

<p align="center"> <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/v/@agentmemory/agentmemory?color=CB3837&label=npm&style=for-the-badge&logo=npm" alt="npm version" /></a> <a href="https://www.npmjs.com/package/@agentmemory/agentmemory"><img src="https://img.shields.io/npm/dm/@agentmemory/agentmemory?color=CB3837&label=downloads&style=for-the-badge&logo=npm" alt="npm downloads" /></a> <a href="https://github.com/rohitg00/agentmemory/actions"><img src="https://img.shields.io/github/actions/workflow/status/rohitg00/agentmemory/ci.yml?label=tests&style=for-the-badge&logo=github" alt="CI" /></a> <a href="https://github.com/rohitg00/agentmemory/blob/main/LICENSE"><img src="https://img.shields.io/github/license/rohitg00/agentmemory?color=blue&style=for-the-badge" alt="License" /></a> <a href="https://github.com/rohitg00/agentmemory/stargazers"><img src="https://img.shields.io/github/stars/rohitg00/agentmemory?style=for-the-badge&color=yellow&logo=github" alt="Stars" /></a> </p>

<p align="center"> <picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/stat-recall.svg"><img src="assets/tags/stat-recall.svg" alt="95.2% retrieval R@5" height="38" /></picture> <picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/stat-tokens.svg"><img src="assets/tags/stat-tokens.svg" alt="92% fewer tokens" height="38" /></picture> <picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/stat-tools.svg"><img src="assets/tags/stat-tools.svg" alt="53 MCP tools" height="38" /></picture> <picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/stat-hooks.svg"><img src="assets/tags/stat-hooks.svg" alt="12 auto hooks" height="38" /></picture> <picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/stat-deps.svg"><img src="assets/tags/stat-deps.svg" alt="0 external DBs" height="38" /></picture> <picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/stat-tests.svg"><img src="assets/tags/stat-tests.svg" alt="950+ tests passing" height="38" /></picture> </p>

<p align="center"> <img src="assets/demo.gif" alt="agentmemory demo" width="720" /> </p>

<p align="center"> <a href="#install">Install</a> &bull; <a href="#quick-start">Quick Start</a> &bull; <a href="#benchmarks">Benchmarks</a> &bull; <a href="#vs-competitors">vs Competitors</a> &bull; <a href="#works-with-every-agent">Agents</a> &bull; <a href="#how-it-works">How It Works</a> &bull; <a href="#mcp-server">MCP</a> &bull; <a href="#real-time-viewer">Viewer</a> &bull; <a href="#iii-console">iii Console</a> &bull; <a href="#powered-by-iii">Powered by iii</a> &bull; <a href="#configuration">Config</a> &bull; <a href="#api">API</a> </p>

---

Key Capabilities

CapabilityDescription
**Automatic capture**Every tool use recorded via hooks — zero manual effort
**Semantic search**BM25 + vector + knowledge graph with RRF fusion
**Memory evolution**Versioning, supersession, relationship graphs
**Auto-forgetting**TTL expiry, contradiction detection, importance eviction
**Privacy first**API keys, secrets, <private> tags stripped before storage
**Self-healing**Circuit breaker, provider fallback chain, health monitoring
**Claude bridge**Bi-directional sync with MEMORY.md
**Knowledge graph**Entity extraction + BFS traversal
**Team memory**Namespaced shared + private across team members
**Citation provenance**Trace any memory back to source observations
**Git snapshots**Version, rollback, and diff memory state

---

Triple-stream retrieval combining three signals:

StreamWhat it doesWhen
**BM25**Stemmed keyword matching with synonym expansionAlways on
**Vector**Cosine similarity over dense embeddingsEmbedding provider configured
**Graph**Knowledge graph traversal via entity matchingEntities detected in query

Fused with Reciprocal Rank Fusion (RRF, k=60) and session-diversified (max 3 results per session).

BM25 tokenizes Greek, Cyrillic, Hebrew, Arabic, and accented Latin out of the box. For Chinese / Japanese / Korean memories, install the optional segmenters (npm install @node-rs/jieba tiny-segmenter) to split CJK runs into word-level tokens; without them, agentmemory soft-falls to whole-run tokenization and prints a one-time hint on stderr.

OPENAI_EMBEDDING_DIMENSIONS=1536 # Required when the model is not in the known-models table

Install

```bash npm install -g @agentmemory/agentmemory # once — bare agentmemory on PATH

If you hit EACCES on macOS/Linux system Node installs, retry with:

sudo npm install -g @agentmemory/agentmemory

agentmemory # start the memory server on :3111 agentmemory demo # seed sample sessions + prove recall agentmemory connect claude-code # wire your agent (also: codex, cursor, gemini-cli, ...)


Or via `npx` (no install):
bash npx @agentmemory/agentmemory

Heads-up — npx caches per version. If a bare `npx @agentmemory/agentmemory` serves an older release, force the latest with `npx -y @agentmemory/agentmemory@latest`, or clear the cache once with `rm -rf ~/.npm/_npx` (macOS/Linux; on Windows delete `%LOCALAPPDATA%\npm-cache\_npx`). The first npx run from v0.9.16+ prompts to install globally inline so the bare `agentmemory` command works everywhere afterwards.

Full options at [Quick Start](#quick-start) below. Agent-specific wiring at [Works with every agent](#works-with-every-agent).

---

<h2 id="works-with-every-agent"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-agents.svg"><img src="assets/tags/section-agents.svg" alt="Works with every agent" height="32" /></picture></h2>

agentmemory works with any agent that supports hooks, MCP, or REST API. All agents share the same memory server.

<table>
<tr>
<td align="center" width="12.5%">
<a href="https://claude.com/product/claude-code"><img src="https://matthiasroder.com/content/images/2026/01/Claude.png?size=120" alt="Claude Code" width="48" height="48" /></a><br/>
<strong>Claude Code</strong><br/>
<sub>native plugin + 12 hooks + MCP</sub>
</td>
<td align="center" width="12.5%">
<a href="https://github.com/openai/codex"><img src="https://github.com/openai.png?size=120" alt="Codex CLI" width="48" height="48" /></a><br/>
<strong>Codex CLI</strong><br/>
<sub>native plugin + 6 hooks + MCP</sub>
</td>
<td align="center" width="12.5%">
<a href="integrations/openclaw/"><img src="https://github.com/openclaw.png?size=120" alt="OpenClaw" width="48" height="48" /></a><br/>
<strong>OpenClaw</strong><br/>
<sub>native plugin + MCP</sub>
</td>
<td align="center" width="12.5%">
<a href="integrations/hermes/"><img src="https://github.com/NousResearch.png?size=120" alt="Hermes" width="48" height="48" /></a><br/>
<strong>Hermes</strong><br/>
<sub>native plugin + MCP</sub>
</td>
<td align="center" width="12.5%">
<a href="integrations/pi/"><img src="assets/agents/pi.svg" alt="pi" width="48" height="48" /></a><br/>
<strong>pi</strong><br/>
<sub>native plugin + MCP</sub>
</td>
<td align="center" width="12.5%">
<a href="https://github.com/tinyhumansai/openhuman"><img src="https://raw.githubusercontent.com/tinyhumansai/openhuman/main/app/src-tauri/icons/128x128.png" alt="OpenHuman" width="48" height="48" /></a><br/>
<strong>OpenHuman</strong><br/>
<sub>native Memory trait backend</sub>
</td>
<td align="center" width="12.5%">
<a href="https://cursor.com"><img src="https://www.freelogovectors.net/wp-content/uploads/2025/06/cursor-logo-freelogovectors.net_.png" alt="Cursor" width="48" height="48" /></a><br/>
<strong>Cursor</strong><br/>
<sub>MCP server</sub>
</td>
<td align="center" width="12.5%">
<a href="https://github.com/google-gemini/gemini-cli"><img src="https://github.com/google-gemini.png?size=120" alt="Gemini CLI" width="48" height="48" /></a><br/>
<strong>Gemini CLI</strong><br/>
<sub>MCP server</sub>
</td>
</tr>
<tr>
<td align="center" width="12.5%">
<a href="https://github.com/opencode-ai/opencode"><img src="https://github.com/opencode-ai.png?size=120" alt="OpenCode" width="48" height="48" /></a><br/>
<strong>OpenCode</strong><br/>
<sub>22 hooks + MCP + plugin</sub>
</td>
<td align="center" width="12.5%">
<a href="https://github.com/cline/cline"><img src="https://github.com/cline.png?size=120" alt="Cline" width="48" height="48" /></a><br/>
<strong>Cline</strong><br/>
<sub>MCP server</sub>
</td>
<td align="center" width="12.5%">
<a href="https://github.com/block/goose"><img src="https://github.com/block.png?size=120" alt="Goose" width="48" height="48" /></a><br/>
<strong>Goose</strong><br/>
<sub>MCP server</sub>
</td>
<td align="center" width="12.5%">
<a href="https://github.com/Kilo-Org/kilocode"><img src="https://github.com/Kilo-Org.png?size=120" alt="Kilo Code" width="48" height="48" /></a><br/>
<strong>Kilo Code</strong><br/>
<sub>MCP server</sub>
</td>
<td align="center" width="12.5%">
<a href="https://github.com/Aider-AI/aider"><img src="https://github.com/Aider-AI.png?size=120" alt="Aider" width="48" height="48" /></a><br/>
<strong>Aider</strong><br/>
<sub>REST API</sub>
</td>
<td align="center" width="12.5%">
<a href="https://claude.ai/download"><img src="https://github.com/anthropics.png?size=120" alt="Claude Desktop" width="48" height="48" /></a><br/>
<strong>Claude Desktop</strong><br/>
<sub>MCP server</sub>
</td>
<td align="center" width="12.5%">
<a href="https://windsurf.com"><img src="https://exafunction.github.io/public/brand/windsurf-black-symbol.svg?size=120" alt="Windsurf" width="48" height="48" /></a><br/>
<strong>Windsurf</strong><br/>
<sub>MCP server</sub>
</td>
<td align="center" width="12.5%">
<a href="https://github.com/RooCodeInc/Roo-Code"><img src="https://github.com/RooCodeInc.png?size=120" alt="Roo Code" width="48" height="48" /></a><br/>
<strong>Roo Code</strong><br/>
<sub>MCP server</sub>
</td>
</tr>
</table>

<p align="center">
  <sub>Works with <strong>any</strong> agent that speaks MCP or HTTP. One server, memories shared across all of them.</sub>
</p>

---

You explain the same architecture every session. You re-discover the same bugs. You re-teach the same preferences. Built-in memory (CLAUDE.md, .cursorrules) caps out at 200 lines and goes stale. agentmemory fixes this. It silently captures what your agent does, compresses it into searchable memory, and injects the right context when the next session starts. One command. Works across agents.

**What changes:** Session 1 you set up JWT auth. Session 2 you ask for rate limiting. The agent already knows your auth uses jose middleware in `src/middleware/auth.ts`, your tests cover token validation, and you chose jose over jsonwebtoken for Edge compatibility. No re-explaining. No copy-pasting. The agent just *knows*.
bash npx @agentmemory/agentmemory ```

New in v0.9.0 — Landing site at agent-memory.dev, filesystem connector (@agentmemory/fs-watcher), standalone MCP now proxies to the running server so hooks and the viewer agree, audit policy codified across every delete path, health stops flagging memory_critical on tiny Node processes. Full notes in CHANGELOG.md.

---

Benchmarks

If you hit EACCES on macOS/Linux system Node installs, retry with:

sudo npm install -g @agentmemory/agentmemory

agentmemory # start the server (same as the npx form) agentmemory stop # tear it down agentmemory remove # uninstall everything we created agentmemory connect claude-code # wire one agent agentmemory doctor # interactive diagnostics + fix prompts


From v0.9.16 onward, the first npx run prompts you to install globally inline — answer `Y` once and you're set. If you skip, fall back to either of these for a fresh fetch:
bash npx -y @agentmemory/agentmemory@latest # forces latest from npm (cross-platform) rm -rf ~/.npm/_npx && npx @agentmemory/agentmemory # macOS/Linux only (POSIX shell) ```

On Windows / PowerShell, the equivalent cache clear is Remove-Item -Recurse -Force "$env:LOCALAPPDATA\npm-cache\_npx" — the npx -y ...@latest form above is the cross-platform option.

2. register the agentmemory marketplace and install the plugin

codex plugin marketplace add rohitg00/agentmemory codex plugin install agentmemory


The Codex plugin ships from the same `plugin/` directory as the Claude Code plugin. It registers:

- `@agentmemory/mcp` as an MCP server (proxies all 51 tools when `AGENTMEMORY_URL` points at a running agentmemory server; falls back to 7 tools locally when no server is reachable)
- 6 lifecycle hooks: `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `PreCompact`, `Stop`
- 4 skills: `/recall`, `/remember`, `/session-history`, `/forget`

Codex's hook engine injects `CLAUDE_PLUGIN_ROOT` into hook subprocesses (per [`codex-rs/hooks/src/engine/discovery.rs`](https://github.com/openai/codex/blob/main/codex-rs/hooks/src/engine/discovery.rs)), so the same hook scripts work across both hosts without duplication. Subagent / SessionEnd / Notification / TaskCompleted / PostToolUseFailure events are Claude-Code-only and are not registered for Codex.

#### Codex Desktop: plugin hooks currently silent (workaround available)

`CodexHooks` and `PluginHooks` are both stable + default-enabled in [`codex-rs/features/src/lib.rs`](https://github.com/openai/codex/blob/main/codex-rs/features/src/lib.rs), but Codex Desktop builds currently do not dispatch plugin-local `hooks.json` ([openai/codex#16430](https://github.com/openai/codex/issues/16430)). MCP tools still work; only the lifecycle observations are missing.

Until upstream lands the fix, mirror the same hook commands into the global `~/.codex/hooks.json`:
bash agentmemory connect codex --with-hooks

This adds an idempotent block to `~/.codex/hooks.json` referencing absolute paths to the bundled scripts (no `${CLAUDE_PLUGIN_ROOT}` expansion needed at user-scope). Re-run the same command after upgrading agentmemory to refresh paths. User entries in the same file are preserved; only previous agentmemory entries are replaced.

<details>
<summary><b>OpenClaw (paste this prompt)</b></summary>
Install agentmemory for OpenClaw. Run npx @agentmemory/agentmemory in a separate terminal to start the memory server on localhost:3111. Then add this to my OpenClaw MCP config so agentmemory is available with all 51 memory tools:

{ "mcpServers": { "agentmemory": { "command": "npx", "args": ["-y", "@agentmemory/mcp"], "env": { "AGENTMEMORY_URL": "http://localhost:3111" } } } }

Restart OpenClaw. Verify with curl http://localhost:3111/agentmemory/health. Open http://localhost:3113 for the real-time viewer. For deeper memory-slot integration, copy integrations/openclaw to ~/.openclaw/extensions/agentmemory and enable plugins.slots.memory = "agentmemory" in ~/.openclaw/openclaw.json.


Full guide: [`integrations/openclaw/`](integrations/openclaw/)

</details>

<details>
<summary><b>Hermes Agent (paste this prompt)</b></summary>
Install agentmemory for Hermes. Run npx @agentmemory/agentmemory in a separate terminal to start the memory server on localhost:3111. Then add this to ~/.hermes/config.yaml so Hermes can use agentmemory as an MCP server with all 51 memory tools:

mcp_servers: agentmemory: command: npx args: ["-y", "@agentmemory/mcp"]

memory: provider: agentmemory

Verify with curl http://localhost:3111/agentmemory/health. Open http://localhost:3113 for the real-time viewer. For deeper 6-hook memory provider integration (pre-LLM context injection, turn capture, MEMORY.md mirroring, system prompt block), copy integrations/hermes from the agentmemory repo to ~/.hermes/plugins/agentmemory. ```

Full guide: integrations/hermes/

</details>

1. Install Docker Desktop for Windows

2. Start Docker Desktop and make sure the engine is running

# Azure: https://<resource>.openai.azure.com/openai/deployments/<deployment>

Terminal 2: seed sample data and see recall in action

npx @agentmemory/agentmemory demo ```

demo seeds 3 realistic sessions (JWT auth, N+1 query fix, rate limiting) and runs semantic searches against them. You'll see it find "N+1 query fix" when you search "database performance optimization" — keyword matching can't do that.

Open http://localhost:3113 to watch the memory build live.

Config File

Put agentmemory runtime configuration in ~/.agentmemory/.env instead of exporting variables in every shell. If the viewer shows a setup hint like export ANTHROPIC_API_KEY=..., copy it into this file as ANTHROPIC_API_KEY=... without the export prefix, then restart agentmemory.

Process environment variables still work and take precedence over values in the file.

On Windows, the same file lives at %USERPROFILE%\.agentmemory\.env:

New-Item -ItemType Directory -Force $HOME\.agentmemory
notepad $HOME\.agentmemory\.env

To test with a Claude Code Pro/Max subscription instead of an API key, opt in explicitly:

AGENTMEMORY_ALLOW_AGENT_SDK=true
AGENTMEMORY_AUTO_COMPRESS=true

Turn on graph or consolidation features in the same file if you want them:

GRAPH_EXTRACTION_ENABLED=true
CONSOLIDATION_ENABLED=true

Environment Variables

Create ~/.agentmemory/.env:

```env

ANTHROPIC_BASE_URL=... # Optional: Anthropic-compatible proxy / Azure

OPENAI_BASE_URL=https://api.openai.com # Optional: override for Azure / vLLM / LM Studio / proxies

OPENAI_API_VERSION=2024-08-01-preview # Optional: Azure api-version query param

OPENAI_MODEL=gpt-4o-mini # Optional: default model

OPENAI_TIMEOUT_MS=60000 # Optional: OpenAI-scoped alias for the outbound fetch

# for back-compat with v0.9.17. New configs should

OPENAI_REASONING_EFFORT=none # Optional: "low" | "medium" | "high" | "none"

OPENAI_API_KEY_FOR_LLM=false # Optional: set to false to skip OpenAI auto-detection

Codex CLI (Codex plugin platform)

```bash

ANTHROPIC_API_KEY=sk-ant-...

GEMINI_API_KEY=...

OPENROUTER_API_KEY=...

MINIMAX_API_KEY=...

OPENAI_API_KEY=*** # NOTE: this same key auto-activates BOTH the

# OPENAI_API_KEY_FOR_LLM=false to scope it

# api-key header + api-version query param.

Opt-in Claude-subscription fallback (spawns @anthropic-ai/claude-agent-sdk);

AGENTMEMORY_ALLOW_AGENT_SDK=true

VOYAGE_API_KEY=...

OPENAI_API_KEY=sk-...

OPENAI_BASE_URL=https://api.openai.com # Override for Azure / vLLM / LM Studio / proxies

or via the shim package:

npx -y @agentmemory/mcp


**Diagnostics for Windows:** if `npx @agentmemory/agentmemory` fails, re-run with `--verbose` to see the actual engine stderr. Common failure modes:

| Symptom | Fix |
|---|---|
| `iii-engine process started` then `did not become ready within 15s` | Engine crashed on startup — re-run with `--verbose`, check stderr |
| `Could not start iii-engine` | Neither `iii.exe` nor Docker is installed. See Option A or B above |
| Port conflict | `netstat -ano \| findstr :3111` to see what's bound, then kill it or use `--port <N>` |
| Docker fallback skipped even though Docker is installed | Make sure Docker Desktop is actually running (system tray icon) |

> Note: there is no `cargo install iii-engine` — `iii` is not published to crates.io. The only supported install methods are the prebuilt binary above, the upstream `sh` install script (macOS/Linux only), and the Docker image.

---

<h2 id="deploy">Deploy</h2>

One-click templates for managed hosts. Each one ships a self-contained
Dockerfile that pulls `@agentmemory/agentmemory` from npm and copies
the iii engine binary in from the official `iiidev/iii` Docker Hub
image — no pre-built agentmemory image required. Persistent storage
mounts at `/data`; the first-boot entrypoint overwrites the
npm-bundled iii config (which binds `127.0.0.1`) with a deploy-tuned
one that binds `0.0.0.0` and uses absolute `/data` paths, generates
the HMAC secret, then drops privileges from `root` to `node` via
`gosu` before exec'ing the agentmemory CLI.

<p>
  <a href="https://fly.io/launch?repo=https://github.com/rohitg00/agentmemory&path=deploy/fly"><img src="https://img.shields.io/badge/Deploy%20to-fly.io-8b5cf6?style=for-the-badge&logo=fly.io&logoColor=white" alt="Deploy to fly.io" /></a>
  <a href="https://railway.com/new/template?template=https%3A%2F%2Fgithub.com%2Frohitg00%2Fagentmemory&rootDirectory=deploy%2Frailway"><img src="https://img.shields.io/badge/Deploy%20to-Railway-0B0D0E?style=for-the-badge&logo=railway&logoColor=white" alt="Deploy to Railway" /></a>
</p>

Render's one-click deploy button requires `render.yaml` at the repository root, which we deliberately keep clean. Use the Render Blueprint flow documented in [`deploy/render/`](./deploy/render/README.md) to point at the in-repo blueprint manually.

Full setup details (HMAC capture, viewer SSH tunnel, rotation, backup,
cost floors) live in [`deploy/`](./deploy/README.md):

- [`deploy/fly`](./deploy/fly/README.md) — single machine with
  `auto_stop_machines = "stop"`; cheapest idle.
- [`deploy/railway`](./deploy/railway/README.md) — Hobby plan flat fee,
  volume in the dashboard.
- [`deploy/render`](./deploy/render/README.md) — Blueprint flow,
  automatic disk snapshots on paid plans.
- [`deploy/coolify`](./deploy/coolify/README.md) — self-hosted on your
  own VPS via [Coolify](https://coolify.io/self-hosted); same Docker
  Compose stack, you own the host and the data.

Only port `3111` is published. The viewer on `3113` stays bound to
loopback inside the container — every template's README documents the
SSH-tunnel pattern for reaching it.

---

<h2 id="why-agentmemory"><picture><source media="(prefers-color-scheme: dark)" srcset="assets/tags/light/section-why.svg"><img src="assets/tags/section-why.svg" alt="Why agentmemory" height="32" /></picture></h2>

Every coding agent forgets everything when the session ends. You waste the first 5 minutes of every session re-explaining your stack. agentmemory runs in the background and eliminates that entirely.
Session 1: "Add auth to the API" Agent writes code, runs tests, fixes bugs agentmemory silently captures every tool use Session ends -> observations compressed into structured memory

Session 2: "Now add rate limiting" Agent already knows: - Auth uses JWT middleware in src/middleware/auth.ts - Tests in test/auth.test.ts cover token validation - You chose jose over jsonwebtoken for Edge compatibility Zero re-explaining. Starts working immediately. ```

Memory Pipeline

PostToolUse hook fires
  -> SHA-256 dedup (5min window)
  -> Privacy filter (strip secrets, API keys)
  -> Store raw observation
  -> LLM compress -> structured facts + concepts + narrative
  -> Vector embedding (6 providers + local)
  -> Index in BM25 + vector

Stop / SessionEnd hook fires
  -> Summarize session
  -> Knowledge graph extraction (if GRAPH_EXTRACTION_ENABLED=true)
  -> Slot reflection (if SLOT_REFLECT_ENABLED=true)

SessionStart hook fires
  -> Load project profile (top concepts, files, patterns)
  -> Hybrid search (BM25 + vector + graph)
  -> Token budget (default: 2000 tokens)
  -> Inject into conversation

vs built-in agent memory

Every AI coding agent ships with built-in memory — Claude Code has MEMORY.md, Cursor has notepads, Cline has memory bank. These work like sticky notes. agentmemory is the searchable database behind the sticky notes.

Built-in (CLAUDE.md)agentmemory
Scale200-line capUnlimited
SearchLoads everything into contextBM25 + vector + graph (top-K only)
Token cost22K+ at 240 observations~1,900 tokens (92% less)
Cross-agentPer-agent filesMCP + REST (any agent)
CoordinationNoneLeases, signals, actions, routines
ObservabilityRead files manuallyReal-time viewer on :3113

---

How It Works

🇨🇳 中文文档镜像 AI 翻译 2026-05-23
英文原文章节由系统翻译为中文摘要,便于快速理解。完整原文见上方 "📑 README 深度解析"。
📌 简介

agentmemory 是一个持久性记忆系统,用于 AI 编码代理。它基于 iii 引擎,提供了一个持久性记忆系统,用于 Claude Code、Cursor、Gemini CLI、Codex CLI、Hermes、OpenClaw、pi、OpenCode 等编码代理。

⚡ 功能介绍

agentmemory 的关键功能包括自动捕获、语义搜索、记忆演进、自动遗忘和隐私优先。它使用 BM25 + 向量 + 知识图谱融合语义搜索,支持版本控制、超级替代、关系图谱等功能。

📋 环境依赖

agentmemory 需要 OPENAI_EMBEDDING_DIMENSIONS=1536 环境变量,用于设置嵌入维度。

🛠 安装步骤(Docker/pip/源码)

安装 agentmemory 可以使用 npm install -g @agentmemory/agentmemory 或 npx @agentmemory/agentmemory。也可以使用 Docker 或 pip 安装。

⚙️ 配置说明(含 MCP / env)

agentmemory 的配置文件位于 ~/.agentmemory/.env 中。可以在这个文件中设置 Anthropic Base URL、Anthropic API Key 等环境变量。

🔌 API 说明

agentmemory 提供了 Codex CLI API,用于与 Codex CLI 进行交互。可以使用 ANTHROPIC_API_KEY 和 GEMINI_API_KEY 等环境变量来配置 API。

🔄 工作流/模块

agentmemory 的工作流包括 PostToolUse 钩子、SHA-256 去重、隐私过滤器、存储原始观察、LLM 压缩、结构化事实和概念、向量嵌入等。

🎯 aiskill88 AI 点评 A 级 2026-05-20

工程化程度高,解决AI agent的核心痛点——记忆能力。13.6k星证明社区认可度强,TypeScript实现保证代码质量,持续维护值得信赖。

📚 实用指南(长尾问题)
适合谁
  • 使用 Cursor 编辑器、希望提升 AI 编程效率的开发者
  • 需要让 Claude / Cursor 操作本地工具的 AI 工程师
  • 构建多智能体协作系统的 Agent 开发者
  • 构建企业知识库 / RAG 检索应用的团队
最佳实践
  • 配置 MCP 服务器时建议使用 stdio 传输 + JSON-RPC,避免暴露公网
  • 生产部署优先使用 Docker Compose 隔离依赖,并挂载 volume 持久化数据
  • 本地部署优先选 GGUF 量化模型,节省显存并保持响应速度
  • Agent 任务先做 dry-run 验证工具调用链,再开启自主执行
  • Cursor rules 控制在 80 行内,否则模型上下文成本会显著上升
常见错误
  • API key 直接提交到 git 仓库(请用 .env 并加入 .gitignore)
  • MCP 配置路径拼错或权限不足,重启 Claude Desktop 才生效
  • 容器内无法访问宿主机 localhost — 使用 host.docker.internal
  • 显存不足直接 OOM — 优先降低 context 或换更小的量化模型
部署方案
  • Docker:agentmemory 提供官方镜像,docker compose up 一键启动
  • CLI:直接 npm install -g / pip install,命令行调用
  • 本地部署:CPU 8GB 起,GPU 推荐 16GB+ 显存
  • 云端托管:可放在 Vercel / Railway / Fly.io 等 PaaS 平台
⚡ 核心功能
  • 开源免费,支持本地部署,数据完全自主可控
  • 活跃的 GitHub 开源社区,持续迭代更新
  • 提供详细文档和使用示例,新手友好
  • 支持自定义配置,灵活适配不同使用环境
  • 可作为基础组件集成进现有技术栈或进行二次开发
👥 适合谁
  • 使用 Cursor 编辑器、希望提升 AI 编程效率的开发者
  • 需要让 Claude / Cursor 操作本地工具的 AI 工程师
  • 构建多智能体协作系统的 Agent 开发者
  • 构建企业知识库 / RAG 检索应用的团队
⭐ 最佳实践
  • 配置 MCP 服务器时建议使用 stdio 传输 + JSON-RPC,避免暴露公网
  • 生产部署优先使用 Docker Compose 隔离依赖,并挂载 volume 持久化数据
  • 本地部署优先选 GGUF 量化模型,节省显存并保持响应速度
  • Agent 任务先做 dry-run 验证工具调用链,再开启自主执行
⚠️ 常见错误
  • API key 直接提交到 git 仓库(请用 .env 并加入 .gitignore)
  • MCP 配置路径拼错或权限不足,重启 Claude Desktop 才生效
  • 容器内无法访问宿主机 localhost — 使用 host.docker.internal
  • 显存不足直接 OOM — 优先降低 context 或换更小的量化模型
👥 适合人群
AI 技术爱好者研究人员和学生开发者和工程师技术创业者
🎯 使用场景
  • 本地部署运行,保护数据隐私,满足合规要求
  • 自定义集成到现有系统,扩展技术栈能力
  • 作为开源基础组件进行商业化二次开发
⚖️ 优点与不足
✅ 优点
  • +GitHub 13.6k Star,社区高度认可
  • +Apache-2.0 协议,可免费商用
  • +完全开源免费,无授权费用
  • +本地部署,数据完全自主可控
  • +开发者社区支持,遇问题可查可问
⚠️ 不足
  • 安装和初始配置可能需要一定技术基础
  • 功能完整性通常不如成熟商业产品
  • 技术支持主要依赖开源社区,响应速度不稳定
⚠️ 使用须知

AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。

建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。

📄 License 说明

✅ Apache 2.0 — 宽松开源协议,可商用,需保留版权声明和 NOTICE 文件,含专利授权条款。

❓ 常见问题 FAQ
主要支持Claude及其他主流LLM,可扩展集成其他模型。
💡 AI Skill Hub 点评

总体来看,AI编码助手持久化记忆系统 是一款质量优秀的AI工具,在同类工具中具备一定竞争力。AI Skill Hub 将持续追踪其更新动态,建议收藏备用,结合自身场景选择合适时机引入使用。

📚 深入学习 AI编码助手持久化记忆系统
查看分步骤安装教程和完整使用指南,快速上手这款工具
🌐 原始信息
原始名称 agentmemory
原始描述 开源AI工作流:#1 Persistent memory for AI coding agents based on real-world benchmarks。⭐13.6k · TypeScript
Topics 智能体记忆AI工作流编码助手Claude持久化存储
GitHub https://github.com/rohitg00/agentmemory
License Apache-2.0
语言 TypeScript
🔗 原始来源
🐙 GitHub 仓库  https://github.com/rohitg00/agentmemory 🌐 官方网站  https://agent-memory.dev

收录时间:2026-05-19 · 更新时间:2026-05-19 · License:Apache-2.0 · AI Skill Hub 不对第三方内容的准确性作法律背书。