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
  • 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.3.tar.gz (82.6 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.3-py3-none-any.whl (88.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mnemon_ai-1.0.3.tar.gz
  • Upload date:
  • Size: 82.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mnemon_ai-1.0.3.tar.gz
Algorithm Hash digest
SHA256 1f0706efba8db82d1fcc65386ccefb614043e3cc99ed89b6e37d9b5cd33d4dbf
MD5 2e6338c4c05672453e3e6723ddd0307d
BLAKE2b-256 fc1d7f2f18cdf6e44be8aa99bf7dbb7c2cf9c2542e64a28cd35f8f1b37f0f79e

See more details on using hashes here.

Provenance

The following attestation bundles were made for mnemon_ai-1.0.3.tar.gz:

Publisher: publish.yml on smartass-4ever/Mnemon

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: mnemon_ai-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 88.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mnemon_ai-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 14f51be730f051c00fc8c4f129351be1d1c8f061c71997a4e2d0c2f922f2882a
MD5 a60911b6d03ed61117cf9f1fe7d7b803
BLAKE2b-256 adf122317f3c44f893aec85338d4bdbcff5e12d781e79b33f95c21f3c1e17d02

See more details on using hashes here.

Provenance

The following attestation bundles were made for mnemon_ai-1.0.3-py3-none-any.whl:

Publisher: publish.yml on smartass-4ever/Mnemon

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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