Skip to main content

AgentMemry 🧠

Local-first memory for AI agents. No cloud. No setup. Just SQLite.

License: MIT Python 3.9+ Tests: pytest

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

Metadata

Release files for agentmemry 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agentmemry 0.1.1
File Size Uploaded Provenance Actions
agentmemry-0.1.1.tar.gz 12.7 kB Without provenance Details for agentmemry-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for agentmemry 0.1.1
File Interpreter ABI Platform Actions
agentmemry-0.1.1-py3-none-any.whl Python 3 none any Details for agentmemry-0.1.1-py3-none-any.whl

Total release size: 23.6 kB

Release files / agentmemry-0.1.1.tar.gz

Download URL agentmemry-0.1.1.tar.gz
Size 12.7 kB
Tags Source
SHA-256 checksum
How to use checksums
3df443d2d64cf6a46adc7d3189a8dd1cd337eb60a4ca2c1bd143ee77571c3386
BLAKE2b-256 checksum
How to use checksums
958b77630a1f0227159729b1c70318b8d4993d68270e7a48921027062df2dda7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / agentmemry-0.1.1-py3-none-any.whl

Download URL agentmemry-0.1.1-py3-none-any.whl
Size 10.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bda8cb3b286f04f6c74ea63c5edd4064203efd906de32afcae6c81fe121645d9
BLAKE2b-256 checksum
How to use checksums
01f20b28e8c022f3ca7aa02486874e4282a66edee074144838b7571deef5999a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Security for agentmemry 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page