Zero-config, traceable, MCP-native long-term memory for agents.
Project description
agent-memory
Zero-config, traceable, MCP-native long-term memory for agents.
agent-memory targets a gap in the current memory stack: a local-first engine that works with pip install, runs on pure SQLite, and makes memory evolution explainable instead of opaque.
PyPI distribution name: agent-memory-engine
Why this exists
Mem0proves demand, but pulls in heavier infra such as Neo4j or Qdrant.- Local agents and personal copilots need a memory layer that is easy to embed, debug, export, and ship.
- Interviews love this surface area: storage, retrieval, ranking, decay, provenance, conflict handling, MCP, and evaluation.
Current Status
- SQLite backend with WAL, FTS5, audit log, evolution log, entity index, and causal parent links
- Schema indexes for type, layer, recency, trust, source, relation, and audit hot paths
- Python SDK via
MemoryClient - Rule-based intent router with Reciprocal Rank Fusion
- Adaptive forgetting utilities with dual-threshold layer transitions
- Heuristic conflict detection with contradiction edges and trust-score adjustment
- Optional LLM-backed conflict adjudication for top semantic candidates
- Governance helpers for health reports, audit reads, and JSONL export/import
- Optional MCP server and REST API adapters with dependency-friendly fallbacks
sqlite-vecintegration with safe fallback to Python cosine scan when unavailable- Deterministic local fallback embeddings for testability and zero-friction startup
- LLM-first conversation extraction with heuristic fallback
- Trace graph reports with ancestors, descendants, relations, and evolution history
- Idempotent maintenance cycle for decay, promotion/demotion, conflict upkeep, and consolidation
- Benchmark helpers and LOCOMO-Lite style starter data
Quickstart
pip install -e .[dev]
.venv/bin/python -m pytest -q
agent-memory store "User prefers SQLite for local-first agents." --source-id demo
agent-memory search "Why SQLite?"
agent-memory health
from agent_memory import MemoryClient
client = MemoryClient()
item = client.add(
"The user prefers SQLite for local-first agent projects.",
source_id="demo-session",
)
results = client.search("What database does the user prefer?")
print(results[0].item.content)
trace = client.trace_graph(item.id)
print(trace.descendants)
health = client.health()
print(health.suggestions)
Architecture
graph TD
A["Python SDK / CLI"] --> B["MemoryClient"]
C["MCP Server"] --> B
D["REST API"] --> B
B --> E["Intent Router"]
B --> F["Conflict Detector"]
B --> G["Trust Scorer"]
B --> H["Forgetting Engine"]
E --> I["SQLite Backend"]
F --> I
G --> I
H --> I
I --> J[("SQLite + FTS5 + sqlite-vec")]
Core components
src/agent_memory/client.py— high-level SDK entry pointsrc/agent_memory/storage/sqlite_backend.py— SQLite persistence, FTS, vector fallback, trace queriessrc/agent_memory/controller/router.py— intent-aware retrieval routing and RRF fusionsrc/agent_memory/controller/forgetting.py— Ebbinghaus-inspired adaptive forgettingsrc/agent_memory/controller/conflict.py— contradiction detection and conflict recordssrc/agent_memory/controller/consolidation.py— overlap grouping and merge-draft generationsrc/agent_memory/controller/trust.py— multi-factor trust scoringsrc/agent_memory/governance/health.py— stale/orphan/conflict monitoringsrc/agent_memory/interfaces/mcp_server.py— eight MCP toolssrc/agent_memory/extraction/pipeline.py— conversation-to-memory extractionbenchmarks/— storage/retrieval microbenchmarks and synthetic eval seeds
Design choices
- SQLite + WAL keeps deployment zero-config while fitting agent workloads: many reads, occasional writes.
- Rule routing over LLM routing keeps routing latency predictable and testable.
- RRF instead of score averaging avoids calibration problems across lexical, entity, and semantic retrieval.
sqlite-vecplus fallback gives C/SQL vector search when available while keeping the package runnable everywhere.- Soft delete preserves provenance and causal trace integrity.
- Hash fallback embeddings make the package runnable even before a local embedding model is available.
- Unique relation edges keep maintenance idempotent and health metrics stable.
Project layout
agent-memory/
├── docs/plans/
├── examples/
├── src/agent_memory/
│ ├── controller/
│ ├── embedding/
│ ├── extraction/
│ └── storage/
└── tests/
Benchmarks
Synthetic LOCOMO-Lite run on the bundled starter dataset (30 dialogues / 150 questions):
| Metric | agent-memory |
Semantic-only baseline |
|---|---|---|
| Overall hit rate | 50.0% | 23.3% |
| Factual recall | 53.3% | 6.7% |
| Temporal recall | 36.7% | 3.3% |
| Causal recall | 53.3% | 6.7% |
| p95 retrieval latency | 16.64ms | 11.50ms |
- Full report:
docs/benchmark-results.md - Re-run locally:
python benchmarks/locomo_lite/evaluate.py
MCP Usage
Install MCP support and launch the stdio server:
pip install -e .[mcp]
python -m agent_memory.interfaces.mcp_server
Claude Desktop configuration:
{
"mcpServers": {
"agent-memory": {
"command": "python",
"args": ["-m", "agent_memory.interfaces.mcp_server"],
"env": {
"AGENT_MEMORY_DB_PATH": "/absolute/path/to/default.db"
}
}
}
}
Typical tools:
memory_store— store a memory with provenancememory_search— run intent-aware retrievalmemory_trace— inspect causal ancestry and evolutionmemory_health— inspect stale/conflict/orphan metrics
More details: docs/mcp-integration.md
Demos
python examples/demo_cross_session.py --db /tmp/agent-memory-demo.dbpython examples/interactive_chat.py --db chat_memory.db --provider nonepython examples/mcp_server.py
Release Notes
benchmarks/locomo_lite/latest_results.jsonis regenerated by the evaluation scriptdocs/screenshots/is reserved for verified MCP client screenshots- Update GitHub URLs if you publish under a different org/user
- Delivery record and full tutorial:
docs/project-delivery-and-tutorial.md - Expansion and optimization review:
docs/plans/2026-03-24-agent-memory-expansion-review.md
Dev Notes
- Run all tests with
.venv/bin/python -m pytest -q - Use the built-in CLI with
agent-memory --help sqlite-vecis installed as a package dependency; if the extension cannot be loaded at runtime, vector search safely falls back to Python cosine scan- Try microbenchmarks with
python benchmarks/bench_storage.pyandpython benchmarks/bench_retrieval.py - Try the demo runner with
python examples/benchmark_runner.py
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 agent_memory_engine-0.1.0.tar.gz.
File metadata
- Download URL: agent_memory_engine-0.1.0.tar.gz
- Upload date:
- Size: 58.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2d095003b9e09c09cccd9e94060d832057a6aa619c453e7b63101580a88d814
|
|
| MD5 |
fedd661bafaa09edf8b97ff954eecc1a
|
|
| BLAKE2b-256 |
92daad1bcf1c4c0d8fcd49ae7ea31170feef1511d8b7401cb44937f2fe5a92d6
|
File details
Details for the file agent_memory_engine-0.1.0-py3-none-any.whl.
File metadata
- Download URL: agent_memory_engine-0.1.0-py3-none-any.whl
- Upload date:
- Size: 40.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d24a61636c7a4d5f5557b79d78e5c7cdf57e611beb9843afaed36f9ba6e4413
|
|
| MD5 |
49bd0e63988527fa2fe64e6909f9c496
|
|
| BLAKE2b-256 |
efe3daf63c7971445625c92fce0da624104915a97fdb8d02ce5d1829f1b6726f
|