The full upstream README, mirrored here for reference. Install config, tool schemas, adoption signals, and an original overview live on the Agent Memory listing page.
Persistent semantic memory for AI agents with intelligent decision-making.

🚀 Created by: TheProdSDE
Most AI memory systems retrieve and inject past context into every prompt. This leads to wasted tokens, inconsistent responses, and agents that blindly replay stale or wrong answers.
Agent Memory adds a decision layer:
Every resolve() returns an explicit action with a scored, explainable rationale —
not just a retrieved chunk.
Adversarial eval: 34/36 (94%) on trap queries — the 2 misses return VERIFY (cautious), never a wrong REPLAY — see benchmarks.
Context rot is the measured degradation of LLM accuracy as the context window fills — long before the token limit. Stale chunks, irrelevant retrievals, and unbounded conversation history don't just waste tokens; they actively degrade answers ("lost in the middle", instruction drift, distractor sensitivity).
Context rot has two causes. Agent Memory addresses the first; nothing outside the model itself can address the second.
1. What goes into the context — controllable, and this SDK's job:
| Rot source | Mechanism in Agent Memory |
|---|---|
| Irrelevant memory injected into every prompt | Decision layer — NONE refuses to inject when nothing truly matches (34/36 on adversarial trap queries; the 2 misses fail safe to VERIFY) |
| Unbounded in-session history | PagedMemory — fixed in-context buffer; old turns page out to recall storage and return per-query (MemGPT-style tiers) |
| Instruction drift in long coding sessions | RESTORE re-injects the relevant convention fresh, near the end of context, exactly when a query needs it |
| Stale facts silently reused | VERIFY + custom verifier callbacks + TTL expiry + half-life temporal decay |
| Reminders that never adapt | mark_correct() / mark_wrong() — confidence learning promotes memories that keep helping, demotes corrected ones |
| Knowledge lost when the session ends | from_conversation() distills durable facts from conversation turns into the store |
2. How the model attends over tokens already in its context — not controllable from outside. Attention degradation over long context is a property of the model. No memory layer changes that. What Agent Memory does is keep the context small and relevant enough that the model rarely enters the degraded regime in the first place.
The honest claim: Agent Memory prevents context pollution — the dominant
controllable cause of context rot in agentic systems. It doesn't change model attention
behavior, and it only helps if your agent routes context through resolve() /
PagedMemory instead of concatenating history by hand.
Today you need three tools wired together to get what resolve() does in one call:
a semantic cache (GPTCache) for replay, a memory layer (Mem0 / Zep) for context, and
custom staleness logic for verification. No existing tool decides — at read time —
whether and how a memory should be used.
Cells about other projects are capability checks against their own source or
docs (mem0 checked on 2026-09-27), not measured behaviour; ❔ means we have not
tested it rather than that it is absent. Corrections welcome — see
docs/comparison.md for sourcing and the
benchmark RFC for the review process.
| Capability | Mem0 | Zep / Graphiti | Letta (MemGPT) | GPTCache | Agent Memory |
|---|---|---|---|---|---|
| Read-time decision (replay / inject / verify / skip) | ❌ always injects | ❌ always injects | ⚠️ LLM self-manages | ⚠️ replay only | ✅ REPLAY / RESTORE / VERIFY / NONE |
| Explainable per-decision scores | ❌ | ❌ | ❌ | ❌ | ✅ decision.explain() |
| Semantic answer cache (skip the LLM call) | ❌ | ❌ | ❌ | ✅ | ✅ |
| Staleness protection at read time | ⚠️ write-side updates + expiration_date | ✅ temporal graph | ❌ | ⚠️ eviction only | ✅ VERIFY + TTL + confidence decay |
| Adversarial trap-query eval published | ❔ none found | ❔ none found | ❔ none found | ❔ none found | ✅ 34/36 (94%) |
| LLM / API calls per memory op | 1+ | 1+ | 1+ | 0 | 0 |
| Local after model assets are installed/cached, zero API keys | ⚠️ self-hostable; needs an LLM for extraction | ⚠️ needs server + LLM | ⚠️ LLM per op | ✅ | ✅ SQLite + local ONNX |
| Paged context tiers (MemGPT-style) | ❌ | ❌ | ✅ | ❌ | ✅ memory.paged() |
Because hosted or model-backed configurations can add an LLM or embedding API round-trip per memory operation, their latency includes provider, model, and network costs. Exact latency depends on each project's configuration; this repository does not publish a universal 100ms–2s floor. Agent Memory resolves in-process in SQLite-only mode; measured latency depends on corpus shape and cache state (see performance and stress-testing details).
On retrieval, we publish a cleaned-release retrieval-proxy measurement below. On end-to-end accuracy (LLM answering + judge, where Mem0 and Zep publish), we don't quote numbers we haven't measured yet — that stage is next on the roadmap. → Full feature matrix and trade-offs (including where they're better): docs/comparison.md
LongMemEval is a benchmark for conversational-history retrieval. These results measure Agent Memory's RESTORE/retrieval tier, not REPLAY, VERIFY, TTL, or end-to-end answer correctness. Each question runs against a separate SQLite store containing that question's haystack; aggregate ingestion totals are not the size of one queried store. All ingestion uses zero LLM calls and $0 in API charges:
LongMemEval_S (500 independent ~48-session haystacks; 124K turn-pair entries across all runs): 98.1% session Recall@5 with local ONNX embeddings, 96.0% lexical-only, 10.04ms lexical / 19.56ms semantic p50 retrieval. The report includes p90/p95/p99 and run-resource measurements.
LongMemEval_M (500 independent ~500-session haystacks; ~2,500 turn-pair entries per queried store): 87.0% session Recall@5 with lexical retrieval, 12.05ms p50. This uses the official cleaned re-release and turn-pair indexing; it is not directly comparable with the paper's original-release session-index baselines.


Full methodology, per-type tables, scope notes (what this benchmark does and
doesn't test), and negative results are in the
benchmark report. Reproduce the semantic
_S result with uv run python benchmarks/longmemeval/run_retrieval.py --semantic.
Every claim below is reproducible from this repo:
agent-memory eval (methodology)| Use case | Without memory | With Agent Memory | Saving |
|---|---|---|---|
| Support bot handling 10k identical FAQ queries/day | Every query costs 1 LLM call | If roughly 75% of requests match reusable memories, those matches can REPLAY without an LLM call | Potentially lower LLM cost; measure your workload |
| Coding agent that re-derives project conventions each session | Wastes 2–5 LLM calls per session to "remember" conventions | Conventions stored once are REPLAYED/RESTORED from the first query of every later session | No re-derivation overhead |
| Research agent building knowledge over multiple sessions | Each session starts cold; re-reads the same sources | Facts and summaries are RESTORED as context | Persistent cross-session knowledge |
| Customer onboarding bot answering the same steps repeatedly | Always generates a response | High-confidence workflows are REPLAYED verbatim | Consistent identical answers |
| Tool-output caching for expensive API calls | Calls the external API every time | Results stored with TTL; REPLAY within TTL, re-call after | Reduced external API cost |
| Policy-compliance agent that must verify facts before replaying | Silent hallucination risk on stale data | requires_verification=True routes relevant matches to VERIFY; low-scoring matches return NONE | Auditability + safety |
A GPT-4o call costs ~$0.005. A support agent handling 50,000 queries/day with 70% repeat rate:
REPLAY avoids an LLM call when policy permits it. The latency and cost difference depends on the local workload, provider, model, and network; measure both paths in your own pipeline.
Good fit:
Not the right tool:
| Feature | What it does |
|---|---|
| Decision engine | Every resolve() returns REPLAY / RESTORE / VERIFY / NONE — never silent injection |
| Explainability | decision.explain() shows per-component scores: semantic, recency, confidence, usage |
| Hybrid retrieval | BM25 FTS5 + optional vector KNN + RRF fusion — fast and accurate |
| 4 backends | SQLite (default, zero-setup) · ChromaDB · Redis · PostgreSQL |
| Framework adapters | Drop-in BaseMemory for LangChain and LlamaIndex |
| MCP server | Works with Cursor, Claude Code, VS Code via Model Context Protocol |
| REST API | FastAPI server with 9 endpoints + Swagger UI |
| Dashboard | Streamlit UI — stats, memory browser, live resolve sandbox |
| Multi-agent | SHARED / NAMESPACED / ISOLATED memory across multiple agents |
| Confidence learning | Event-driven confidence updates + half-life temporal decay |
| Memory graph | Relationship edges, path-finding, clusters, PageRank importance |
| Paged context | MemGPT-style tiers: in-context buffer → recall → archival; bounded working set per query |
| Conversation distillation | from_conversation() auto-extracts facts, preferences, and entities from turns |
| Async API | aremember, aresolve, alist, … — memory read/write and decision operations have async counterparts |
| TTL & states | Automatic expiry, archiving, near-duplicate consolidation |
→ Full feature reference: docs/features.md
Latency, CPU, and memory use depend on the corpus, query distribution, cache state, embedding mode, machine, and operating system. The bundled harness uses a repeatable synthetic workload; it does not establish a production SLA.
The current lexical FTS5 benchmark results and charts are archived with their source JSON in the stress-test methodology. See that document for commands, workload scope, and guidance on interpreting results.
Use Agent Memory when:
Don't use it for:
→ Full integration pattern and API reference: docs/usage.md
An interactive Streamlit dashboard for exploring memories, testing the resolve sandbox, and monitoring stats.

| Stats — KPIs + charts | Memories — searchable table |
|---|---|
![]() | ![]() |
| Resolve → REPLAY | Resolve → VERIFY |
|---|---|
![]() | ![]() |
Agent Memory is published on the MCP Registry — install it in any MCP-compatible client with zero manual setup.
Cursor — add to .cursor/mcp.json in your project, or ~/.cursor/mcp.json globally:
Claude Desktop — add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
Claude Code — add to .claude/settings.json in your project:
uvx installs the package on first run — no pip install needed.
| Variable | Default | Description |
|---|---|---|
AGENT_MEMORY_DIR | ~/.agent_memory | Directory for the persistent SQLite store |
AGENT_MEMORY_COLLECTION | agent_memories | Collection name (one DB per collection) |
| Tool | What it does |
|---|---|
resolve_memory | Retrieve memory and get an explicit decision: replay / restore / verify / none — with confidence score and reasoning |
remember_memory | Store a query/response pair with optional tags, type, scope, confidence, TTL |
list_memories | Paginated list of stored memories with scope and archive filters |
get_memory_by_id | Fetch a single memory entry by ID |
forget_memory | Permanently delete a memory |
archive_memory | Archive a memory (excluded from retrieval, not deleted) |
consolidate_memories | Merge near-duplicate memories into summary entries |
→ Full MCP setup guide and Docker config: docs/mcp.md
agent-memory-sdk is the core — every integration delegates to Memory.
| Integration | Install extra | Example |
|---|---|---|
| Core SDK (SQLite) | (none) | basic_usage.py |
LangChain BaseMemory | [langchain] | langchain_integration.py |
LlamaIndex BaseMemory | [llamaindex] | llamaindex_integration.py |
| Redis backend | [redis] | redis_backend.py |
| PostgreSQL backend | [postgres] | postgres_backend.py |
| Multi-agent isolation | (none) | multi_agent.py |
| FastAPI REST server | [api] | rest_api.py |
| Confidence + Graph | (none) | confidence_and_graph.py |
| Benchmark harness | (none) | benchmark_harness.py |
→ Setup instructions and code snippets for each: examples/README.md
| Component | Technology |
|---|---|
| Language | Python 3.10+ |
| Storage | SQLite · ChromaDB · Redis · PostgreSQL |
| Retrieval | BM25 FTS5 + Vector KNN + RRF fusion |
| Interfaces | MCP · FastAPI · Streamlit · CLI |
| Adapters | LangChain BaseMemory · LlamaIndex BaseMemory |
| Search DSA | Bloom filter (NONE fast-path) · Dynamic IDF stop words · RRF fusion |
| Testing | pytest (412 collected tests) · ruff · mypy |
| CI/CD | GitHub Actions — test matrix 3.10–3.13 → release gate → PyPI |
No API keys required — everything runs locally.
| Doc | Contents |
|---|---|
| docs/usage.md | Integration pattern, API reference, MemoryEntry / MemoryDecision fields |
| docs/features.md | Decision actions, hybrid retrieval, types, scopes, TTL, graph, multi-agent |
| docs/mcp.md | MCP server setup for Cursor, Claude Code, VS Code; Docker config |
| docs/cli.md | CLI commands, REST API server, dashboard launch, eval dataset format |
| docs/roadmap.md | All shipped features, what's next, GitHub Project board |
| docs/release.md | CI-automated release process, versioning, rollback |
| docs/architecture.md | Retrieval pipeline, scoring policy, system design |
| docs/comparison.md | Feature matrix vs Redis, mem0, Zep, LangMem, LlamaIndex, MemGPT |
| docs/stress-testing.md | 10K / 100K / 1M latency benchmarks with methodology |
| docs/benchmarks.md | Eval results and reproduce commands |
| docs/why-decision-layer.md | The failure mode this project exists to fix |
| examples/README.md | Index of all runnable examples |
| CONTRIBUTING.md | Dev setup, test commands, PR checklist |
All planned features through v0.5.0 are shipped. Track what's next on the GitHub Project →
Tag-triggered, fully CI-gated: git tag v0.x.y && git push origin v0.x.y
See CONTRIBUTING.md for dev setup, test commands, and the PR checklist.
If you use Agent Memory SDK or its benchmark suite in your research, articles, or projects, please cite this repository using GitHub's Cite this repository button.
For reproducible benchmark comparisons, reference the exact SDK version, benchmark dataset version, configuration, and Git commit.
Apache-2.0 — see LICENSE.
Agent Memory helps agents decide: Replay → Restore → Verify → Ignore
Built with ❤️ by TheProdSDE
mcp-name: io.github.theprodsde/agent-memory