agentmemory: Persistent Memory for AI Coding Agents

9 min read

agentmemory (rohitg00) explained: persistent memory for Claude Code, Cursor and Codex, npx setup, its self-reported benchmarks, vs Hindsight and Mem0.

agentmemory is an open-source memory server that gives AI coding agents persistent memory across sessions. Hooks in Claude Code, Codex CLI, Cursor, Hermes, OpenClaw and other agents record what the agent does, and the server injects the most relevant past context when the next session starts. You install it with npx -y @agentmemory/agentmemory@latest.

The project lives at github.com/rohitg00/agentmemory, is written in TypeScript under the Apache 2.0 license, and had about 29,300 GitHub stars on 12 October 2026. This page covers what it does, how it works, how to set it up, what its benchmark numbers mean, and how it compares with Hindsight and Mem0 for coding-agent memory. Facts come from the agentmemory README and benchmark files, checked on 12 October 2026. (This site, aiagentmemory.org, has no connection to the agentmemory project.)

What is agentmemory?

agentmemory is a local memory server for coding agents. It captures prompts, tool calls and results through agent hooks, compresses them into searchable memories, and returns a small, ranked set of past context (2,000 tokens by default) at the start of each session. Any agent that speaks MCP or HTTP can share the same memory.

The problem it targets is simple. Each new coding session starts from zero, so you explain your stack, your past bugs and your choices again. Built-in memory files like CLAUDE.md or Cursor rules help, but they are loaded whole into every session. The README’s example: in session 1 you add JWT auth; in session 2 you ask for rate limiting, and the agent already knows the auth middleware lives in src/middleware/auth.ts and that you picked jose over jsonwebtoken.

agentmemory runs on the iii engine (a pinned v0.22.1) and stores state in local files by default, with Redis as an option. It needs no external database. The README is translated into more than 30 languages, including Simplified and Traditional Chinese.

Other projects named agentmemory

Several unrelated projects use the same name. Check which one a guide means:

NameWhat it isStatus (12 Oct 2026)
rohitg00/agentmemory, npm @agentmemory/agentmemoryMemory server for coding agents (this page)Active, v0.9.30 on npm
PyPI agentmemory (pip install agentmemory)Python library for agent memory and document search on ChromaDB, or Postgres with pgvectorLast release 0.4.8, October 2023; its listed GitHub repo returns 404
mturac/agentmemoryA GitHub fork of rohitg00/agentmemoryFork, no separate releases

How agentmemory works

The memory pipeline runs on agent lifecycle hooks. Claude Code gets 12 hooks, Codex CLI 6 and Cursor 7, according to the README.

  1. During the session, the PostToolUse hook sends each tool call to the server. It drops duplicates (SHA-256, 5-minute window), strips API keys, secrets and <private> tags, stores the raw observation, and indexes it for keyword search (and vectors, if embeddings are on).
  2. At session end, the Stop and SessionEnd hooks summarize the session. Knowledge graph extraction runs only if you enable it.
  3. At the next session start, the SessionStart hook loads a project profile (top concepts, files, patterns), runs a hybrid search and injects results within a token budget (2,000 tokens by default).
  4. Before context compaction, the PreCompact hook re-injects memory so it isn’t lost.

Search fuses three streams with reciprocal rank fusion (k=60): BM25 keyword search (always on), vector search (when an embedding provider is set) and knowledge graph traversal (when the query names known entities). It keeps at most 3 results per session so one long session can’t fill the context.

Memory tiers follow the familiar split of working, episodic, semantic and procedural memory. The README says memories decay over time on an Ebbinghaus curve, frequently used ones get stronger, stale ones are evicted, and contradictions are detected. See AI agent memory types for what those tiers mean.

LLM use is optional. The default provider is a no-op: compression is “synthetic” (no LLM) and recall uses BM25. LLM-written compression needs both a provider key (Anthropic, OpenAI, Gemini, OpenRouter, MiniMax or a local OpenAI-compatible server like Ollama) and AGENTMEMORY_AUTO_COMPRESS=true. Keyless mode also turns off vector embeddings until you set EMBEDDING_PROVIDER=local, which downloads all-MiniLM-L6-v2 once and then runs on your machine.

For Chinese, Japanese and Korean text, BM25 splits whole runs of characters as one token unless you install the optional segmenters: npm install @node-rs/jieba tiny-segmenter. If your notes and prompts are in Chinese, install them, or keyword recall will be weak.

Other features the README lists: an MCP server with 54 tools (8 in core mode), a live viewer on localhost:3113 with session replay, per-agent scoping with AGENT_ID (shared or isolated), import of old Claude Code JSONL transcripts, and git snapshots of memory state.

How to set up agentmemory

agentmemory needs Node.js 20 or newer. On macOS and Linux the first run downloads the iii engine automatically; native Windows needs a manual iii.exe download, so WSL2 or Docker are easier there.

  1. Start the server and run the setup wizard: npx -y @agentmemory/agentmemory@latest. It asks which agents to connect and which LLM provider to use (or none).
  2. Check it works: curl http://localhost:3111/agentmemory/health, then run npx -y @agentmemory/agentmemory@latest demo to seed three sample sessions and test recall.
  3. In Claude Code, install the plugin: /plugin marketplace add rohitg00/agentmemory, then /plugin install agentmemory. This registers the hooks, the skills and the MCP server.
  4. In Codex CLI: codex plugin marketplace add rohitg00/agentmemory, then codex plugin add agentmemory@agentmemory, and trust the plugin hooks.
  5. For other agents (Cursor, Gemini CLI, OpenCode, Hermes, OpenClaw and others), run agentmemory connect <agent>. Pure MCP clients need AGENTMEMORY_URL=http://localhost:3111, or they see only 7 fallback tools.
  6. Optional: add EMBEDDING_PROVIDER=local to ~/.agentmemory/.env and restart for semantic search. Open http://localhost:3113 to watch memories arrive.

The server uses four local ports (3111, 3112, 3113, 49134). Data lives outside your repo, in ~/Library/Application Support/agentmemory on macOS or ~/.local/share/agentmemory on Linux. One warning from the README: Claude Code deletes JSONL transcripts older than 30 days by default, so importing old history only recovers the last month. Hooks capture live sessions and avoid that problem.

From Python you can call the same functions through the iii SDK (pip install iii-sdk), as in the README:

1from iii import register_worker
2
3iii = register_worker("ws://localhost:49134")
4iii.connect()
5
6iii.trigger({
7    "function_id": "mem::smart-search",
8    "payload": {"project": "demo", "query": "how do tokens refresh"},
9})

agentmemory benchmark claims (self-reported)

All numbers below come from agentmemory’s own README and benchmark files. No outside group has published a check of them.

Test (agentmemory README)MetricagentmemoryBaseline in the same test
LongMemEval-S, 500 questionsRecall@5 (retrieval only)95.2% (BM25 + vector)86.2% (BM25 only)
LongMemEval-SRecall@10 / MRR98.6% / 88.2%94.6% / 71.5%
coding-agent-life-v1 (in-house, 15 sessions)Recall@5 / top-5 hit rate1.000 / 15 of 15grep: 0.967 / 15 of 15
Context injected vs a full CLAUDE.mdTokens at 240 observations~1,90022,000+ (“92% fewer tokens”)

How to read these:

  • 95.2% is not a LongMemEval accuracy score. The project’s LongMemEval notes say it plainly: these are “retrieval recall scores, not end-to-end QA accuracy,” with no LLM answering and no judge, and “We do NOT claim these as ‘LongMemEval scores’.” Recall@5 asks whether any correct session shows up in the top 5 results.
  • The coding benchmark is small. The README calls it “small and gold-sparse,” and plain grep also finds 15 of 15.
  • The token saving compares against loading a whole memory file, not against other memory servers.

The team publishes a harness to reproduce the runs (eval/ in the repo), which is a good sign. For how to test memory systems on your own data, see the LLM memory evaluation guide.

agentmemory vs Hindsight vs Mem0 for coding agents

All three can give Claude Code, Codex or Cursor memory that lasts across sessions. They differ in how memory gets written, what runs where, and what they measure.

agentmemoryHindsightMem0
LicenseApache 2.0MIT, full server includedApache 2.0 (hosted Platform has extra features)
Main designLocal server built for coding agentsGeneral memory server with coding-agent pluginsMemory layer API, hosted or self-run
How memory is writtenHooks capture every tool call automaticallyLLM extracts facts, time, entities and relations on retainAgent or your code calls add; hosted MCP lets the agent decide
RetrievalBM25 + vector + graph, RRF fusionSemantic + BM25 + graph + temporal, RRF, cross-encoder rerankSemantic + BM25 + entity matching
Reasoning over memoryNoreflect, observations, mental modelsNo
LLM neededNo (keyless mode works)Yes, for retain and consolidationYes, for fact extraction
StorageLocal files (iii engine), or RedisPostgreSQL + pgvector, embedded optionVector store you choose, or Mem0 Platform
Coding agentsClaude Code, Codex, Cursor, Copilot CLI, Gemini CLI, Hermes, OpenClaw and moreClaude Code, Codex, Cursor, Copilot, opencode, Cline, Aider, Hermes, OpenClawHosted MCP for Claude Code, Codex, Cursor and others
Published benchmark95.2% Recall@5 on LongMemEval-S (retrieval only)94.6 LongMemEval, 92 LoCoMo, 73.9 BEAM 1M, 64.1 BEAM 10M (accuracy)94.4 LongMemEval, 92.5 LoCoMo, 64.1 BEAM 1M, 48.6 BEAM 10M (Platform)
Hosted optionNoHindsight Cloud, pay per useMem0 Platform

Sources: the agentmemory README, the Hindsight README, Mem0’s MCP docs, and Mem0’s Mem0 vs Hindsight page for the Hindsight and Mem0 scores. Every score is vendor-run. agentmemory’s figure measures retrieval, the other two measure answer accuracy, so don’t rank them on one scale.

Where agentmemory is strong: it is built only for coding agents. Capture is automatic, it runs fully local with no LLM key and no database, and setup is one npx command. If you want memory for Claude Code today at zero cost, it’s an easy start.

Where Hindsight fits

Hindsight is the stronger choice when the agent should learn from its history, not only find old sessions:

  • Long project histories. On the BEAM tests Hindsight scores 73.9 at 1M tokens and 64.1 at 10M, leading Mem0 by 9.8 and 15.5 points (from Mem0’s own comparison page). A coding agent used for months builds exactly this kind of history.
  • Learning, not just recall. Hindsight merges related facts into observations (evidence-backed beliefs that get refined, not overwritten) and keeps mental models up to date in the background. reflect reasons over many memories to answer questions like “why did we move off Redis?”
  • Native coding-agent plugins plus wide reach. Claude Code, Codex, Cursor, Copilot, opencode, Cline and Aider, plugins for Hermes and OpenClaw, an MCP server, and 60+ integrations in total.
  • Everything open source. Graph, temporal recall, consolidation, reflect and mental models are all in the MIT release, with 25+ LLM providers, including local ones.

Its costs: every retain and consolidation calls an LLM, so writes cost more than agentmemory’s keyless capture, and by Mem0’s measurements it returns more context per retrieval than Mem0 (set max_tokens lower). Hindsight’s benchmarks are vendor-reported, with results reproduced by research collaborators at Virginia Tech and The Washington Post. For the details, see Mem0 vs Hindsight.

How to choose:

If you…Pick
Want free, local memory for Claude Code or Codex with no LLM keyagentmemory
Want memory that consolidates lessons and reasons over months of workHindsight
Need the longest histories handled well (BEAM 1M and 10M)Hindsight
Want a hosted memory service with SOC 2 and HIPAAMem0 Platform
Want the smallest context per retrievalMem0

For how Claude Code, Codex and Cursor remember things without any of these tools, read AI coding agent memory. For memory exposed over MCP in general, see AI memory MCP servers.