Intelligent, token-optimized memory stack for AI agents
Project description
OpenMemX: The Intelligent Memory Stack for AI Agents
Beyond Vector RAG. OpenMemX is a token-optimized cognitive layer for autonomous agents, implementing hierarchical abstraction, Bayesian surprise-driven forgetting, and multi-hop reasoning.
🧠 The Theory: Why OpenMemX?
Most AI agents suffer from the "Memory Wall": their context windows fill up with redundant information, leading to high latency and "forgetfulness." OpenMemX solves this through three pillars:
1. Bayesian Surprise-Driven Forgetting
Instead of a simple "Last In, First Out" (LRU) buffer, OpenMemX calculates the informational novelty of every interaction.
- High Surprise: Stored in episodic memory and promoted to the semantic knowledge graph.
- Low Surprise: Summarized or pruned to save tokens.
2. Hierarchical Semantic Abstraction (H-MEM)
- Episodic (SQLite/LanceDB): Fast, temporal log of recent events.
- Semantic (Knowledge Graph): Crystallized facts and relationships (GraphRAG) for multi-hop reasoning (e.g., "How does delay X impact goal Y?").
- Archival (Git): "Time-travel" versioning of your agent's entire world-view.
3. Faithful Prompt Compression (LLMLingua-2)
Using bidirectional BERT-based extractive compression, OpenMemX reduces prompt size by 20-40% without losing semantic coherence, effectively doubling your agent's virtual context window.
📈 Performance Benchmarks
| Metric | Vector RAG (Standard) | OpenMemX (Optimized) |
|---|---|---|
| Token Density | 1.0x (Raw) | 1.4x - 2.0x (Compressed) |
| Reasoning Depth | Single-hop only | Multi-hop (Graph Traversal) |
| Search Speed | Fast (Vector) | Ultra-Fast (LanceDB Zero-Copy) |
| Versioning | None | Git-backed (Commits/Diffs) |
🚀 Installation & Setup
1. Install the Core Engine
Open a terminal and run:
pip install openmemx
2. Connect Your Agents (Grounding)
OpenMemX works by connecting to your favorite AI tools. Choose your agent below to set up its "Brain":
💎 Gemini CLI (Automated)
Run this command to automatically configure your Gemini sessions:
openmemx instruct --gemini
Restart your Gemini terminal and type /openmemx_system_init to begin.
☁️ Claude Desktop (Automated)
Run this command to add OpenMemX to Claude's toolbelt:
openmemx instruct --claude
Restart Claude, click the paper icon (Prompts), and select openmemx_system_init.
🦀 OpenClaw (Automated)
Run this command to add OpenMemX to OpenClaw/Moltbot:
openmemx instruct --openclaw
Restart OpenClaw and trigger the openmemx_system_init prompt via your agent's interface.
🤖 Nanobot (Manual Skill Setup)
Nanobot uses a "Skills" system. To add OpenMemX:
- Locate your Nanobot workspace: (Usually
~/.nanobot/workspace/) - Copy the OpenMemX Skill:
mkdir -p ~/.nanobot/workspace/skills cp -r .agent/skills/openmemx ~/.nanobot/workspace/skills/
- Use it: Simply tell Nanobot: "Use the OpenMemX skill to manage my memory."
🏗️ Generic / Other Agents
If your agent supports MCP (Model Context Protocol), point it to:
Command: python -m openmemx.mcp_server
📅 The "Daily Standup" (Universal Monitoring)
OpenMemX is now a Universal Activity Monitor. It can read logs from Nanobot, Gemini, and OpenClaw to give you a bird's-eye view of your productivity.
How to use it:
- Initialize Patterns: Run
openmemx instructat least once to set up your global config. - Ask your Agent: "Give me a global activity report for the last 24 hours."
- View Results: Your agent will aggregate actions from across your entire system, even if they happened in different tools or folders.
🛠 Management CLI
# Ingest your existing notes/markdown files
openmemx migrate my_notes.md --conversation_id "research_project"
# Reset your local configuration
openmemx instruct
# Manage automatic memory logging
openmemx auto-ingest --status # See if it's currently recording
openmemx auto-ingest --enable # Start recording everything automatically
openmemx auto-ingest --disable # Stop recording
openmemx auto-ingest --new-conversation # Start a fresh conversation session
🤖 AI Agent Use Cases
1. The Coding Assistant
Use openmemx migrate to ingest your existing project documentation or Obsidian dev-notes. The agent gains a permanent, vectorized understanding of your coding style.
2. Personal Assistant (OpenClaw / Moltbot)
OpenMemX is the perfect companion for OpenClaw (Moltbot).
- Persistence: Your memories survive restarts.
- Sync: Use the Git layer to sync your agent's memory across multiple devices.
- Efficiency: Keep your local LLM snappy by compressing long chat histories.
Auto-Ingest & Project-Aware Memory (NEW)
OpenMemX is now context-aware. It automatically manages sessions based on your current working directory, allowing you to "resume" memory context simply by navigating to a project folder.
1. Project-Aware Sessions
- Automatic Context: When you run OpenMemX in
/projects/backend, it loads that specific project's memory history. - Seamless Resumption: Switch folders, and your agent switches context automatically.
- Registry System: Keeps track of which Conversation ID belongs to which directory.
2. Auto-Ingest
- Zero-Friction: Your queries to
retrieve_memoryare automatically logged. - Smart Logging: Use
configure_auto_ingestto toggle query/response logging preferences.
3. Global Awareness (The "Daily Standup")
Even with isolated project memories, your agent maintains a global view.
get_recent_activity: This tool returns a summary of all interactions across all projects from the last 24 hours.- Use Case: Ask your agent "What did I work on yesterday?" and it will aggregate context from your backend, frontend, and infrastructure projects into a single report.
MCP Tools:
Core Memory Operations:
ingest_interaction- Store a new interaction in episodic memory with Bayesian Surprise scoringretrieve_memory- Semantic search across all conversation historyconsolidate_memory- Trigger "sleep cycle" to identify high-surprise items and prune low-surprise noise
Knowledge Graph (GraphRAG):
add_knowledge_node- Add entities to the semantic knowledge graphadd_knowledge_edge- Create relationships between entitiestraverse_knowledge_graph- Multi-hop reasoning over crystallized facts
Prompt Optimization:
compress_prompt- Reduce prompt size using LLMLingua-2 (20-40% compression)snapshot_memory- Create Git-backed version checkpoint
Auto-Ingest & Sessions:
get_recent_activity- Global report of actions across all project directorieslog_interaction- Quick logging without managing conversation IDsconfigure_auto_ingest- Customize auto-ingest behaviorget_auto_ingest_status- Check current configurationstart_new_conversation- Force a fresh conversation thread for the current project
🧩 Architecture Details
- Location: All memory data is stored in the
~/.openmemxdirectory (persistent across sessions). - Python 3.10+ (Optimized for Apple Silicon & NVIDIA RTX)
- Model Context Protocol (MCP) v1.0
- Extractive Pruning: LLMLingua-2
- Vector Engine: LanceDB (In-Process)
📜 License & Research
OpenMemX is based on the research report: Computational Architectures for Efficient Long-Term Memory in Localized Agentic Systems. See the doc/ folder for the full whitepaper.
Project details
Release history Release notifications | RSS feed
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 openmemx-1.0.1.tar.gz.
File metadata
- Download URL: openmemx-1.0.1.tar.gz
- Upload date:
- Size: 24.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca61e91c5d96830c7d95fd7a795a564b3aa25ddfd9a3b5c5a442bc6c5882b647
|
|
| MD5 |
e76cc7ae83f9a6503256a9294a00c67a
|
|
| BLAKE2b-256 |
31110e5c14374bc9f2a130d200190f241222ee33e7625216990389e0b84b7cac
|
File details
Details for the file openmemx-1.0.1-py3-none-any.whl.
File metadata
- Download URL: openmemx-1.0.1-py3-none-any.whl
- Upload date:
- Size: 21.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7bc378b0db74dbd1fff1cd90428fd316a6305d9f4fe327cc323a52c7191e1479
|
|
| MD5 |
972947f80d7e2d4005fc8fcc7ae63372
|
|
| BLAKE2b-256 |
e4abb6c1a09fff51ca0185f6243f4e27ad2ebe7bac9193dddad29928c874e32f
|