memagent — Human-brain memory for LLM agents
Chinese README: README.md
The problem
LLM agents that run for more than a few turns have a memory problem. Either you stuff the entire history into the context window (and the model starts hallucinating from the noise), or you drop everything and the agent forgets what it just learned.
Most agent memory libraries (MemGPT, Mem0, Zep, etc.) use fixed forgetting parameters — a constant decay rate, a hard cap on stored items, hand-tuned similarity thresholds. They're generic scaffolding, not a real memory.
memagent is different: every memory has its own forgetting curve, the parameters self-tune at runtime from actual recall behavior, and memories are reconsolidated when recalled (like how your brain rewrites a memory each time you think about it).
What you get
- Zero dependencies in the core package (pure Python stdlib)
- Self-learning forgetting curve — each memory learns its own decay rate from usage
- Hot / Warm / Cold tiered storage — frequently recalled memories promote, rarely recalled ones compact into summaries
- Sleep consolidation — periodic replay that strengthens important memories and compresses the rest (the "REM sleep" of your agent)
- Retrieval-induced forgetting — querying a memory actually strengthens it (the testing effect)
- Three entry points: CLI, REST API, and MCP server (for Hermes, Claude, Cursor, etc.)
- 650+ tests passing on Python 3.10-3.13, Windows + Linux
Install
pip install memagent-local # core, zero dependencies
pip install memagent-local[mcp] # + MCP server (for AI agents)
pip install memagent-local[embed-local] # + local embeddings (sentence-transformers)
pip install memagent-local[embed-fastembed] # + ONNX embeddings (lightweight, no torch)
Verify:
memagent --version # should print 0.3.5
Quick start
from memagent import MemoryAgent
agent = MemoryAgent(persist="memory.json")
agent.remember("User prefers concise responses", importance=0.9)
agent.remember("Project uses FastAPI on port 8000", importance=0.6)
results = agent.retrieve("what does the user prefer?")
print(results)
The agent learns your memory patterns — important memories survive longer, rarely-used ones compress into Cold summaries.
Entry points
| Entrypoint | How | When to use |
|---|---|---|
| CLI | memagent |
Ad-hoc queries, diagnostics, exports |
| REST | python -m memagent.server --port 8000 |
Non-Python clients (Node, Go, browser) |
| MCP | python -m memagent.mcp_server |
Native integration with Hermes, Claude, Cursor |
Why "self-tuning"?
Traditional memory systems pick a decay rate once and never change. That means:
- Frequently-referenced memories decay at the same rate as one-time trivia
- The parameters don't adapt to your usage pattern
memagent's τ-learner and plasticity-learner observe actual retrieval behavior and adjust each memory's decay rate at runtime. Your memory learns from your usage, not from a hardcoded constant.
License
MIT — use it in your product, modify it, sell what you build on top.
Looking for early users
First release. If you try it and something breaks, please open an issue. The first few real users get priority fixes — this project is currently dogfooded by the author.
Links
Metadata
Release files for memagent-local 0.3.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| memagent_local-0.3.6.tar.gz | 426.2 kB | Without provenance | Details for memagent_local-0.3.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| memagent_local-0.3.6-py3-none-any.whl | Python 3 | none | any | Details for memagent_local-0.3.6-py3-none-any.whl |
Total release size: 669.1 kB
Release files / memagent_local-0.3.6.tar.gz
| Download URL | memagent_local-0.3.6.tar.gz |
|---|---|
| Size | 426.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8826fe2e6f4a3557320674a7bb85905366fb9704f95585c2a1f1fcfb71190ec5
|
|
BLAKE2b-256 checksum How to use checksums |
56ad4ffdf9c5cbc5b72274e5e34b40eb7b476191ef6c976ded6d5eef460acaab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.15
|
Release files / memagent_local-0.3.6-py3-none-any.whl
| Download URL | memagent_local-0.3.6-py3-none-any.whl |
|---|---|
| Size | 242.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9544b68237ae6bfe76d9061b4a6ad9781d24c3494c91abf81511b5973576a8a1
|
|
BLAKE2b-256 checksum How to use checksums |
f0f19cdec22dd763223bc037b135c248e857a963ff7a4d934ee05ea92c142f2a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.15
|
Security for memagent-local 0.3.6
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.