Skip to main content

memagent — Human-brain memory for LLM agents

CI PyPI version License: MIT Python 3.10+

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

memagent_local-0.3.6.tar.gz (426.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

memagent_local-0.3.6-py3-none-any.whl (242.8 kB view details)

Uploaded Python 3

File details

Details for the file memagent_local-0.3.6.tar.gz.

File metadata

  • Download URL: memagent_local-0.3.6.tar.gz
  • Upload date:
  • Size: 426.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.15

File hashes

Hashes for memagent_local-0.3.6.tar.gz
Algorithm Hash digest
SHA256 8826fe2e6f4a3557320674a7bb85905366fb9704f95585c2a1f1fcfb71190ec5
MD5 0418e0d27ccfd0bebe4ca8d9517d344a
BLAKE2b-256 56ad4ffdf9c5cbc5b72274e5e34b40eb7b476191ef6c976ded6d5eef460acaab

See more details on using hashes here.

File details

Details for the file memagent_local-0.3.6-py3-none-any.whl.

File metadata

  • Download URL: memagent_local-0.3.6-py3-none-any.whl
  • Upload date:
  • Size: 242.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.15

File hashes

Hashes for memagent_local-0.3.6-py3-none-any.whl
Algorithm Hash digest
SHA256 9544b68237ae6bfe76d9061b4a6ad9781d24c3494c91abf81511b5973576a8a1
MD5 53ab7d311160c255f783334186018a9c
BLAKE2b-256 f0f19cdec22dd763223bc037b135c248e857a963ff7a4d934ee05ea92c142f2a

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.6 This release

2 files

0.3.5

2 files

0.3.4

2 files

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