Skip to content

AgentMem is a high-performance, enterprise-grade memory management platform for AI agents and LLM-powered applications. It provides persistent memory, intelligent semantic search, and AI-powered reasoning capabilities.

License

Notifications You must be signed in to change notification settings

louloulin/AgentMem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1,382 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

AgentMem

Enterprise-Grade AI Memory Platform for Production Applications

Rust License Build Status Coverage Version Discord

Documentation β€’ Examples β€’ Changelog β€’ Contributing


🎯 Overview

AgentMem is a high-performance, enterprise-grade memory management platform built in Rust, designed specifically for AI agents and LLM-powered applications. It provides persistent memory, intelligent semantic search, and enterprise-grade reliability with a modular plugin architecture.

Why AgentMem?

Modern LLM applications face critical limitations that AgentMem solves:

Problem AgentMem Solution
❌ No persistent memory βœ… Cross-session memory retention
❌ Context window limits βœ… Intelligent memory retrieval
❌ High API costs ($300K/month for 1M users) βœ… 90% cost reduction via selective retrieval
❌ Poor personalization βœ… User-specific memory scoping
❌ No enterprise features βœ… RBAC, audit logs, multi-tenancy

✨ Key Features

πŸš€ Performance

  • 216,000 ops/sec plugin throughput
  • <100ms semantic search latency (P95)
  • 93,000x cache acceleration ratio
  • 5,000 ops/s memory addition throughput
  • Asynchronous, lock-free architecture

🧠 Intelligent Memory

  • Automatic fact extraction powered by LLMs
  • 5 search engines: Vector, BM25, Full-Text, Fuzzy, Hybrid (RRF)
  • Conflict resolution for contradictory information
  • Memory importance scoring and decay
  • Graph-based reasoning with relationship traversal

πŸ”Œ Extensible Architecture

  • WASM plugin system with hot-reload capability
  • 18 modular crates for clear separation of concerns
  • 20+ LLM providers: OpenAI, Anthropic, DeepSeek, Google, Azure, and more
  • Multi-backend storage: LibSQL, PostgreSQL, Pinecone, LanceDB, Qdrant
  • Language bindings: Python, JavaScript, Go, Cangjie

πŸ›‘οΈ Enterprise-Grade

  • RBAC (Role-Based Access Control) with fine-grained permissions
  • JWT & Session authentication
  • Comprehensive audit logging
  • Full observability: Prometheus, OpenTelemetry, Grafana
  • Multi-modal support: Text, images, audio, video
  • Kubernetes-ready with Helm charts
  • 99.9% uptime SLA capability

πŸš€ Quick Start

Installation

Using Cargo

Add to your Cargo.toml:

[dependencies]
agent-mem = "2.0"
tokio = { version = "1", features = ["full"] }

Using Docker

docker pull agentmem/server:latest
docker run -p 8080:8080 agentmem/server:latest

From Source

git clone https://github.com/louloulin/agentmem.git
cd agentmem
cargo build --release

Basic Usage

use agent_mem::Memory;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Zero-configuration initialization
    let memory = Memory::new().await?;

    // Add memories with automatic fact extraction
    memory.add("I love pizza").await?;
    memory.add("I live in San Francisco").await?;
    memory.add("My favorite food is pizza").await?; // Auto-deduplicated

    // Semantic search
    let results = memory.search("What do you know about me?").await?;
    for result in results {
        println!("- {} (score: {:.2})", result.memory, result.score);
    }

    Ok(())
}

Running the Server

# Start the full-stack server (API + UI)
cargo run --bin agent-mem-server

# Or use Docker Compose
docker-compose up -d

Access Points:

  • 🌐 API: http://localhost:8080
  • πŸ–₯️ Web UI: http://localhost:3001
  • πŸ“š API Docs: http://localhost:8080/swagger-ui/

πŸ“Š Performance Benchmarks

Operation Throughput Latency (P50) Latency (P99)
Add Memory 5,000 ops/s 20ms 50ms
Vector Search 10,000 ops/s 10ms 30ms
BM25 Search 15,000 ops/s 5ms 15ms
Plugin Call 216,000 ops/s 1ms 5ms
Batch Operations 50,000 ops/s 100ms 300ms
Graph Traversal 1,000 queries/s 50ms 200ms

Benchmarks run on: Apple M2 Pro, 32GB RAM, LibSQL backend


πŸ—οΈ Architecture

AgentMem is organized into 18 specialized crates with clear separation of concerns:

agentmem/
β”œβ”€β”€ agent-mem-traits          # Core abstractions and traits
β”œβ”€β”€ agent-mem-core             # Memory management engine (32K lines)
β”œβ”€β”€ agent-mem                 # Unified high-level API
β”œβ”€β”€ agent-mem-llm             # 20+ LLM provider integrations
β”œβ”€β”€ agent-mem-embeddings      # Embedding models (FastEmbed, ONNX)
β”œβ”€β”€ agent-mem-storage         # Multi-backend storage layer
β”œβ”€β”€ agent-mem-intelligence    # AI reasoning engine (DeepSeek, etc.)
β”œβ”€β”€ agent-mem-plugin-sdk      # WASM plugin SDK
β”œβ”€β”€ agent-mem-plugins         # Plugin manager with hot-reload
β”œβ”€β”€ agent-mem-server          # HTTP REST API (175+ endpoints)
β”œβ”€β”€ agent-mem-client          # HTTP client library
β”œβ”€β”€ agent-mem-compat          # Mem0 compatibility layer
β”œβ”€β”€ agent-mem-observability   # Monitoring and metrics
β”œβ”€β”€ agent-mem-performance     # Performance optimizations
β”œβ”€β”€ agent-mem-deployment      # Kubernetes deployment
β”œβ”€β”€ agent-mem-distributed     # Distributed support
└── agent-mem-python          # Python bindings (PyO3)

Total: 275,000+ lines of production Rust code


πŸ”Œ Plugin System

AgentMem features a high-performance WASM plugin system with sandbox isolation:

use agent_mem_plugins::PluginManager;

// Create plugin manager with LRU cache
let plugin_manager = PluginManager::new(100);

// Register plugins with hot-reload
plugin_manager.register(weather_plugin).await?;

// Execute plugins in isolated sandbox
let result = plugin_manager.execute("weather", &input).await?;

Plugin Features:

  • πŸ”’ Sandbox isolation - WebAssembly security
  • ⚑ LRU caching - 93,000x speedup on cached calls
  • πŸ”„ Hot-reload - Load/unload without restart
  • πŸŽ›οΈ Capability system - Fine-grained permissions
  • πŸ“Š Performance monitoring - Built-in metrics

πŸ”Œ Model Context Protocol (MCP) Integration

AgentMem provides a complete Model Context Protocol (MCP) server implementation, enabling seamless integration with Claude Code, Claude Desktop, and other MCP-compatible clients.

MCP Features

  • βœ… 5 Core Tools: Memory management, search, chat, system prompts, and agent listing
  • βœ… Multiple Transports: stdio, HTTP, SSE (Server-Sent Events)
  • βœ… Resource Management: Dynamic resource discovery and subscription
  • βœ… Prompt Templates: Reusable prompt templates with variables
  • βœ… Authentication: JWT and API key support
  • βœ… Production Ready: Battle-tested with Claude Code integration

Quick Start with Claude Code

# 1. Build the MCP server
cargo build --package mcp-stdio-server --release

# 2. Create .mcp.json in your project root
cat > .mcp.json << EOF
{
  "mcpServers": {
    "agentmem": {
      "command": "./target/release/agentmem-mcp-server",
      "args": [],
      "env": {
        "AGENTMEM_API_URL": "http://127.0.0.1:8080",
        "RUST_LOG": "info"
      }
    }
  }
}
EOF

# 3. Start Claude Code in the project directory
claude

Available MCP Tools

Tool Description Parameters
agentmem_add_memory Add a new memory to the system content, user_id, agent_id (optional), memory_type (optional)
agentmem_search_memories Search memories semantically query, user_id, limit (optional), search_type (optional)
agentmem_chat Intelligent chat with memory context message, user_id, agent_id (optional)
agentmem_get_system_prompt Get personalized system prompt user_id, agent_id (optional)
agentmem_list_agents List all available agents None

Example Usage in Claude Code

User: Remember that I prefer dark mode and use Rust for backend development

Claude: [Calls agentmem_add_memory]
βœ… Memory saved successfully

User: What do you know about my preferences?

Claude: [Calls agentmem_search_memories]
Based on your saved memories:
- You prefer dark mode
- You use Rust for backend development

Documentation


🌐 Language Bindings

AgentMem provides official SDKs for multiple languages:

Python

from agentmem import Memory

memory = Memory()
memory.add("User prefers dark mode")
results = memory.search("user preferences")

Installation: pip install agentmem

JavaScript/TypeScript

import { Memory } from 'agentmem';

const memory = new Memory();
await memory.add("User prefers dark mode");
const results = await memory.search("user preferences");

Installation: npm install agentmem

Go

import "github.com/agentmem/agentmem-go"

memory := agentmem.NewMemory()
memory.Add("User prefers dark mode")
results := memory.Search("user preferences")

Cangjie

import agentmem.*

let memory = Memory.create()
memory.add("User prefers dark mode")
let results = memory.search("user preferences")

See: SDKs Documentation


πŸ“š Documentation

πŸ“– Complete Documentation Index - Central hub for all documentation

Getting Started

User Guides

Developer Resources

API & Integration


πŸ’‘ Use Cases

1. AI Chatbots

Provide persistent memory for conversational AI:

memory.add("user123", "Prefers dark mode").await?;
let context = memory.search("user preferences", "user123").await?;

2. Knowledge Management

Build enterprise knowledge bases:

memory.add("company_kb", "Vacation policy: 20 days/year").await?;
let results = memory.search("vacation policy", "company_kb").await?;

3. Multi-Agent Systems

Coordinate multiple AI agents with shared memory:

let scope = MemoryScope::Agent {
    user_id: "alice",
    agent_id: "coding-assistant"
};
memory.add_with_scope("Prefers Rust", scope).await?;

4. Mem0 Migration

Drop-in replacement for Mem0:

use agent_mem_compat::Mem0Client;

let client = Mem0Client::new().await?;
let id = client.add("user", "content", None).await?;

🀝 Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

Ways to contribute:

  • πŸ› Bug fixes and reports
  • πŸ’‘ Feature requests
  • πŸ“ Documentation improvements
  • πŸ§ͺ Test cases
  • πŸ”§ Performance optimizations
  • 🌍 Internationalization

Development Setup

# Clone the repository
git clone https://github.com/louloulin/agentmem.git
cd agentmem

# Build the workspace
cargo build --workspace

# Run tests
cargo test --workspace

# Run linting
cargo clippy --workspace -- -D warnings

# Format code
cargo fmt --all

πŸ“ˆ Roadmap

Current Version (2.0.0)

  • βœ… Core memory management
  • βœ… 5 search engines
  • βœ… WASM plugin system
  • βœ… Multi-backend storage
  • βœ… Enterprise features (RBAC, audit logs)
  • βœ… Language bindings (Python, JS, Go, Cangjie)

Upcoming (2.1.0)

  • πŸ”œ Code-native memory (AST parsing)
  • πŸ”œ GitHub integration
  • πŸ”œ Claude Code deep integration
  • πŸ”œ Advanced context management
  • πŸ”œ Performance optimizations

See: Roadmap


πŸ† Production Ready

AgentMem is battle-tested and production-ready:

  • βœ… 99.9% uptime capability
  • βœ… Horizontal scaling support
  • βœ… Multi-region deployment ready
  • βœ… Disaster recovery with backup/restore
  • βœ… Security audits and vulnerability scanning
  • βœ… Comprehensive monitoring and alerting

πŸ“„ License

Dual-licensed under:


πŸ™ Acknowledgments

Built with amazing open-source projects:


AgentMem - Give your AI the memory it deserves. 🧠✨

GitHub Β· Documentation Β· Examples Β· Discord Β· Blog Β· δΈ­ζ–‡ζ–‡ζ‘£

Made with ❀️ by the AgentMem team

About

AgentMem is a high-performance, enterprise-grade memory management platform for AI agents and LLM-powered applications. It provides persistent memory, intelligent semantic search, and AI-powered reasoning capabilities.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •