agentmemory: Persistent, token‑efficient memory for any coding LLM agent
agentmemory – Persistent memory for AI coding agents
What it is – agentmemory is a self‑hosted memory engine that sits alongside large‑language‑model‑based coding assistants (Claude Code, GitHub Copilot CLI, Gemini CLI, Codex CLI, Cursor, etc.). It automatically records what the agent does, compresses the information into a searchable store, and injects the right context the next time the agent runs, so you never have to re‑explain your codebase, authentication setup, or past bugs.
Key ideas
- Built on the open‑source iii engine (v0.11.2) and uses only SQLite – no external vector DBs.
- Hybrid retrieval: BM25 + local embeddings (
all‑MiniLM‑L6‑v2) + graph‑based RRF fusion. - Auto‑capture via 12 built‑in hooks; no manual
add()calls. - Multi‑agent aware: a single memory server (
agentmemoryon port 3111) can serve any MCP‑ or HTTP‑compatible agent, letting several agents share the same knowledge base. - Lifecycle management: 4‑tier consolidation, decay, and auto‑forget to keep the store fresh and token‑efficient.
Installation & quick start
# Global install (adds the `agentmemory` command)
npm install -g @agentmemory/agentmemory
# Start the memory server (default data dir under your OS’s app‑data folder)
agentmemory # → listens on :3111
# Run a demo that seeds sample sessions and verifies recall
agentmemory demo # or: agentmemory demo --serve
# Wire a coding agent into the memory server
agentmemory connect claude-code # works for copilot‑cli, codex, cursor, gemini‑cli, etc.
You can also run it one‑off with npx @agentmemory/agentmemory – the first run will install the pinned iii engine in ~/.agentmemory/bin.
Supported agents – any tool that implements MCP (Memory‑Control‑Protocol) or a simple REST API. The README lists 54 integrations, including Claude Code, GitHub Copilot CLI, OpenClaw, Hermes, pi, OpenCode, Cursor, Gemini CLI, Aider, Warp, and many more.
Benchmarks
| Metric | Result |
|---|---|
| Recall @5 (LongMemEval‑S, 500 Q) | 95.2 % |
| Recall @10 | 98.6 % |
| MRR | 88.2 % |
| Token savings vs pasting full context | ~170 K tokens/yr (≈ $10/yr) |
| Retrieval latency (top‑5) | 14 ms |
| Hybrid vs grep baseline (coding‑agent‑life‑v1) | 100 % top‑5 hit rate, 1 000 ms latency vs 0 ms grep |
The project also provides a real‑time viewer (localhost:3113) to inspect stored memories, and a set of “recipes” for pairing with graph‑indexing tools like codegraph, Understand Anything, and Graphify.
Why it matters
- Token economy – By summarizing and re‑using past interactions, agents stay within model context windows and dramatically cut API costs.
- Developer productivity – No more copy‑pasting long config files or re‑explaining authentication logic; the agent recalls prior sessions automatically.
- Multi‑agent collaboration – A single memory server can be shared across different agents, enabling coordinated workflows.
Getting help – The repo includes a full changelog, benchmark docs, evaluation harness, and a design‑doc gist that has over 1.3 k stars. Issues can be filed on GitHub; CI runs on every push.
All information above is taken directly from the repository’s README; no additional features are inferred.