AgentMemory: The #1 Persistent Memory System for AI Coding Agents — 22,000 Stars for Real-World Benchmarks — A Practical Guide 2026
AgentMemory (22,038 GitHub stars) provides persistent memory for AI coding agents based on real-world benchmarks. Remember past sessions, maintain context across days, learn from previous interactions. Works with Claude Code, Codex CLI, OpenCode, and more. Includes setup tutorial, architecture breakdown, and benchmarks.
- ⭐ 3000
- Updated 2026-06-08
Persistent Memory for AI Coding Agents in 2026 • AI Agent Memory Systems 2026
┌──────────────────────────────────────────────────────┐
│ AgentMemory Architecture │
│ │
│ ┌────────────┐ ┌────────────┐ ┌──────────────┐ │
│ │ Session 1 │ │ Session 2 │ │ Session N │ │
│ │ (Claude) │ │ (Codex) │ │ (OpenCode) │ │
│ └─────┬──────┘ └─────┬──────┘ └──────┬───────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌───────────────────────────────────────────────┐ │
│ │ Memory Storage Layer │ │
│ │ • Vector DB (embeddings) │ │
│ │ • Graph DB (relationships) │ │
│ │ • Key-value (facts, decisions) │ │
│ └───────────────────────┬───────────────────────┘ │
│ │ Query & Retrieve │
│ ┌───────────────────────▼───────────────────────┐ │
│ │ Agent Gets Context from Memory │ │
│ │ "Last time you fixed the auth bug..." │ │
│ └───────────────────────────────────────────────┘ │
└──────────────────────────────────────────────────────┘
AgentMemory: sessions → memory storage → context-aware agent
Introduction #
AI coding agents forget everything between sessions. You fix a bug on Tuesday, come back Wednesday, and the agent asks you to explain the codebase again — from scratch. AgentMemory (22,038 GitHub stars) solves this by giving AI coding agents persistent memory: it remembers past sessions, key decisions, bug fixes, and architectural patterns across days, weeks, or months. Benchmarked on real-world development workflows, it improves agent accuracy by 34% and reduces onboarding time by 60%. Works with Claude Code, Codex CLI, OpenCode, and any agent that supports tool calling.
What Is AgentMemory? #
AgentMemory is a persistent memory system for AI coding agents that enables agents to remember and retrieve information across sessions. It uses a combination of vector embeddings, knowledge graphs, and structured fact storage to create a searchable memory that agents can query at the start of each session.
Key capabilities:
- Cross-session memory — Remember what happened in previous sessions, days, or weeks
- Multi-agent support — Share memory across Claude Code, Codex, OpenCode, and more
- Structured facts — Store decisions, bug fixes, architecture patterns as structured data
- Semantic search — Find relevant past context using embedding-based retrieval
- Automatic extraction — Extract and store important facts without manual configuration
- Real-world benchmarks — Tested on 500+ real development sessions
Built with Python, uses ChromaDB for vector storage, networkx for graph operations, and SQLite for structured data.
How AgentMemory Works #
AgentMemory (22,063 GitHub stars) operates as an MCP server that provides persistent memory for AI coding agents. It enables agents to remember and retrieve information across sessions through a combination of vector embeddings, knowledge graphs, and structured fact storage.
Stage 1: MCP Server Setup #
# Install AgentMemory globally
npm install -g @agentmemory/agentmemory
Stage 2: Memory Extraction #
Memory is extracted from agent sessions through the MCP protocol. Agents query the memory server to store and retrieve facts about code decisions, bug fixes, and architectural patterns. The system processes tool calls, code changes, and conversation context automatically.
Key extraction types include:
- Decisions — Architecture choices, library selections, design patterns
- Fixes — Bug fixes applied, root causes, solutions implemented
- Patterns — Coding patterns, conventions, style choices used
- Config — Build configurations, environment settings, dependencies
Stage 3: Memory Retrieval #
When a new session starts, the agent queries the MCP server for relevant past context. Results are ranked by relevance using vector similarity search, returning structured memory entries that help the agent continue where it left off.
Deploy AgentMemory: The #1 Persistent Memory System for AI Coding Agents on DigitalOceanInstallation & Setup #
Install via npm #
# Install the MCP server globally
npm install -g @agentmemory/agentmemory
# Verify installation
npm list -g @agentmemory/agentmemory
Configure Agent Integration #
AgentMemory works through the MCP protocol, which is supported by Claude Code, Codex CLI, OpenCode, Gemini CLI, and other agents. Configure the MCP endpoint in your agent settings to point to the running AgentMemory server.
Memory Storage Options #
AgentMemory supports multiple storage backends out of the box:
- ChromaDB — Default local vector store, zero configuration required
- Qdrant — Distributed vector store for production deployments
- Weaviate — Cloud-native vector search with GPU acceleration
- SQLite — Lightweight embedded database for simple setups
- PostgreSQL — Production relational database with pgvector extension
- Neo4j — Graph database for complex relationship modeling
Storage Backend Configuration #
Select a storage backend by setting the environment variable before starting the AgentMemory server:
# Use Qdrant as vector store
export AGENTMEMORY_VECTOR_STORE=qdrant
export QDRANT_HOST=localhost
export QDRANT_PORT=6333
# Use Weaviate
export AGENTMEMORY_VECTOR_STORE=weaviate
export WEAVIATE_URL=http://localhost:8080
# Use Neo4j for graph-based memory
export AGENTMEMORY_GRAPH_STORE=neo4j
export NEO4J_URI=bolt://localhost:7687
export NEO4J_USER=neo4j
export NEO4J_PASSWORD=your_password
MCP Protocol Details #
AgentMemory implements the Model Context Protocol (MCP), which standardizes how AI agents interact with external tools and data sources. The MCP server exposes memory operations — store, retrieve, search, and delete — through a unified interface that any MCP-compatible agent can use.
# Start the AgentMemory MCP server
agentmemory start --port 8080
# Connect from an MCP client
agentmemory connect --endpoint http://localhost:8080
# Check server health and connected agents
agentmemory status
Memory Fact Schema #
Each memory fact has a structured schema with metadata:
{
"fact_id": "f7a3b2c1",
"type": "decision",
"category": "architecture",
"content": "Used FastAPI instead of Flask for the API layer",
"source_session": "session_2024_03_15",
"confidence": 0.95,
"created_at": "2024-03-15T14:30:00Z",
"updated_at": "2024-03-15T14:30:00Z",
"tags": ["framework", "api", "decision"],
"related_facts": ["f8b4c3d2", "f9c5d4e3"]
}
Memory Query Examples #
Retrieve memory using natural language queries or structured filters:
# Natural language search
agentmemory search "what architecture decisions were made?"
# Structured filter by type
agentmemory search --type decision --category architecture
# Filter by time range
agentmemory search --since 2024-01-01 --until 2024-06-01
# Retrieve related facts for a specific ID
agentmemory get-related --fact-id f7a3b2c1 --max-depth 3
Memory Pruning Operations #
Manage memory growth with built-in pruning tools:
# Prune facts older than 90 days
agentmemory prune --older-than 90d
# Set automatic pruning threshold in config
echo 'cleanup_threshold_days: 90' >> ~/.agentmemory/config.yaml
# View memory statistics
agentmemory stats
# Output: 1,247 facts stored, 48MB disk usage, avg_confidence: 0.87
Local vs. Remote Deployment #
AgentMemory can run locally on your machine or be deployed remotely for team access. Local deployment stores all memory on your machine with no external connections. Remote deployment enables shared memory across multiple agents and developers.
Integration with Claude Code, Codex CLI, OpenCode, and Gemini CLI #
AgentMemory integrates with any AI coding agent that supports MCP protocol. The integration layer translates agent sessions into memory operations — extracting facts during sessions and retrieving relevant context at session start.
Supported agents include Claude Code, Codex CLI, OpenCode, Gemini CLI, Cursor, and any OpenAI-compatible tooling. Each agent connects as an MCP client to the AgentMemory server.
Configuring Claude Code for AgentMemory #
Set up AgentMemory as a persistent memory tool for Claude Code:
# Set up Claude Code to use AgentMemory MCP server
claude code --mcp-config ~/.claude/mcp-config.json
# MCP config file for AgentMemory
cat > ~/.claude/mcp-config.json << 'EOF'
{
"mcpServers": {
"agentmemory": {
"command": "agentmemory",
"args": ["start", "--port", "8080"],
"env": {
"MEMORY_PATH": "~/.agentmemory/data"
}
}
}
}
EOF
Configuring Codex CLI for AgentMemory #
# Set up Codex to connect to AgentMemory
codex config set memory.endpoint http://localhost:8080
codex config set memory.auto_extract true
# Verify connection
codex test memory
# Output: connected, 1247 facts loaded, retrieval_latency: 45ms
Multi-Session Memory Workflow #
Demonstrate how memory persists across sessions:
# Session 1: Start working on a project
agentmemory start --port 8080
# Agent extracts: "Project uses PostgreSQL with Prisma ORM"
# Session 2 (next day): Agent retrieves relevant context
agentmemory search "database setup"
# Returns: "In session 1, project uses PostgreSQL with Prisma ORM"
# Agent can continue without re-explaining the setup
# Session 3: Memory grows with new facts
agentmemory stats
# Output: 2,341 facts stored, 92MB disk usage
Export and Import Memory #
Transfer memory between machines or share with team members:
# Export memory as JSON
agentmemory export --format json --output /tmp/agentmemory-backup.json
# Export as SQLite dump
agentmemory export --format sqlite --output /tmp/agentmemory-backup.db
# Import from backup
agentmemory import --source /tmp/agentmemory-backup.json --target my-project
Custom Fact Extraction Rules #
Define custom extraction rules for domain-specific facts:
# ~/.agentmemory/rules.yaml
extraction_rules:
- name: security_fixes
pattern: ".*(fix|patch|resolve).*security.*"
type: fix
category: security
priority: high
- name: api_changes
pattern: ".*(change|update|migrate).*api.*"
type: decision
category: api
priority: medium
- name: performance_optimization
pattern: ".*(optimize|improve|speed).*performance.*"
type: decision
category: performance
priority: high
Memory Conflict Resolution #
When multiple agents record conflicting facts, AgentMemory uses confidence scoring:
# Detect conflicting facts
agentmemory conflicts --type decision --category framework
# Output:
# CONFLICT: framework selection
# fact_a: "Used React for frontend" (confidence: 0.92, session: 42)
# fact_b: "Used Vue for frontend" (confidence: 0.88, session: 55)
# Recommended: fact_a (higher confidence, more recent)
# Resolve manually
agentmemory resolve --keep fact_a --discard fact_b --reason "React was explicitly chosen"
For reliable hosting, deploy on WebShare DigitalOcean droplets for shared team memory, or HTStack for Asia-Pacific low-latency. For trading automation, connect to Binance or OKX APIs for real-time data feeds.
Benchmarks / Real-World Use Cases #
Cross-Session Memory Retention #
AgentMemory stores facts, decisions, and patterns from each session. Over time, the knowledge base grows, and agents become more productive as they retain more context. The system handles varying time gaps between sessions with high accuracy.
Memory accuracy over time:
- Same day — 96% accuracy (fresh memory still cached)
- 1 week — 91% accuracy (vector search retrieves relevant context)
- 1 month — 84% accuracy (semantic search maintains relevance)
- 3 months — 72% accuracy (long-tail facts still retrievable)
- 6 months — 61% accuracy (older facts may need pruning)
Team Development Scenario #
In a team setting, AgentMemory enables knowledge sharing without explicit handoffs. When Developer A fixes a bug and documents the root cause, Developer B can pick up the same task with full context from the memory system.
Multi-Agent Memory Sharing #
Multiple agents can share the same memory store. This is useful for teams running parallel development efforts or for personal workflows using different tools across sessions.
Advanced Usage / Production Hardening #
Storage Backend Selection #
Choosing the right storage backend depends on your scale and requirements:
- Start with ChromaDB for local development — it requires no external services
- Move to Qdrant when you need distributed vector search across team members
- Use Neo4j when graph relationships between facts matter most
- Use SQLite for minimal overhead on small projects
Privacy and Data Control #
All memory data stays on your machine by default. No data is sent to external services. The project is open-source (MIT license), allowing you to audit the extraction logic and ensure no sensitive code or credentials are stored.
Memory Pruning #
Over time, you may want to prune older facts to reduce storage and improve retrieval quality. Set a pruning threshold to automatically remove facts older than a specified number of days. This keeps the memory store lean and focused on recent, relevant context.
Comparison with Alternatives #
| Feature | AgentMemory | Cursor Memories | GitHub Copilot Chat | Custom RAG | |
💬 Discussion