AI Card Bao API.AICARDBAO.COM
Home / 开源 / agentmemory
AI TOOL / #12992

agentmemory

An AI coding agent with persistent memory engine, based on real-world benchmark evaluations and inspired by the concepts in the Karpathy LLM Wiki.

Introduction

Persistent memory across coding sessions and agents.

Persistent memory for Claude Code, GitHub Copilot CLI, Cursor, Gemini CLI, Codex CLI, Hermes, OpenClaw, pi, Oh My Pi, OpenCode, DeepSeek Harness, and any MCP client.

🇬🇧 English • 🇨🇳 简体中文 • 🇹🇼 繁體中文 • 🇯🇵 日本語 • 🇰🇷 한국어 • 🇵🇹 Português • 🇧🇷 Português (Brasil) • 🇪🇸 Español • 🇩🇪 Deutsch • 🇫🇷 Français • 🇮🇹 Italiano • 🇳🇱 Nederlands • 🇵🇱 Polski • 🇨🇿 Čeština • 🇷🇴 Română • 🇭🇺 Magyar • 🇬🇷 Ελληνικά • 🇸🇪 Svenska • 🇩🇰 Dansk • 🇳🇴 Norsk • 🇫🇮 Suomi • 🇷🇺 Русский • 🇺🇦 Українська • 🇹🇷 Türkçe • 🇮🇱 עברית • 🇸🇦 العربية • 🇮🇳 हिन्दी • 🇧🇩 বাংলা • 🇵🇰 اردو • 🇹🇭 ไทย • 🇻🇳 Tiếng Việt • 🇮🇩 Bahasa Indonesia • 🇵🇭 Tagalog

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

Install • Quick Start • Benchmarks • vs Competitors • Agents • Architecture • How It Works • MCP • Viewer • Config • API


AgentMemory captures coding sessions, makes decisions and fixes searchable, and lets your agents recall them later. Keep one memory store across tools, inspect what was saved, and choose how much context reaches the model.

  • Capture: native hooks and plugins record supported session events, with secret scrubbing and offline replay.
  • Recall: keyword search works without an API key; local or remote embeddings add semantic search.
  • Continue: retrieve project history, lessons and session handoffs from another agent.
  • Inspect: browse, edit, export and forget memories in the live viewer.

Install

Requirements:

  • Node.js 20 or newer with npm and npx (node -v, npm -v, and npx -v).
  • macOS/Linux also need curl, a POSIX sh, and tar for automatic runtime setup.
  • Windows users can use WSL2 or follow the native Windows setup.

Start setup:

npx -y @agentmemory/agentmemory@latest

Choose your agents and either a provider or keyless mode. Setup writes the configuration, starts the memory server, and offers a global install for the agentmemory command. -y accepts the npm package prompt; @latest selects the current release. LLM-written observation compression is opt-in with a provider and AGENTMEMORY_AUTO_COMPRESS=true.

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 API is at http://localhost:3111 and the live viewer at http://localhost:3113. Both bind to loopback by default. Configuration lives in ~/.agentmemory/.env; see data storage for memory locations and separate instances.

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

Connect another agent with agentmemory connect . See supported integrations and everyday commands.

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).


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

Claude Code

native plugin + 12 hooks + MCP

Codex CLI

native plugin + 6 hooks + MCP

GitHub Copilot CLI

MCP + plugin hooks/skills

Cursor

native plugin + lifecycle hooks + MCP

OpenCode

capture plugin + MCP

Devin

6 hooks + skills + MCP

OpenClaw

native plugin + MCP

Hermes

native plugin + MCP

pi

native recall + capture + skills

OpenHuman

native Memory trait backend

Gemini CLI

MCP server

Antigravity

MCP + hooks

Claude Desktop

MCP server

Warp

connect + MCP + skills

Zed

MCP server

Cline

MCP server

Continue

MCP server

Droid

MCP server

Kiro

MCP server

Qwen Code

MCP server

DeepSeek Harness

native capture + MCP

Roo Code

MCP server

Kilo Code

MCP server

Goose

MCP server

Aider

REST API

Oh My Pi

native recall + capture + skills + optional MCP

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


Architecture

One local server sits between your agents and your memory. Each lane runs locally by default; the dashed line marks what you opt into.

Every tool call goes through the write path; every new session reads back through hybrid search within a token budget.


Data storage

Memories stay outside your repository by default:

PlatformData directory
macOS~/Library/Application Support/agentmemory
Linux$XDG_DATA_HOME/agentmemory or ~/.local/share/agentmemory
Windows%APPDATA%\agentmemory

An existing ./data/state_store.db is reused for instance 0. Choose another directory with `--data-dir

or AGENTMEMORY_DATA_DIR`. Keep the same directory when restarting or upgrading.

agentmemory --data-dir ~/.agentmemory-projects/main
agentmemory --instance 1

--instance 1 uses an instance-1 subdirectory, API port 3211 and viewer port 3213. See storage and backups for Redis and backend migration.

Latest release notes: CHANGELOG.md.


What's new in 0.9.34

  • Search sees every memory: flow-compressed memories are indexed, superseded ones leave the index, and failed index sessions retry.
  • Safer deletes: governance delete, evict, auto-forget and retention deletes hold the remember lock, and auto-forget stays within one project and agent.
  • Long sessions keep capturing: the session cap evicts the lowest-value observations instead of refusing writes.
  • Capture survives a restart: a stop or restart no longer drops queued observations, and the Agent SDK fallback never overrides a provider key you set.
  • Compression accepts real code: shell and generic syntax such as 2>&1 and Vec no longer fails to parse.
  • Orca plugin and native Windows connect: a memory panel for Orca, and agentmemory connect on Windows.

Release notes and contributor credits.

Useful recall without a model API. On LongMemEval-S, AgentMemory's keyless BM25 component found at least one relevant source for 96.2% of answerable questions and every required source for 84.7%.

LongMemEval-S, top 5 distinct sessionsAgentMemory BM25Lexical baseline
Every required source found (strict recall-all@5)84.7%72.1%
At least one relevant source found (any-hit@5)96.2%88.7%

That is 12.6 percentage points higher complete-source retrieval than the lexical baseline on the same inputs, with no embedding model or paid API. Measured on 2026-10-28: 500 questions per adapter, 470 answerable, 30 excluded from retrieval scoring, zero execution failures.

This component test measures retrieval from supplied sessions. Full-system answer quality, hybrid retrieval and competitor rankings require separate evaluations. Read the complete results, including the smaller coding fixture, limitations and reproduction steps.


AgentMemory is built for the coding workflow you already have. Capture supported agent activity automatically, share project history across tools, retrieve scoped memories, and inspect the original sources in a local viewer. Lessons, actions, versioned memories and import/export ship in the Apache-2.0 project; keyword recall needs no account or model API key.

Choose by workload and deployment. Other products also offer local deployment or agent plugins, so those alone are not useful differentiators.

ProjectBest starting point for
AgentMemoryShared local memory for existing coding agents, automatic capture, scoped recall and a live viewer
Mem0Memory APIs, hosted or self-hosted, with SDKs and agent plugins
SupermemoryMemory and document context through a hosted API or local server
Zep / GraphitiEnterprise context and temporal knowledge graphs
LettaBuilding stateful agents with their own managed memory
CogneeTurning documents, code and conversations into searchable knowledge
claude-memCapturing and summarizing coding sessions across supported agents

Detailed comparison and sources, checked 2026-10-28. Deployment options, provider costs and integrations vary; scores from different datasets and metrics are not a head-to-head ranking.


Try it in 30 seconds

# Terminal 1: start the server
npx -y @agentmemory/agentmemory@latest

# Terminal 2: seed sample data and see recall in action
npx -y @agentmemory/agentmemory@latest demo

demo seeds 3 realistic sessions (JWT auth, N+1 query fix, rate limiting) and runs searches against them. Keyless installs disable vectors, so the mem::search keyword queries should hit through BM25 while database performance optimization can return zero. smart-search may additionally return structural graph matches when graph data exists. To make the semantic query find the N+1 fix through vectors, set EMBEDDING_PROVIDER=local, restart, and allow the first model download to finish.

Open http://localhost:3113 to watch the memory build live.

Validate a fresh install and restart persistence

With the server running, check health, the viewer and status:

curl -fsS http://localhost:3111/agentmemory/livez
curl -fsS http://localhost:3111/agentmemory/health
curl -fsS -o /dev/null http://localhost:3113/
npx -y @agentmemory/agentmemory@latest status

status reports server health, provider and embedding mode, capture delivery, and recovery state. Save a probe and confirm it is searchable. Protected REST requests require the daemon secret. If you configured AGENTMEMORY_SECRET, use that value in this terminal; otherwise load the generated local secret:

read -r AGENTMEMORY_SECRET < "$HOME/.agentmemory/secret"
curl -fsS -X POST http://localhost:3111/agentmemory/remember \
  -H "Authorization: Bearer $AGENTMEMORY_SECRET" \
  -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 "Authorization: Bearer $AGENTMEMORY_SECRET" \
  -H 'Content-Type: application/json' \
  -d '{"query":"restart persistence probe","limit":5}'

Then run npx -y @agentmemory/agentmemory@latest stop, start the canonical command again in Terminal 1, wait for /agentmemory/livez, and repeat the search. The probe must still be returned. If you selected a custom --data-dir, pass the same directory on the restart.

Everyday commands

Install and setup live in Install above (the first run walks you through it). Day to day:

agentmemory                    # start the server
agentmemory stop               # stop it cleanly
agentmemory status             # health, providers and recovery state
agentmemory capture            # inspect capture inbox and offline spool
agentmemory capture --drain    # replay queued observations
agentmemory connect     # connect another agent
agentmemory doctor             # interactive diagnostics + fix prompts
agentmemory remove             # uninstall everything we created

Session Replay

Every session agentmemory records is replayable. Open the viewer, pick the Replay tab, and scrub through the timeline: prompts, tool calls, tool results, and responses render as discrete events with play/pause, speed control (0.5x to 4x), and keyboard shortcuts (space to toggle, arrows to step).

To bring in older Claude Code JSONL transcripts:

# Import everything under the default ~/.claude/projects
npx -y @agentmemory/agentmemory@latest import-jsonl

# Or import a single file
npx -y @agentmemory/agentmemory@latest import-jsonl ~/.claude/projects/-my-project/abc123.jsonl

Imported sessions appear alongside native sessions in Replay. Transcripts are indexed for search and marked with origin channel import; session processing can also produce crystals and lessons.

Heads-up if you rely on import-jsonl as your primary capture path: Claude Code's cleanupPeriodDays (in ~/.claude/settings.json, default 30) auto-deletes JSONL transcripts older than that window from ~/.claude/projects/. If you install agentmemory fresh on a months-old Claude Code history, anything older than 30 days is already gone before the first import. Either run import-jsonl on a cron, raise cleanupPeriodDays to something higher, or wire the auto-capture hooks (the default plugin install path) so each turn lands in agentmemory while the session is live and the JSONL cleanup stops mattering.

Upgrade / Maintenance

Use the maintenance command when you intentionally want to update your local runtime:

<
Visits:8 Updated:2026-12-03 AI tools

Related