Universal AI agent memory layer — vault + palace + temporal knowledge graph
Project description
OMPA
Obsidian-MemPalace-Agnostic — Universal AI agent memory layer
OMPA gives any AI agent persistent memory with vault conventions, palace navigation, and a temporal knowledge graph.
Credits & Attribution
This project is a synthesis of ideas and code from the AI agent memory community:
- MemPalace by Kyle Corbitt — The palace metaphor (wings/rooms/drawers), temporal knowledge graph design, and verbatim storage approach. MemPalace proved 96.6% R@5 on LongMemEval with raw verbatim storage.
- obsidian-mind — Vault structure (brain/work/org/perf), wikilink conventions, frontmatter validation, and session lifecycle patterns.
- Claude Code / Anthropic — Hook patterns and agent-tool interaction models.
- OpenClaw — Framework-agnostic agent runtime that inspired the "universal" design goal.
OMPA combines these into a framework-agnostic package that works with any AI agent runtime.
The Problem
Every AI agent starts empty every session. Important decisions get lost. Context grows expensive. ANKI prompts only get you so far.
The Solution
OMPA gives any AI agent — Claude Code, OpenClaw, Codex, Gemini CLI, or any custom agent — persistent, structured memory that:
- Never forgets a decision (vault + knowledge graph)
- Knows where things belong (15 message types with routing hints)
- Survives context compaction (verbatim storage, no summarization loss)
- Works offline (local sentence-transformers, zero API cost)
Quick Start
pip install ompa
ao init
ao status
That's it -- you have a vault with persistent memory. Now use it in a session:
ao session-start # ~2K token context injection
ao classify "We decided to go with Postgres" # Route to right folder
ao search "authentication decisions" # Semantic search
ao kg-query Kai # Query the knowledge graph
ao wrap-up # Session summary + save to vault
How It Works
Three-Layer Memory Architecture
┌─────────────────────────────────────────────────────────┐
│ Layer 1: Vault (human-navigable markdown) │
│ brain/ work/ org/ perf/ ← obsidian-mind structure │
├─────────────────────────────────────────────────────────┤
│ Layer 2: Palace (agent-accessible metadata) │
│ wings → rooms → drawers (vault file references) │
│ halls: facts, events, discoveries, preferences │
│ tunnels: cross-wing connections │
├─────────────────────────────────────────────────────────┤
│ Layer 3: Knowledge Graph (temporal triples) │
│ SQLite: subject → predicate → object + validity window │
│ Query entity history at any point in time │
└─────────────────────────────────────────────────────────┘
5 Lifecycle Hooks
| Hook | Tokens | When |
|---|---|---|
session_start |
~2K | Session begins |
user_message |
~100 | Each user message |
post_tool |
~200 | After each tool call |
pre_compact |
~100 | Before context compaction |
stop |
~500 | Session ends |
15 Message Types
DECISION, INCIDENT, WIN, LOSS, BLOCKER, QUESTION, SUGGESTION, REVIEW, BUG, FEATURE, LEARN, RETROSPECTIVE, ALERT, STATUS, CHORE — each with routing hints that automatically file things in the right place.
Semantic Search (Zero API Cost)
Uses sentence-transformers (all-MiniLM-L6-v2) locally. No OpenAI/Anthropic API calls for search.
Architecture
ompa/
├── core.py # Ompa main class
├── vault.py # Vault management (brain/work/org/perf)
├── palace.py # Palace metadata (wings/rooms/drawers)
├── knowledge_graph.py # Temporal KG (SQLite triples)
├── hooks.py # 5 lifecycle hooks
├── classifier.py # 15 message types
├── semantic.py # Local semantic search
├── mcp_server.py # MCP protocol server (14 tools)
└── cli.py # CLI commands
MCP Server (15 Tools)
Works with Claude Desktop, Cursor, Windsurf natively:
# Claude Desktop
claude mcp add ompa -- python -m ompa.mcp_server
Tools: ao_session_start, ao_classify, ao_search, ao_kg_query, ao_kg_add, ao_palace_wings, ao_palace_rooms, ao_palace_tunnel, ao_validate, ao_wrap_up, ao_status, ao_orphans, ao_init, ao_search, ao_stop
Python API
from ompa import Ompa
ao = Ompa(vault_path="./workspace")
# Lifecycle
result = ao.session_start() # Returns ~2K token context injection
hint = ao.handle_message("We won the enterprise deal!")
ao.post_tool("write", {"file_path": "work/active/auth.md"})
ao.stop()
# Search
results = ao.search("authentication decisions", wing="Orion")
# Knowledge Graph
ao.kg.add_triple("Kai", "works_on", "Orion", valid_from="2025-06-01")
triples = ao.kg.query_entity("Kai")
timeline = ao.kg.timeline("Orion")
# Palace
ao.palace.create_wing("Orion", type="project")
ao.palace.create_tunnel("Kai", "Orion", "auth-migration")
traversal = ao.palace.traverse("Orion", "auth-migration")
CLI Commands
ao init ao status ao session-start ao classify
ao search ao orphans ao wrap-up ao wings
ao rooms ao tunnel ao kg-query ao kg-timeline
ao kg-stats ao validate ao rebuild-index
Framework Agnostic
Unlike MemPalace (Claude Code + MCP only) or obsidian-mind (Claude Code hooks only), OMPA works with any AI agent:
| Agent | Integration |
|---|---|
| OpenClaw | Python API or MCP server |
| Claude Code | Python API or MCP server |
| Codex | Python API or MCP server |
| Gemini CLI | Python API or MCP server |
| Custom agent | Python API |
Installation
pip install ompa # Core only
pip install ompa[all] # All dependencies including sentence-transformers
Requires Python 3.10+.
Why "Agnostic"?
Because memory should not be coupled to your agent framework. Build once, use anywhere. The "Universal" angle is the moat — not just another Claude Code plugin.
Comparison
| Feature | OMPA | MemPalace | obsidian-mind |
|---|---|---|---|
| Framework | Any | Claude Code | Claude Code |
| Memory type | Vault + Palace + KG | Palace + KG | Vault only |
| Semantic search | Local (free) | ChromaDB API | QMD (paid) |
| Temporal KG | SQLite ✓ | SQLite ✓ | ✗ |
| MCP server | 15 tools | 15 tools | ✗ |
| CLI | 14 commands | ✗ | ✗ |
| Hooks | 5 lifecycle | 3 lifecycle | 3 lifecycle |
| Message types | 15 | 15 | 5 |
| Verbatim storage | ✓ | ✓ | ✗ |
| Multi-agent | ✓ | ✗ | ✗ |
License
MIT — Micap AI
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 ompa-0.4.0.tar.gz.
File metadata
- Download URL: ompa-0.4.0.tar.gz
- Upload date:
- Size: 48.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49ff2468bcd60f6424a1eaf9af841170c1dab485f87be147daab0f1122fd6515
|
|
| MD5 |
ee627c99788a330bb505a11d9cb7b70a
|
|
| BLAKE2b-256 |
25a68d11c96f385d6a3ad69dfdada2fa08f8480154676f6646fc66aee1553c2e
|
Provenance
The following attestation bundles were made for ompa-0.4.0.tar.gz:
Publisher:
ci.yml on jmiaie/ompa
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ompa-0.4.0.tar.gz -
Subject digest:
49ff2468bcd60f6424a1eaf9af841170c1dab485f87be147daab0f1122fd6515 - Sigstore transparency entry: 1276555048
- Sigstore integration time:
-
Permalink:
jmiaie/ompa@611044292860481633570d840e649c18d79d8c74 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/jmiaie
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@611044292860481633570d840e649c18d79d8c74 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ompa-0.4.0-py3-none-any.whl.
File metadata
- Download URL: ompa-0.4.0-py3-none-any.whl
- Upload date:
- Size: 45.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d20af39683bc688a266c395be83be77270e587cad391bac41fc286ffb7276bc0
|
|
| MD5 |
ddab2ac7b77bea12490ba95ac35c7fe8
|
|
| BLAKE2b-256 |
84f25ff0f2e4b72b25013fe3f5101e5a3d860a00cd2bff640d7f13750ee2203f
|
Provenance
The following attestation bundles were made for ompa-0.4.0-py3-none-any.whl:
Publisher:
ci.yml on jmiaie/ompa
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ompa-0.4.0-py3-none-any.whl -
Subject digest:
d20af39683bc688a266c395be83be77270e587cad391bac41fc286ffb7276bc0 - Sigstore transparency entry: 1276555122
- Sigstore integration time:
-
Permalink:
jmiaie/ompa@611044292860481633570d840e649c18d79d8c74 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/jmiaie
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@611044292860481633570d840e649c18d79d8c74 -
Trigger Event:
push
-
Statement type: