Overview
AgentMemory is a persistent memory system specifically designed for AI coding agents. With over 9,400 stars and ranked #1 in persistent memory benchmarks, it provides long-term memory capabilities that enable agents to remember context across sessions, learn from interactions, and build cumulative knowledge.
Features
- ✓Cross-session persistent memory
- ✓Vector storage with semantic search
- ✓Hierarchical memory organization
- ✓Time-aware retrieval
- ✓Multiple backend support (SQLite, PostgreSQL, Redis, Chroma, Qdrant)
Installation
pip install agent-memoryPros
- +#1 performance on memory benchmarks
- +Multiple backend options for different needs
- +Framework agnostic - works with any agent
- +Production-ready with real-world validation
- +Clear documentation and examples
Cons
- −Additional dependency to manage
- −Multiple backend options can be confusing
- −Vector databases can add infrastructure cost
- −Memory retrieval adds latency to responses
Alternatives
Documentation
AgentMemory
Overview
AgentMemory is a persistent memory system specifically designed for AI coding agents. With over 9,400 stars and ranked #1 in persistent memory benchmarks, it provides long-term memory capabilities that enable agents to remember context across sessions, learn from interactions, and build cumulative knowledge.
Key Features
🧠 Persistent Memory
AgentMemory provides true persistent memory for AI agents:
- Cross-Session Persistence: Memory survives agent restarts
- Vector Storage: Semantic search across all memories
- Hierarchical Organization: Organize memories by context and topic
- Time-Aware Retrieval: Consider temporal context in memory retrieval
📊 Benchmark-Backed
Validated against real-world benchmarks:
- #1 in Memory Benchmarks: Outperforms competitors on standard tests
- Real-World Testing: Validated on actual coding agent workloads
- Performance Metrics: Measured retrieval accuracy and latency
- Scalability Testing: Tested with thousands of memory entries
🔗 Agent Integration
Seamless integration with popular agent frameworks:
from agent_memory import MemoryStore
# Initialize memory store
memory = MemoryStore(
backend="sqlite", # or "postgres", "redis", "chroma"
embedding_model="text-embedding-3-small"
)
# Store memory
memory.store(
content="The user prefers TypeScript over Python for new projects",
context="project_preferences",
metadata={"user_id": "user123"}
)
# Retrieve relevant memories
relevant = memory.retrieve(
query="What language should I use for the new API?",
top_k=5
)
📈 Memory Operations
Complete CRUD operations for memories:
# Create
memory.store("New memory content", context="general")
# Read
memories = memory.retrieve("search query", top_k=10)
# Update
memory.update(memory_id, "Updated content")
# Delete
memory.delete(memory_id)
# Search
results = memory.search("semantic search query")
# List
all_memories = memory.list(context="project_preferences")
Installation
pip install agent-memory
Supported Backends
| Backend | Use Case | Persistence | Performance |
|---|---|---|---|
| SQLite | Local development, small scale | ✅ Yes | Fast |
| PostgreSQL | Production, large scale | ✅ Yes | Very Fast |
| Redis | Caching, fast access | ⚠️ Volatile | Fastest |
| Chroma | Vector-first workloads | ✅ Yes | Fast |
| Qdrant | Enterprise vector search | ✅ Yes | Very Fast |
Integration Examples
Claude Code Integration
from agent_memory import ClaudeMemoryPlugin
# Add to Claude Code
memory_plugin = ClaudeMemoryPlugin(
store=MemoryStore(backend="postgres"),
auto_save=True,
auto_retrieve=True
)
# Memory is automatically managed
# Agent remembers context across sessions
Cursor Integration
from agent_memory import CursorMemoryPlugin
memory_plugin = CursorMemoryPlugin(
workspace_path="./my-project",
auto_index=True
)
# Memory indexed from workspace files
Custom Agent Integration
from agent_memory import MemoryStore
from openai import OpenAI
class MemoryEnhancedAgent:
def __init__(self):
self.memory = MemoryStore(backend="chroma")
self.client = OpenAI()
async def chat(self, message: str, user_id: str) -> str:
# Retrieve relevant memories
memories = self.memory.retrieve(
query=message,
top_k=5,
filter={"user_id": user_id}
)
# Build context
context = "\n".join([m.content for m in memories])
# Generate response with memory context
response = self.client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "system", "content": f"Relevant memories:\n{context}"},
{"role": "user", "content": message}
]
)
# Store new memory
self.memory.store(
content=f"User asked: {message}\nAgent responded: {response}",
context="conversation",
metadata={"user_id": user_id}
)
return response.choices[0].message.content
Advanced Patterns
Memory Summarization
# Auto-summarize long conversations
memory.summarize(
context="conversation",
filter={"session_id": "session123"},
summary_key="session_summary"
)
Memory Compression
# Compress old memories to save space
memory.compress(
older_than="30 days",
strategy="summarize" # or "embed"
)
Multi-Tenant Memory
# Separate memories by user/project
memory.store("Content", context="general", metadata={"tenant": "user123"})
memory.store("Content", context="general", metadata={"tenant": "user456"})
# Retrieve with tenant filter
memories = memory.retrieve("query", filter={"tenant": "user123"})
Memory Export/Import
# Export memories
export = memory.export(format="json") # or "csv", "parquet"
# Import memories
memory.import_data(export, format="json")
Pros
- ✅ Benchmark #1: Top performance on memory benchmarks
- ✅ Multiple Backends: Choose the right storage for your needs
- ✅ Framework Agnostic: Works with any agent framework
- ✅ Production Ready: Used in production by many teams
- ✅ Well-Documented: Clear documentation and examples
- ✅ Active Development: Rapidly improving with community feedback
Cons
- ❌ Additional Dependency: One more component to manage
- ❌ Setup Complexity: Multiple backend options can be confusing
- ❌ Cost: Vector databases can add infrastructure cost
- ❌ Latency: Memory retrieval adds some latency to agent responses
Use Cases
| Use Case | Why AgentMemory |
|---|---|
| Coding Agents | Remember codebase context across sessions |
| Multi-tenant Systems | Isolate memories by user or project |
| Long-term Projects | Build cumulative knowledge over time |
| Benchmark Validation | Use proven memory performance |
| Flexible Storage | Choose backend for your needs |
Comparison with Alternatives
| Feature | AgentMemory | Mem0 | Zep | LangChain Memory |
|---|---|---|---|---|
| Paradigm | Persistent storage | Self-improving | Entity extraction | Conversation buffer |
| Vector Search | ✅ Yes | ✅ Yes | ✅ Yes | ⚠️ Via plugins |
| Multi-Tenant | ✅ Yes | ✅ Yes | ⚠️ Via session_id | ❌ No |
| Benchmarks | ✅ #1 | ⚠️ Limited | ⚠️ Limited | ❌ No |
| Backend Options | ✅ 5 options | ⚠️ Cloud only | ⚠️ Limited | ⚠️ Limited |
| Framework Support | Universal | Universal | Universal | LangChain only |
| Learning Curve | Medium | Low | Medium | Low |
| Best for | Coding agents | Personalization | Structured memory | Simple conversations |
Best Practices
- Choose backend wisely — SQLite for dev, Postgres for production
- Use context tags — Organize memories by topic and project
- Set top_k appropriately — Balance relevance vs. context window
- Implement summarization — Compress old memories to save space
- Use multi-tenant isolation — Separate memories by user/project
- Backup regularly — Export memories for disaster recovery
Troubleshooting
| Issue | Solution |
|---|---|
| Memories not retrieved | Check embedding model matches stored memories |
| Slow retrieval | Use SQLite for small scale, Postgres for large |
| Memory conflicts | Use update instead of store for existing memories |
| Backend connection fails | Verify database credentials and network |
| Embedding errors | Check embedding model is available and loaded |
Resources
- GitHub: https://github.com/rohitg00/agentmemory
- Documentation: https://agentmemory.dev/
- Benchmarks: https://github.com/rohitg00/agentmemory#benchmarks
- Examples: https://github.com/rohitg00/agentmemory/tree/main/examples
Comparison
| Feature | AgentMemory | LangChain Memory | Custom SQLite |
|---|---|---|---|
| Persistence | ✅ Yes | ⚠️ Limited | ✅ Yes |
| Vector Search | ✅ Yes | ⚠️ Via plugins | ❌ No |
| Multi-Tenant | ✅ Yes | ❌ No | ⚠️ Manual |
| Benchmarks | ✅ #1 | ❌ No | ❌ No |
| Framework Support | Universal | LangChain only | Universal |
| Ease of Use | Medium | Easy | Hard |
Last updated: May 2026
