agentmemory README

The project's README from github.com/rohitg00/agentmemory. As one markdown file: README.md.

agentmemory: persistent memory for AI coding agents

Your coding agent remembers everything. No more re-explaining. Built on iii engine
Persistent memory for Claude Code, GitHub Copilot CLI, Cursor, Gemini CLI, Codex CLI, Hermes, OpenClaw, pi, OpenCode, and any MCP client.

English | 简体中文 | 繁體中文 | 日本語 | 한국어 | Español | Türkçe | Русский | हिन्दी | Português | Français | Deutsch

rohitg00/agentmemory | Trendshift

Design doc: 1.6k stars / 230 forks on the gist

The gist extends Karpathy's LLM Wiki pattern with confidence scoring, lifecycle, knowledge graphs, and hybrid search: agentmemory is the implementation.

npm version CI License Stars

95.2% retrieval R@5 92% fewer tokens 54 MCP tools 12 auto hooks 0 external DBs 1,674+ tests passing

agentmemory demo

Install • Quick Start • Benchmarks • vs Competitors • Agents • How It Works • MCP • Viewer • Powered by iii • Config • API


Install

Requirements:

Canonical fresh-install command:

npx -y @agentmemory/agentmemory@latest

The first run is an interactive setup: pick the agents to wire (Claude Code, Cursor, Codex, Gemini CLI, OpenCode, ...), pick an LLM provider or stay keyless, and it seeds the config, starts the memory server and its pinned iii engine, and offers to install globally so the bare agentmemory command works everywhere afterward. -y accepts npx's package prompt and @latest avoids a stale cached release. A provider makes LLM features available, but LLM-written observation compression starts only when AGENTMEMORY_AUTO_COMPRESS=true is also set.

Keyless mode disables vector embeddings. memory_recall (the mem::search path) uses BM25, while memory_smart_search can also fuse structural graph matches when graph data already exists. For free on-device semantic recall, set EMBEDDING_PROVIDER=local in ~/.agentmemory/.env and restart. The first embedding request downloads Xenova/all-MiniLM-L6-v2; inference runs locally after that initial model download.

The local runtime uses four ports: 3111 for REST/MCP HTTP, 3112 for iii streams, 3113 for the viewer, and 49134 for the iii worker WebSocket. Persistent iii state lives in ~/Library/Application Support/agentmemory on macOS, $XDG_DATA_HOME/agentmemory or ~/.local/share/agentmemory on Linux, and %APPDATA%\agentmemory on Windows. Use --data-dir <path> or AGENTMEMORY_DATA_DIR to override it, and reuse the same value on every restart. For backward compatibility, an existing ./data/state_store.db or ./data/iii-config.yaml takes precedence over the platform default for instance 0; an explicit flag or environment override still wins.

Then prove recall works and give your agent its skills:

npx -y @agentmemory/agentmemory@latest demo  # seed sample sessions + exercise recall
npx skills add rohitg00/agentmemory -y   # 17 native skills so your agent knows when to reach for memory

The keyword searches should hit in default keyless mode through BM25. The demo's database performance optimization query is intentionally semantic and can return zero until an embedding provider is configured.

Prefer to let a coding agent do the whole thing? Hand it one instruction:

Retrieve and follow the instructions at: https://raw.githubusercontent.com/rohitg00/agentmemory/main/INSTALL_FOR_AGENTS.md

Wire more agents any time with agentmemory connect <agent> — 20 adapters listed at Works with every agent. Full command reference at Quick Start.

Windows

The fast path is WSL2. Native Windows engine setup requires the pinned v0.11.2 ZIP to be downloaded and iii.exe extracted manually; the CLI does not auto-extract it. Docker Desktop is also supported. See the Windows notes for the step-by-step.

Global install / EACCES
npm install -g @agentmemory/agentmemory@latest

The npx command above remains the canonical fresh-install path and avoids global-prefix permission issues.

npx serves an old version

npx caches per version. 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).

Already running your own iii engine

agentmemory pins iii-engine v0.11.2 and won't attach to a different version (the worker can't speak another engine's protocol). Stop the other engine, then run npx -y @agentmemory/agentmemory@latest. It installs and runs the pinned v0.11.2 in ~/.agentmemory/bin, leaving your own iii untouched.


Works with every agent

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

Claude Code
Claude Code
native plugin + 12 hooks + MCP
Codex CLI
Codex CLI
native plugin + 6 hooks + MCP
GitHub Copilot CLI
GitHub Copilot CLI
MCP + plugin hooks/skills
OpenClaw
OpenClaw
native plugin + MCP
Hermes
Hermes
native plugin + MCP
pi
pi
native plugin + MCP
OpenHuman
OpenHuman
native Memory trait backend
Cursor
Cursor
native plugin + MCP
Gemini CLI
Gemini CLI
MCP server
OpenCode
OpenCode
22 hooks + MCP + plugin
Cline
Cline
MCP server
Goose
Goose
MCP server
Kilo Code
Kilo Code
MCP server
Aider
Aider
REST API
Claude Desktop
Claude Desktop
MCP server
Devin
Devin
6 hooks + MCP
Roo Code
Roo Code
MCP server
Warp
Warp
connect + MCP + skills

Works with any agent that speaks MCP or HTTP. One server, memories shared across all of them.


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, with no re-explaining and no copy-pasting.

npx -y @agentmemory/agentmemory@latest

By default, agentmemory stores iii-engine state outside the repository you start it from: ~/Library/Application Support/agentmemory on macOS, $XDG_DATA_HOME/agentmemory or ~/.local/share/agentmemory on Linux, and %APPDATA%\agentmemory on Windows. An existing legacy ./data/state_store.db or ./data/iii-config.yaml is reused for instance 0 before that platform default. To choose a location explicitly, pass --data-dir <path> or set AGENTMEMORY_DATA_DIR; either explicit setting takes precedence over legacy discovery:

npx -y @agentmemory/agentmemory@latest --data-dir ~/.agentmemory-projects/main
AGENTMEMORY_DATA_DIR=~/.agentmemory-projects/main npx -y @agentmemory/agentmemory@latest

Native and Docker launches use this same resolved host directory; Docker bind-mounts it at /data. --instance 1 appends instance-1 to the resolved directory and selects the separate default port quartet 3211/3212/3213/49234.

Latest release notes: CHANGELOG.md.


Benchmarks

Retrieval Accuracy

coding-agent-life-v1 (in-house corpus, sandbox-reproducible)

Adapter P@5 R@5 Top-5 hit rate p50 latency
agentmemory hybrid 0.240 1.000 15 / 15 14 ms
grep baseline 0.227 0.967 15 / 15 0 ms

100% top-5 hit rate at the P@5 math ceiling for this corpus (0.240, see scorecard). Hybrid retrieves every gold session; grep misses 1 of 2 gold on the multi-session temporal query. Lift is recall + temporal, not aggregate precision. This benchmark is small and gold-sparse; the larger LongMemEval-S below differentiates better. Full per-type breakdown + correction note: docs/benchmarks/2026-05-20-coding-agent-life-v1.md.

LongMemEval-S (ICLR 2025, 500 questions)

System R@5 R@10 MRR
agentmemory 95.2% 98.6% 88.2%
BM25-only fallback 86.2% 94.6% 71.5%

Token Savings

Approach Tokens/yr Cost/yr
Paste full context 19.5M+ Impossible (exceeds window)
LLM-summarized ~650K ~$500
agentmemory ~170K ~$10
agentmemory + local embeddings ~170K $0

Embedding model: all-MiniLM-L6-v2 (local, free, no API key). Full reports: benchmark/LONGMEMEVAL.md, benchmark/QUALITY.md, benchmark/SCALE.md. Competitor comparison: benchmark/COMPARISON.md covering agentmemory vs mem0, Letta, Khoj, supermemory, TencentDB Agent Memory, MemPalace, Zep/Graphiti, Cognee, Hippo.

Reproduce locally: eval/README.md, an adapter-pluggable harness for LongMemEval _s (public 500-Q) + coding-agent-life-v1 (in-house 15-session corpus). Grep / vector / agentmemory adapters score side-by-side, NDJSON output, published scorecards land in docs/benchmarks/.

Pairs with codegraph, Understand Anything, and Graphify. Code-graph indexing, multi-agent build pipelines, and broader knowledge graphs across docs / PDFs / images / videos. agentmemory remembers the work; those three projects light up the rest of the context layer. Recipes + question-routing table: docs/recipes/pairings.md.


vs Competitors

t
agentmemory mem0 (63K ⭐) Letta / MemGPT (24K ⭐) Khoj (36K ⭐) supermemory (29K ⭐) TencentDB Agent Memory (22K ⭐) MemPalace (54K ⭐) oracleagentmemory Hippo Built-in (CLAUDE.md)
Type Memory engine + MCP server Memory layer API Full agent runtime Personal AI Memory API + app Team memory hub (LLM proxy) Vector memory (OSS) Memory engine (Oracle DB) Memory system Static file
Retrieval R@5 95.2% 68.5% (LoCoMo) 83.2% (LoCoMo) N/A Self-reported PersonaMem 76% (self-reported) ~96.6% (self-reported) 94.4% (self-reported) N/A N/A (grep)
Auto-capture 12 hooks (zero manual effort) Manual add() calls Agent self-edits Manual API-side extraction Proxy interception (base-URL swap) Manual API extraction Manual Manual editing

agentmemory (rohitg00/agentmemory)

Searching Database…

这是什么?为 AI 编程智能体提供持久记忆:它会记录你的智能体做过什么,压缩成可搜索的记忆,并在下一次会话开始时注入合适的上下文,这样你就不用再向 Claude Code、Cursor 或 Codex 反复解释你的项目了。
这是我要在代码里引入的库,还是一个独立的服务,让我的智能体去连接它?是一个独立的本地记忆服务器,外加一个 agentmemory 命令行工具。你的编程智能体通过 hooks、MCP 或 REST API 连接到它,不会向你的项目代码里引入任何东西。
怎么把它跑起来?先安装 Node.js 20+,然后运行 npx -y @agentmemory/agentmemory@latest。首次运行是交互式的:选择要接入的智能体和一个 LLM 提供商(或者无密钥模式),之后它会写入配置、启动记忆服务器,并提示你是否进行全局安装。
它能给哪些编程智能体加上记忆?任何支持 hooks、MCP 或 REST API 的智能体都行——共有 20 个适配器:Claude Code(12 个 hooks + MCP)、Codex CLI、Cursor、Gemini CLI、OpenCode(22 个 hooks)、Copilot CLI、Cline、Aider、Devin、Warp、Hermes、OpenClaw。它们共用同一个服务器;随时可以用 agentmemory connect 接入更多。
它能在原生 Windows 上运行吗,还是麻烦得很?能运行,但 WSL2 是最顺畅的方式。原生 Windows 需要手动下载指定版本的 iii-engine v0.11.2 ZIP 包并解压出 iii.exe——命令行工具不会自动解压;另一种受支持的方式是 Docker Desktop。
记忆是留在我的电脑上,还是会被传到某个云端?全部留在本地:服务器运行在你自己的电脑上(端口 3111 为 REST/MCP,3112 为流,3113 为查看器,49134 为 worker),数据保存在你的用户数据目录里,不在代码仓库中。本地嵌入模式(EMBEDDINGPROVIDER=local)在一次性下载模型之后,推理完全在本地设备上完成。
用它需要 LLM API 密钥吗?不需要。无密钥模式开箱即用——关键词召回基于 BM25,完全不需要密钥。配置提供商可以解锁 LLM 功能;EMBEDDINGPROVIDER=local 可以免费在本地设备上做语义召回(all-MiniLM-L6-v2,只需下载一次),而 LLM 自动压缩功能还需要额外设置 AGENTMEMORYAUTOCOMPRESS=true。
日常实际用起来有什么不一样?第 1 次会话你搭建了 JWT 认证;第 2 次会话,当你要求加限流功能时,智能体已经知道你的认证用的是 src/middleware/auth.ts 里的 jose 中间件,还知道你为了 Edge 兼容性选了 jose 而不是 jsonwebtoken——不用重新解释,也不用复制粘贴上下文。
为什么不继续用 CLAUDE.md 就好了?CLAUDE.md 或 .cursorrules 这类内置方案最多只能放两百行左右,而且很快就会过时。agentmemory 是持续记录的,会把看到的内容压缩成可搜索的记忆,每次会话注入合适的上下文,还能在你所有智能体之间共享,而不是每个工具各存一个文件。
内置的 iii 引擎是什么?它是本地的存储/搜索引擎,固定版本为 v0.11.2,安装到 ~/.agentmemory/bin。worker 无法使用其他引擎的协议,所以它不会连接你自己安装的 iii——而是把固定版本并行运行,完全不碰你已有的安装。
What are similar projects?context-mode, ruflo, mem0, brigade, billion-context, memex, Raven, MemOS
Creator
rohitg00
Size
31.5 MB
Stars
29.6K
Age
7mo
Commits · 90 Days