The intelligence layer between your agents and oblivion
Project description
Mnemon
The intelligence layer between your agents and oblivion.
Install
pip install mnemon-ai
Connect your LLM — set one environment variable:
export ANTHROPIC_API_KEY=sk-ant-... # pip install mnemon-ai[anthropic]
export OPENAI_API_KEY=sk-... # pip install mnemon-ai[openai]
export GOOGLE_API_KEY=AIza... # pip install mnemon-ai[google]
export GROQ_API_KEY=gsk_... # pip install mnemon-ai[groq] ← free tier
Mnemon detects the key automatically. No config file needed.
One line to add memory to any agent
import mnemon
m = mnemon.init()
That's it. Mnemon auto-detects your project, connects your LLM, and is ready to use anywhere in your codebase:
# Remember things
m.remember("Acme Corp prefers formal PDF reports")
m.learn_fact("acme_contact", "Sarah K")
# Recall relevant context
context = m.recall("weekly security audit for Acme Corp")
# Run with execution caching — LLM skipped on repeat tasks
result = m.run(
goal="weekly security audit for Acme Corp",
inputs={"client": "Acme Corp", "week": "March 17-21"},
generation_fn=my_planning_function,
)
print(f"Cache: {result['cache_level']}")
print(f"Tokens saved: {result['tokens_saved']}")
print(f"Time saved: {result['latency_saved_ms']:.0f}ms")
Access the same instance from anywhere:
m = mnemon.get()
No context manager required. Cleans up automatically when your process exits.
The Problem
Every major agent framework — CrewAI, Letta, Dify, LangChain — treats agents as stateless by default. Every run starts from zero. Agents re-plan things they already planned. They repeat mistakes they already made. They forget what they learned last session. Parallel agents step on each other's state.
This isn't a small inconvenience. It's why production agent deployments are fragile, slow, and expensive at scale.
Mnemon fixes this. Drop it in and your agents stop being amnesiac.
Mnemon was Alexander the Great's personal historian — the one whose only job was to ensure nothing was ever forgotten, so every campaign built on the total accumulated knowledge of every campaign before it. Your agents have a Mnemon now.
Benchmarks
| Benchmark | Metric | Score |
|---|---|---|
| LongMemEval | Retrieval accuracy | 64.6% |
| LoCoMo | Recall | 0.619 |
| LoCoMo | F1 | 0.636 |
| EME (execution cache) | System 1 hit rate | varies by workload |
Retrieval improved from 0.273 → 0.619 recall after the v1.0 overhaul. Full benchmark runs are in reports/.
Three Components
mnemon.memory — Cognitive Memory System
Five-layer stratified memory with protein bond activation retrieval.
- Working — ephemeral scratchpad, flushes at task end (no context bleed)
- Episodic — chronological experiences, importance-scored
- Semantic — stable facts, versioned key-value vault
- Relationship — per-user interaction patterns
- Emotional — emotional context, time-decayed
Retrieval: protein bond pattern assembly (~15ms, zero LLM) followed by conditional intent drone (only when needed).
mnemon.cache — Execution Memory Engine (EME)
Template cache for expensive recurring agent computations.
- System 1 — exact fingerprint match → sub-millisecond, zero LLM
- System 2 — partial segment match → gap fill with windowed context
- Fragment library — 49 pre-warmed segments from real enterprise runs
Works for agent plans, RAG pipelines, data pipelines, any structured workflow.
mnemon.bus — Two-Tier Experience Bus
Tier 1 — always-on learning loop. Records outcomes, detects patterns, feeds EME and memory.
Tier 2 — agent swarm layer. PAD health monitoring (Pleasure/Arousal/Dominance), collective immunity, atomic belief registry for shared state.
Async API
import asyncio
from mnemon import Mnemon
async def main():
async with Mnemon(tenant_id="my_company") as m:
await m.remember("Acme Corp prefers formal PDF reports")
result = await m.run(
goal="weekly security audit for Acme Corp",
inputs={"client": "Acme Corp", "week": "March 17-21"},
generation_fn=my_planning_function,
)
print(f"Cache level: {result['cache_level']}")
print(f"Tokens saved: {result['tokens_saved']}")
print(f"Latency saved: {result['latency_saved_ms']:.0f}ms")
asyncio.run(main())
Modular — Use Only What You Need
# Memory only
m = Mnemon(tenant_id="x", eme_enabled=False, bus_enabled=False)
# Execution cache only
m = Mnemon(tenant_id="x", memory_enabled=False, bus_enabled=False)
# Specific memory layers only
from mnemon.core.models import MemoryLayer
m = Mnemon(
tenant_id="x",
enabled_layers=[MemoryLayer.EPISODIC, MemoryLayer.SEMANTIC],
eme_enabled=False,
bus_enabled=False,
)
Production Features
from mnemon import Mnemon
from mnemon.security.manager import TenantSecurityConfig
m = Mnemon(
tenant_id="my_company",
security_config=TenantSecurityConfig(
tenant_id="my_company",
blocked_categories=["pii", "medical_records"],
encrypt_privileged=True,
),
enable_watchdog=True,
enable_telemetry=True,
)
Fail-Safe Design
Mnemon never crashes the system it serves.
- Memory retrieval fails → agent runs without context
- EME fails →
generation_fncalled directly - Bus fails → agent continues unmonitored
- Database unavailable → in-memory fallback mode
All failures are logged, never raised.
Framework Adapters
mnemon.init() auto-detects CrewAI if it's installed. For manual control:
from mnemon.adapters.crewai import CrewAIAdapter
m = Mnemon(tenant_id="my_company", adapter=CrewAIAdapter())
Write your own by subclassing TemplateAdapter:
from mnemon.core.eme import TemplateAdapter
class MyAdapter(TemplateAdapter):
def decompose(self, template): ...
def reconstruct(self, segments): ...
def extract_signature(self, template, goal): ...
Issues Filed — Problems Mnemon Solves
Documented on the frameworks themselves:
- CrewAI #4415 — context pollution and DB write contention
- Dify #32306 — redundant reasoning tax in agent nodes
- Kimi CLI #1058 — context saturation in 100-agent swarms
- E2B #1207 — environmental amnesia in sandboxes
License
MIT — free to use, free to build on.
Project details
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 mnemon_ai-1.0.5.tar.gz.
File metadata
- Download URL: mnemon_ai-1.0.5.tar.gz
- Upload date:
- Size: 113.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d8e9def02602a40b825c545a7aad52f8244c89dee8dd8b7b5a68e4ac8fbd2fe
|
|
| MD5 |
8330f014aec905e6c13c9839153aefad
|
|
| BLAKE2b-256 |
7b77cc7913154d82234a91bf3e8718aaea4d4388d6de12f395ff7ff497889c4f
|
File details
Details for the file mnemon_ai-1.0.5-py3-none-any.whl.
File metadata
- Download URL: mnemon_ai-1.0.5-py3-none-any.whl
- Upload date:
- Size: 121.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5dd3020f616c3188da40b401201c70e27d95f1e817b58af2e387b00d158833d4
|
|
| MD5 |
91c99772b4450127c1f1e121a1f89618
|
|
| BLAKE2b-256 |
4d945ef3bcb6849448979c092b5d9fd004d3b2819f253fab1bcf61cbd45b9e6c
|