Overview
agentmemory is a self-hosted memory server for AI coding agents. Coding assistants normally start each session with no idea what happened in the last one, so you re-explain the same architecture, conventions, and past decisions. agentmemory records what the agent actually does — prompts, tool calls, tool outputs, failures — through the agent's own lifecycle hooks, then injects the relevant parts back at the start of the next session within a token budget (2000 tokens by default).
Capture runs as a pipeline: a PostToolUse hook fires, the observation is SHA-256 deduplicated within a five-minute window, passed through a privacy filter that strips secrets and API keys, stored, compressed, and indexed in BM25 (plus vectors when an embedding provider is configured). At session end it summarizes, and can extract a knowledge graph. Memories are organised into four tiers modeled on human memory — working (raw observations), episodic (session summaries), semantic (extracted facts and patterns), and procedural (workflows and decision patterns) — and decay on an Ebbinghaus curve so frequently used memories strengthen while stale ones are evicted.
It runs locally with no external database: the server exposes a REST API and an MCP server on port 3111, an iii event stream on 3112, and a live viewer on 3113 where you can watch memory build and replay any recorded session event by event. It works with Claude Code, GitHub Copilot CLI, Cursor, Gemini CLI, Codex CLI, OpenCode and other MCP clients, wired up with agentmemory connect. It is written in TypeScript, licensed Apache 2.0, and built on the iii engine (pinned to v0.11.2).
What it does
- Automatic capture through agent lifecycle hooks — SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, PostToolUseFailure, PreCompact, subagent lifecycle, Stop and SessionEnd
- Four-tier consolidation (working, episodic, semantic, procedural) with Ebbinghaus-curve decay, contradiction detection, and auto-eviction of stale memories
- Hybrid retrieval fusing BM25 keyword search, vector similarity, and knowledge-graph matches
- MCP server plus a REST API, so any MCP client can read and write memory
- Privacy filter that strips secrets and API keys before storage, and SHA-256 deduplication over a five-minute window
- Live viewer with session replay: scrub prompts, tool calls, results and responses with play/pause and speed control
- Runs keyless with no external database; optional on-device embeddings via Xenova/all-MiniLM-L6-v2 for semantic recall
Getting started
agentmemory needs Node.js 20 or newer. The first run is an interactive setup that picks which agents to wire up, seeds the config, and starts the memory server and its pinned iii engine.
Start the server
This is the canonical fresh-install command. It walks you through choosing agents and an LLM provider (or staying keyless), then offers to install globally so the bare agentmemory command works afterwards.
npx -y @agentmemory/agentmemory@latestSeed sample data and watch recall work
The demo seeds three realistic sessions (JWT auth, an N+1 query fix, rate limiting) and runs searches against them. Then open the viewer to watch memory build live.
npx -y @agentmemory/agentmemory@latest demo
# then open http://localhost:3113Check the install is healthy
The runtime uses four ports: REST/MCP HTTP on 3111, iii streams on 3112, the viewer on 3113, and the iii worker WebSocket on 49134.
curl -fsS http://localhost:3111/agentmemory/livez
curl -fsS http://localhost:3111/agentmemory/health
npx -y @agentmemory/agentmemory@latest statusSave and search a memory over REST
Anything you store is searchable immediately, and survives a restart of the server.
curl -fsS -X POST http://localhost:3111/agentmemory/remember \
-H 'Content-Type: application/json' \
-d '{"content":"agentmemory restart persistence probe","concepts":["install-check"]}'
curl -fsS -X POST http://localhost:3111/agentmemory/smart-search \
-H 'Content-Type: application/json' \
-d '{"query":"restart persistence probe","limit":5}'Wire up more agents, and run it day to day
Adapters are available for Claude Code, Cursor, Codex CLI, Gemini CLI, GitHub Copilot CLI, OpenCode and others. doctor runs interactive diagnostics with fix prompts.
agentmemory connect <agent> # wire another agent
agentmemory # start the server
agentmemory stop # stop it cleanly
agentmemory doctor # interactive diagnostics
agentmemory remove # uninstall everything it createdTurn on local semantic recall (optional)
Keyless mode disables vector embeddings and searches through BM25 only. For free on-device semantic recall, set the embedding provider and restart; the first request downloads the model, after which inference is local.
echo 'EMBEDDING_PROVIDER=local' >> ~/.agentmemory/.env
agentmemory stop && agentmemoryCommands and code are distilled from the project's own documentation — always check the official repo for the latest.
When to use it
- Stop re-explaining a codebase's architecture and conventions to a coding agent at the start of every session
- Keep memory on your own machine when session transcripts contain code or context you can't send to a hosted memory service
- Share one memory layer across several agents — Claude Code, Cursor, Codex CLI, Copilot CLI — instead of each keeping its own
- Replay a past agent session event by event to work out what it did and why
- Import existing Claude Code JSONL transcripts so older sessions become searchable memory
How agentmemory compares
agentmemory alongside other open-source agent memory tools AI/TLDR tracks, ranked by GitHub stars.
| Tool | Stars | What it does |
|---|---|---|
| Claude-Mem | ★ 93.6k | Persistent memory layer for coding agents: it captures what an agent does during a session, compresses it into semantic summaries, and injects the relevant parts back into later sessions. |
| Mem0 | ★ 65.1k | A memory layer that you add to existing LLM agents to extract, store, and recall user facts and preferences across sessions using vector, graph, and key-value backends. |
| MemPalace | ★ 59k | Local-first agent memory that stores conversations verbatim instead of summarising them, with a structured palace index, pluggable vector backends and an MCP server. |
| OpenViking | ★ 36.5k | A context database that stores an agent's memories, resources, and skills as one browsable viking:// filesystem with three-tier (abstract/overview/details) on-demand loading. |
| Graphiti | ★ 30.8k | A library that builds a temporal knowledge graph from an agent's conversations and data so facts can be tracked and queried as they change over time. |
| Cognee | ★ 30.6k | A graph-native memory engine that turns raw documents and conversations into a queryable knowledge graph for agents that need to build lasting knowledge. |
| Supermemory | ★ 29.6k | A memory and context engine that ingests information across tools and sessions and can run fully locally, acting as a second brain for AI applications. |
| agentmemory | ★ 28.3k | A local memory server that lets coding agents remember past sessions |