Key points
- The problem: Mainstream AI coding assistants (Claude Code, Cursor, Copilot CLI, Codex) only have session-level memory. Vendor stopgaps like Claude Code's MEMORY.md (200-line limit, manually maintained), Cursor notepads, and Cline's memory bank suffer from capacity limits, no search, manual upkeep, and no cross-agent sharing. As creator Rohit Gupta puts it: "You explain the same architecture every session. You re-discover the same bugs. You re-teach the same preferences."
- What agentmemory is: A memory engine + MCP server running locally in the background (default
127.0.0.1:3111). It automatically captures every tool call, conversation, and code change via hooks, compresses them into searchable structured memory, and injects relevant context when a new session starts. Its pitch: "Built-in memory works like sticky notes. agentmemory is the searchable database behind the sticky notes." It integrates with 16+ tools (Claude Code, Codex CLI, GitHub Copilot CLI, Cursor, Gemini CLI, OpenClaw, Hermes, OpenCode, Cline/Roo/Kilo Code, Windsurf, Goose, Aider, Claude Desktop, Warp, pi) — one shared memory server means decisions made in Claude Code are visible in Cursor. - BM25: stemming, keyword matching, synonym expansion — precise, fast, no model needed
- Vector: dense embeddings for semantic search
- Graph: knowledge-graph entity matching + BFS traversal for relational reasoning
- Fused with Reciprocal Rank Fusion (k=60) plus per-session diversification (max 3 results per session)
- Project: agentmemory, author Rohit Gupta
- GitHub: https://github.com/rohitg00/agentmemory
- Install:
npm install -g @agentmemory/agentmemory; MCP:npx -y @agentmemory/mcp - Engine: iii engine (https://iii.dev)
- License: see LICENSE in the GitHub repository
Four-layer memory architecture (modeled on the human brain)
| Layer | Content | Implementation | |---|---|---| | Working memory | Raw observations (tool call inputs/outputs) | SQLite raw storage, 5-min dedup window | | Episodic memory | Session summaries | LLM-compressed narratives | | Semantic memory | Extracted facts and patterns | Structured facts + concept extraction | | Procedural memory | Workflows and decision habits | Pattern detection + workflow logging |
Lifecycle: PostToolUse hook → SHA-256 dedup → privacy filtering (API keys/secrets stripped) → raw storage → LLM compression → vector embedding (6 providers + local) → BM25 + vector indexing. SessionEnd generates summaries and knowledge-graph extraction; SessionStart loads a project profile and performs hybrid search under a token budget (default 2000 tokens).
Memory decay follows an Ebbinghaus-style forgetting curve: frequently accessed memories are reinforced, stale ones expire (TTL + importance-based eviction), and contradictory memories are detected and resolved. This solves the "unbounded growth" problem of static MEMORY.md files.
Three-stream hybrid retrieval
Benchmark (LongMemEval-S): agentmemory scores R@5 95.2%, R@10 98.6%, MRR 88.2%, versus 86.2% / 94.6% / 71.5% for its BM25-only fallback. Comparison figures for mem0 (68.5%), Letta/MemGPT (83.2%), and MemPalace (~96.6%) come from their own papers/self-reports on different benchmarks, not direct comparisons. Relative to BM25-only, the three-stream fusion adds +9pp R@5 and +16.7pp MRR.
Token economics: pasting full context is ~19.5M+ tokens/year (impossible, exceeds window); LLM summarization is ~650K (~$500); agentmemory is ~170K tokens/year (~$10, $0 with local embeddings) — a ~92% saving from precise retrieval.
Zero-friction capture via 12 hooks
Hooks (SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, PostToolUseFailure, PreCompact, SubagentStart/Stop, Stop, SessionEnd) capture observations automatically — unlike mem0, which requires manual add() calls. Developers just code normally; memory accumulates in the background.
Technical foundation: the iii engine
agentmemory avoids Postgres/Redis/Express/pm2, replacing them with the unified iii runtime: SQLite + iii-state KV, iii-stream WebSocket, iii function routing, iii process management, and iii-observability OTEL traces. The built-in viewer (port 3113) exposes every memory operation as an OTEL trace with editable KV entries and replayable triggers. Self-hosted by default; deployable to Fly.io/Railway/Render/Coolify.
53 MCP tools
Core always-available tools: memory_recall, memory_smart_search, memory_save, memory_sessions, memory_profile, memory_file_history. Extended set covers consolidation, team sharing (team_share, team_feed), multi-agent coordination (lease, signal_send, mesh_sync), workflows, auditing, and health (diagnose, heal) — versus 5–10 tools typical of other memory MCPs.
Privacy and limitations
Privacy: local-first (bound to 127.0.0.1), automatic secret stripping, SHA-256 dedup, optional HMAC auth for remote deployment, full audit trail.
Limitations noted in the post: dependency on the iii engine binary (weak Windows support); some hooks are Claude Code-specific; inaccurate retrieval can pollute context and cause hallucinations; long-running projects may grow the store despite TTL; team permission models (shared + private namespaced memory) need careful configuration.
Example workflow
Session 1: "Add auth to the API" — the agent codes, tests, fixes bugs; agentmemory silently captures everything. Session 2: "Now add rate limiting" — the agent automatically receives context like "Auth uses JWT middleware in src/middleware/auth.ts" and "you chose jose over jsonwebtoken for Edge compatibility" — no re-explaining needed.
Closing takeaway
agentmemory upgrades AI coding assistant memory from "static sticky notes" to "a dynamic database": automatic capture, intelligent compression, precise retrieval, natural forgetting. Its value lies not in any single technique but in combining them into a zero-friction, self-hosted, cross-agent system. The author's final observation: as frontier models converge on raw coding capability, competition is shifting to context management — whoever retrieves relevant cross-session memory most precisely wins.