Local-first memory for AI agents. SQLite + local embeddings. No cloud required.
Project description
AgentMemry 🧠
Local-first memory for AI agents. No cloud. No setup. Just SQLite.
Most agent memory frameworks require Postgres, Neo4j, or a cloud vector database. AgentMemry doesn't. It runs entirely on your machine using SQLite and local embeddings — making it the fastest way to add persistent memory to any Python agent.
Why AgentMemry?
| Feature | AgentMemry | Mem0 | Zep | Letta |
|---|---|---|---|---|
| Local-first (no cloud DB) | ✅ | ❌ | ❌ | ❌ |
| Zero setup | ✅ | ⚠️ | ❌ | ❌ |
| No API key required | ✅ | ❌ | ❌ | ✅ |
| Semantic search | ✅ | ✅ | ✅ | ✅ |
| MMR diversity search | ✅ | ❌ | ❌ | ❌ |
| Multi-agent isolation | ✅ | ✅ | ✅ | ✅ |
| Exportable / portable | ✅ (single .db file) | ❌ | ❌ | ❌ |
Installation
AgentMemry is a single, self-contained package. Clone the repo and install it in editable mode:
git clone https://github.com/BaavanshReddy/agentmemry.git
cd agentmemry
pip install -e .
No Docker. No database server. No API keys. (A PyPI release is on the roadmap.)
Quickstart
from agentmemry import Memory
mem = Memory()
# Store memories
mem.add("User prefers concise, bullet-point answers")
mem.add("The project uses FastAPI and PostgreSQL")
mem.add("Authentication uses JWT tokens")
# Search
results = mem.search("what database are we using?")
print(results[0]["content"])
# → "The project uses FastAPI and PostgreSQL"
# Inject context directly into a system prompt
context = mem.get_context("how should I format my response?")
print(context)
# → Relevant memory: User prefers concise, bullet-point answers
Core API
Memory(agent_id, db_path, model, top_k, threshold)
| Parameter | Default | Description |
|---|---|---|
agent_id |
"default" |
Namespace — different agents sharing one DB stay isolated |
db_path |
"agentmemry.db" |
Path to the SQLite file (created automatically) |
model |
"all-MiniLM-L6-v2" |
sentence-transformers model for local embeddings |
top_k |
5 |
Default results returned by search() |
threshold |
0.15 |
Minimum similarity score (0–1) |
mem.add(content, metadata=None) → str
Store a memory. Returns the memory ID.
mem.add("Deadline is Friday", metadata={"type": "task", "priority": "high"})
mem.search(query, top_k=None, threshold=None, diverse=False) → list[dict]
Semantic search over stored memories.
results = mem.search("when is the deadline?")
for r in results:
print(r["content"], r["score"])
Set diverse=True to use Maximal Marginal Relevance (MMR) — returns a more varied set of results instead of near-duplicates.
mem.get_context(query, top_k=None, prefix="Relevant memory: ") → str
Returns a formatted string ready to inject into any LLM prompt.
system_prompt = f"""
You are a helpful assistant.
{mem.get_context(user_message)}
Answer the user's question below.
"""
Other methods
mem.update(memory_id, new_content) # Re-embed and overwrite
mem.delete(memory_id) # Remove one memory
mem.clear() # Wipe all memories for this agent
mem.get_all() # List every memory (newest first)
mem.get_by_id(memory_id) # Fetch a specific memory
mem.stats() # Count, db path, model info
Use case: Coding agent with persistent project memory
from agentmemry import Memory
mem = Memory(agent_id="coding_assistant")
# Session 1 — onboarding
mem.add("This project uses Python 3.11 and FastAPI")
mem.add("Database is PostgreSQL with SQLAlchemy ORM")
mem.add("We use Alembic for migrations, not raw SQL")
mem.add("Tests are written with pytest, coverage must stay above 80%")
# Session 2 — new conversation, agent remembers everything
context = mem.get_context("How should I set up a new migration?")
# → Relevant memory: We use Alembic for migrations, not raw SQL
# → Relevant memory: Database is PostgreSQL with SQLAlchemy ORM
Multi-agent support
Multiple agents can share the same database file without interfering:
agent_a = Memory(agent_id="planner", db_path="agents.db")
agent_b = Memory(agent_id="executor", db_path="agents.db")
agent_c = Memory(agent_id="reviewer", db_path="agents.db")
Each agent only sees its own memories.
How it works
User input
│
▼
sentence-transformers (local, offline)
│ Converts text → float32 vector
▼
SQLite (agentmemry.db)
│ Stores content + embedding blob + metadata
▼
Cosine similarity search (numpy)
│ Ranks stored memories by relevance
▼
Top-K results → injected into LLM prompt
No network calls. No external services. All computation happens in Python.
Running the examples
# Clone the repo
git clone https://github.com/BaavanshReddy/agentmemry.git
cd agentmemry
# Install dependencies
pip install -e ".[dev]"
# Run quickstart
python examples/basic_usage.py
# Run coding agent example
python examples/coding_agent.py
# Run tests
pytest tests/ -v
Requirements
- Python 3.9+
- sentence-transformers
- numpy
Roadmap
- Publish to PyPI
- Automatic memory deduplication
- Time-decay scoring (older memories ranked lower)
- Memory compression for long-running agents
- LangChain / LlamaIndex integration
- Benchmark results on LongMemEval
Contributing
Pull requests are welcome. For major changes, open an issue first.
License
MIT — see LICENSE.
Author
Baavansh Reddy Gundlapalli — GitHub
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agentmemry-0.1.1.tar.gz.
File metadata
- Download URL: agentmemry-0.1.1.tar.gz
- Upload date:
- Size: 12.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3df443d2d64cf6a46adc7d3189a8dd1cd337eb60a4ca2c1bd143ee77571c3386
|
|
| MD5 |
7751c424d6d4bb1c7f0feea68ef162ff
|
|
| BLAKE2b-256 |
958b77630a1f0227159729b1c70318b8d4993d68270e7a48921027062df2dda7
|
File details
Details for the file agentmemry-0.1.1-py3-none-any.whl.
File metadata
- Download URL: agentmemry-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bda8cb3b286f04f6c74ea63c5edd4064203efd906de32afcae6c81fe121645d9
|
|
| MD5 |
dcd05bbb3e36fbbfe80156b02cc00d1f
|
|
| BLAKE2b-256 |
01f20b28e8c022f3ca7aa02486874e4282a66edee074144838b7571deef5999a
|