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.

  • ⭐ 22038
  • Updated 2026-06-08

AgentMemory: The #1 Persistent Memory System for AI Coding Agents — 22,000 Stars for Real-World Benchmarks — A Practical Guide 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.

Installation & 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 #

FeatureAgentMemoryCursor MemoriesGitHub Copilot ChatCustom RAG
Persistent memoryYesYes (local only)NoYes
Cross-sessionYesNoNoYes
Multi-agent6+ agentsCursor onlyCopilot onlyCustom
Structured factsYesNoNoYes
Graph relationshipsYesNoNoYes
Real-world benchmarksYesNoNoNo
Open sourceYes (MIT)NoNoYes
Self-hostedYesYesNoYes
GitHub stars22,038

Limitations / Honest Assessment #

AgentMemory is not for everyone:

  1. Small solo projects — If you’re the only developer and work in single sessions, memory provides limited value. The agent is fast enough to handle small codebases without memory.
  2. Privacy-sensitive code — Memory stores code patterns and decisions locally. For enterprise codebases, you need to audit what facts are extracted and stored.
  3. Cold start period — Memory takes time to build. A new project starts with empty memory and needs 10-20 sessions before the system becomes useful.
  4. Memory drift — Over time, outdated facts can confuse agents. Regular pruning keeps the store clean and relevant.
  5. Vector DB complexity — For production deployments with multiple agents, managing ChromaDB/Qdrant/Neo4j adds operational overhead.

Set a monthly pruning schedule to remove facts older than 90 days. This keeps the memory store focused and prevents stale information from polluting retrieval results. The pruning threshold can be configured in your agent settings.

Backup and Recovery #

Regularly back up your memory store to avoid losing accumulated knowledge. Store backups in version control or cloud storage for easy recovery across machines.

Performance Considerations #

Memory retrieval speed depends on your storage backend. ChromaDB offers fast local queries under 100ms for typical workloads. For larger knowledge bases with thousands of facts, Qdrant or Weaviate provide better scaling characteristics.

Monitoring Memory Health #

Monitor your memory store for health metrics and potential issues:

# Check memory store health
agentmemory health
# Output: OK, 1247 facts, 48MB, last_pruned: 2024-06-01

# View top retrieval queries for optimization
agentmemory analytics --queries --top 10
# Output:
# 1. "authentication flow" - 342 queries
# 2. "database migration" - 218 queries
# 3. "error handling patterns" - 156 queries

# Check for orphaned facts with no references
agentmemory orphan-check --threshold 0.3
# Output: 23 orphaned facts found (confidence < 0.3)

Frequently Asked Questions #

Q: Is AgentMemory privacy-safe?

A: Yes. All memory is stored locally by default. No data leaves your machine unless you configure remote sync. You control what facts are extracted and stored. The project is open-source (MIT), so you can audit the extraction logic.

Q: How much storage does memory use?

A: Typical usage: 5-50MB for a medium project (10K-100K lines) with 50-200 sessions. Memory grows roughly 100-500KB per session depending on complexity.

Q: Can AgentMemory work with local LLMs?

A: Yes. AgentMemory is agent-agnostic and works with any agent that supports tool calling, including agents using local LLMs like Ollama.

Q: How do I clean up old memory?

A: Use agentmemory prune --older-than 90d to remove facts older than 90 days. You can also set automatic pruning in config: cleanup_threshold_days: 90.

Q: Does it work for non-coding tasks?

A: While designed for coding agents, the memory system is general-purpose. You can use it with any agent workflow — data science, research, automation — by defining custom fact types.

Sources & Further Reading #

Conclusion: Give Your AI Agent a Memory — Stop Repeating Yourself #

AgentMemory is the missing piece that turns AI coding agents from one-session tools into lifelong collaborators. By remembering past decisions, bug fixes, and patterns, your agent gets smarter and more accurate with every interaction. The benchmarks are real: 53% accuracy improvement, 60% faster onboarding, and 70% fewer repeating mistakes.

Whether you’re a solo developer who returns to projects weekly, a team sharing code context, or building a production AI workflow, AgentMemory provides the foundation for agents that actually remember.

Join the dibi8 English Telegram group to discuss AgentMemory configurations. Check out our guides on [AI Agent工作平台](https://dibi8.com/paperclip-open-source[Token压缩](https://dibi8.com/headroom-token-compression-proxy-library-mcp-server) 本地ChatGPT for complementary AI tooling. Try AgentMemory today — install it, let it learn from a few sessions, and watch your agent get smarter over time.

Some links above are affiliate links. dibi8.com may earn a commission if you sign up, at no extra cost to you. Helps keep the site running and the content free.

💬 Discussion