Skip to main content

The intelligence layer between your agents and oblivion

Project description

Mnemon

Mnemon

The intelligence layer between your agents and oblivion.


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.


Three Components

mnemon.memory — Cognitive Memory System

Five-layer stratified memory with protein bond activation retrieval and conditional intent drone curation.

  • 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: two-part — protein bond pattern assembly (zero LLM, ~15ms) followed by conditional intent drone (only above memory pool threshold).

mnemon.cache — Execution Memory Engine (EME)

Generalised execution template cache for any expensive recurring computation.

  • System 1 — exact fingerprint match → zero LLM, sub-millisecond
  • System 2 — partial segment match → gap fill with windowed context
  • Fragment library — 49 pre-warmed proven segments, grows with use

Ships with pre-warmed fragment library from 42 real enterprise workflow runs

  • Works for agent plans, RAG pipelines, data pipelines, any structured workflow

mnemon.bus — Two-Tier Experience Bus

Tier 1 — system learning loop, always on, no agents needed. Records outcomes, detects patterns, feeds EME and memory.

Tier 2 — agent intelligence layer. PAD health monitoring (Pleasure/Arousal/Dominance), knowledge propagation (collective immunity), atomic belief registry (shared truth for swarms).


Quick Start

pip install mnemon-ai

Includes out of the box:

  • sentence-transformers — real 384-dim semantic embeddings (~85%+ retrieval precision)
  • cryptography — Fernet AES-128 encryption for sensitive memory
  • anthropic — LLM routing, auto-activated when ANTHROPIC_API_KEY is set
import asyncio
from mnemon import Mnemon

async def main():
    async with Mnemon(tenant_id="my_company", agent_id="agent_01") as m:

        # Remember something
        await m.remember("Acme Corp prefers formal PDF reports")
        await m.learn_fact("acme_contact", "Sarah K")

        # Recall relevant memories
        context = await m.recall("weekly security audit for Acme Corp")

        # Run with full execution caching
        result = await m.run(
            goal="weekly security audit for Acme Corp",
            inputs={"client": "Acme Corp", "week": "March 17-21"},
            generation_fn=my_expensive_planning_function,
        )

        print(f"Cache level:  {result['cache_level']}")
        print(f"Tokens saved: {result['tokens_saved']}")
        print(f"Latency:      {result['latency_ms']:.0f}ms")

asyncio.run(main())

Connect Your LLM

Set one environment variable. Mnemon detects it automatically — no code changes needed.

# Anthropic — Claude (claude-haiku for routing, claude-sonnet for generation)
pip install mnemon-ai[anthropic]
export ANTHROPIC_API_KEY=sk-ant-...

# OpenAI — GPT (gpt-4o-mini for routing, gpt-4o for generation)
pip install mnemon-ai[openai]
export OPENAI_API_KEY=sk-...

# Google — Gemini (gemini-flash for routing, gemini-pro for generation)
pip install mnemon-ai[google]
export GOOGLE_API_KEY=AIza...

# Groq — Llama3 (free tier available — no credit card needed)
pip install mnemon-ai[groq]
export GROQ_API_KEY=gsk_...

Mnemon checks keys in that order and picks the first one it finds. No configuration beyond setting the key.

# No llm_client= argument needed — auto-detected from environment
async with Mnemon(tenant_id="my_company", agent_id="agent_01") as m:
    ...

Or pass explicitly if you prefer:

from mnemon.llm.client import AnthropicClient, OpenAIClient, GoogleClient, GroqClient

m = Mnemon(tenant_id="x", llm_client=GroqClient())  # free tier

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,
)

Framework Adapters

from mnemon.adapters.crewai import CrewAIAdapter
from mnemon.adapters.letta import LettaAdapter

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): ...

Production Features

from mnemon import Mnemon
from mnemon.security.manager import TenantSecurityConfig

m = Mnemon(
    tenant_id="my_company",
    # Security — blocks PII, encrypts privileged content
    security_config=TenantSecurityConfig(
        tenant_id="my_company",
        blocked_categories=["pii", "medical_records"],
        encrypt_privileged=True,
    ),
    # Observability — health checks, self-healing, metrics
    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_fn called directly
  • Bus fails → agent continues unmonitored
  • Database unavailable → in-memory fallback mode
  • All failures logged, never raised

Architecture

Any AI system
      ↓ adapter translates
┌──────────────────────────────────────────┐
│  EME      Execution Memory Engine        │  S1 → S2 → generation
│  Memory   Five-layer cognitive memory    │  protein bonds → intent drone
│  Bus      Two-tier experience bus        │  Tier 1 always / Tier 2 for agents
└──────────────────────────────────────────┘
           ↓
    SQLite (local) / Redis (scale)

Package Structure

mnemon/
├── core/
│   ├── models.py        ← all shared dataclasses and enums
│   ├── persistence.py   ← SQLite + inverted index + migrations
│   ├── memory.py        ← five-layer memory + protein bonds + drone
│   ├── eme.py           ← execution memory engine S1/S2
│   └── bus.py           ← two-tier experience bus + PAD
├── adapters/
│   ├── crewai.py        ← CrewAI adapter
│   └── letta.py         ← Letta/MemGPT adapter
├── llm/
│   └── client.py        ← Anthropic, OpenAI, Mock clients + auto_client()
├── security/
│   └── manager.py       ← content filtering, encryption, isolation
├── observability/
│   ├── watchdog.py      ← health checks, self-healing, alerts
│   └── telemetry.py     ← structured metrics
├── eval/
│   └── harness.py       ← eval suite with scoring
├── fragments/
│   └── library.py       ← 49 pre-warmed execution fragments
└── cli/
    └── main.py          ← mnemon init/eval/health/stats

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
  • Letta RFC — heartbeat contention and sleep-time compute integration

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

mnemon_ai-1.0.4.tar.gz (128.2 kB view details)

Uploaded Source

Built Distribution

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

mnemon_ai-1.0.4-py3-none-any.whl (136.3 kB view details)

Uploaded Python 3

File details

Details for the file mnemon_ai-1.0.4.tar.gz.

File metadata

  • Download URL: mnemon_ai-1.0.4.tar.gz
  • Upload date:
  • Size: 128.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.3

File hashes

Hashes for mnemon_ai-1.0.4.tar.gz
Algorithm Hash digest
SHA256 b06c7742c91864fc76aa067ae1fb9af6f6f695f7deb806c844c5ed5b5d47c74d
MD5 27e8b942dc10f64a39672b10752b1158
BLAKE2b-256 4cbf704f8f4ac680bf1834fcf3ae632d0f02d7cae17eff64d795bf9ed6d67a4a

See more details on using hashes here.

File details

Details for the file mnemon_ai-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: mnemon_ai-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 136.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.3

File hashes

Hashes for mnemon_ai-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 95a34742c444c93a2932c5c9e0b881c38c9c1459d8d9c6bf3ac7e74f3a816af7
MD5 d00f3b626534c3f26c0f99cfdc020fc3
BLAKE2b-256 6aa659bd7554f9727bb56637298241295f4a787ca0f335d93c071e0a2720c58e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page