Skip to main content

OmniMemory — a namespaced, structured memory service for Claude Code and other agents

Project description

OmniMemory

A structured, namespaced memory service for Claude Code and other agents. Agents push raw conversation turns to /ingest and pull context-scoped memory from /retrieve. The work that builds memory (extraction, verification, cascade, reconstruction) runs in the background on a cheap construction model — off the answer model's critical path — while memory is stored as several decoupled, single-purpose indices plus a dependency-rule engine, not one consolidated note.

On the MeME benchmark (six memory tasks × two domains, 100 episodes, opus-judged), OmniMemory scores 84.9% vs. 73.8% for Claude Code's built-in consolidate-over-notes memory (AutoDream) — +11 points, leading on five of six tasks, with the largest gaps on Deletion (+30), Tracking (+17), Absence (+13), and Cascade. See docs/paper/OmniMemory_vs_AutoDream.md.

   Claude Code ──hooks──▶ omni CLI ─┐
               ──MCP────▶ omni mcp ─┤ HTTP :11435
                                    ▼
                            OmniMemory (FastAPI)
            OmniEngine ──▶ construction model (local gemma · your Claude
                    │        Code Sonnet · or deepseek-chat) — background
                    ▼
            ~/.omni/<client_id>/<namespace>/
              state · history · deletions · rules · pages · raw

Install

pip install omni-agent-memory      # distribution name; the import/CLI is `omni`

Quickstart — replace AutoDream in Claude Code

# 1) run the local memory sidecar (FastAPI on 127.0.0.1:11435)
omni serve

# 2) pick a construction model (the work kept OFF your answer-model latency):
#    a) your existing Claude Code subscription's Sonnet — no extra API key, no metered cost:
export OMNI_EXTRACT_MODEL=claude-code/sonnet OMNI_VERIFY_MODEL=claude-code/sonnet
#    b) free + fully local (Ollama):   OMNI_EXTRACT_MODEL=gemma4-ctx32k
#    c) cheap cloud:                    OMNI_EXTRACT_MODEL=deepseek-chat   (needs DEEPSEEK_API_KEY)

# 3) wire a repo with one command (idempotent): merges hooks into .claude/settings.json
#    and writes .mcp.json
omni install-hooks --project .

That installs the standard Claude Code wiring:

// .claude/settings.json
{ "hooks": {
    "SessionStart":     [{ "hooks": [{ "type": "command", "command": "omni retrieve --session-start" }]}],
    "UserPromptSubmit": [{ "hooks": [{ "type": "command", "command": "omni ingest" }]}],
    "Stop":             [{ "hooks": [{ "type": "command", "command": "omni ingest" }]}]
}}
// .mcp.json
{ "mcpServers": { "omni": { "command": "omni", "args": ["mcp"] } } }

Capture is deterministic (hooks push every turn to /ingest, which returns immediately; construction runs in the background). Recall is a SessionStart seed plus the MCP tools memory_search(query) / memory_note(text). Memory is per-project by default (namespace = project dir, client = claude-code).

A hosted OmniMemory Online Service (zero local setup; point the same hooks at a managed endpoint) is on the roadmap.

Why structured memory

A long-horizon agent's memory must do more than retrieve similar text — MeME formalizes six tasks, each a distinct failure mode, and OmniMemory gives each a purpose-built store:

Task Needs OmniMemory store
ER Exact Recall verbatim fact raw/ archive + state.json
Agg Aggregation combine scattered facts list entities + pages
Tr Tracking full revision history history.jsonl + chains.json
Del Deletion recognize removals, withhold old value deletions.json tombstones
Cas Cascade propagate a stated dependency rules.json + cascade-to-fixpoint
Abs Absence admit uncertainty when no replacement rules with null → uncertain

The dependency-rule engine is what most distinguishes it: when the user states "if my X changes, my Y becomes Z" (or "my Y depends on my X"), OmniMemory records a rule and, when the trigger later changes, deduces the new value (Cascade) or flags uncertainty (Absence) — answers that a consolidated note cannot preserve. Strip the rule engine out and Cascade collapses from 88% to 2%.

Code map

File Role
omni/engine.py OmniEngine: ingest → background EXTRACT/RELATE → debounced VERIFY → CASCADE → RECONSTRUCT → retrieve
omni/storage.py Per-namespace on-disk stores (raw / state / history / deletions / rules / pages / vectors)
omni/server.py FastAPI HTTP service + /ui inspector
omni/cli.py omni CLI (hook client + install-hooks + serve/mcp)
omni/mcp_server.py MCP stdio server — memory_search / memory_note
omni/llm.py, omni/prompts.py, omni/config.py model routing, memory-op prompts, env config

HTTP API (quick check)

curl -s localhost:11435/health
curl -s -X POST localhost:11435/ingest  -H 'Content-Type: application/json' \
  -d '{"client_id":"alice","namespace":"proj","turns":[{"role":"user","content":"My medication is Quelmithin."}],"timestamp":"2023/03/17"}'
curl -s -X POST localhost:11435/retrieve -H 'Content-Type: application/json' \
  -d '{"client_id":"alice","namespace":"proj","query":"medication","mode":"search"}'

client_id is required and partitions storage as ~/.omni/<client_id>/<namespace>/. A built-in memory inspector is at http://127.0.0.1:11435/ — an action log of every EXTRACT/RELATE/VERIFY call (request, response, applied writes) plus the current snapshot.

Configuration (env vars)

Var Default Meaning
OMNI_STORAGE_ROOT ~/.omni Storage root (<client_id>/<namespace>/)
OMNI_CLIENT_ID claude-code Default client id for the CLI/MCP clients
OMNI_HOST / OMNI_PORT 127.0.0.1 / 11435 HTTP bind
OMNI_EXTRACT_MODEL / OMNI_VERIFY_MODEL gemma4-ctx32k Construction tier — gemma4-ctx32k (local), claude-code/sonnet, or deepseek-chat
OMNI_ANSWER_MODEL claude-code Optional engine-side answer ensemble
OMNI_VECTOR_ENABLED 1 Vector sub-paths (needs nomic-embed-text via Ollama)
OMNI_VERIFY_DEBOUNCE_SECONDS 20 Idle window before background VERIFY

For a fully-local construction tier via Ollama (note: the OpenAI /v1 path runs Ollama at a baked-in context, so use a large-context variant):

ollama pull gemma4:e4b
printf 'FROM gemma4:e4b\nPARAMETER num_ctx 32768\n' > /tmp/Modelfile.ctx32k
ollama create gemma4-ctx32k -f /tmp/Modelfile.ctx32k
ollama pull nomic-embed-text          # embeddings, if OMNI_VECTOR_ENABLED=1

Documentation

License

Apache-2.0.

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

omni_agent_memory-0.1.1.tar.gz (53.4 kB view details)

Uploaded Source

Built Distribution

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

omni_agent_memory-0.1.1-py3-none-any.whl (48.1 kB view details)

Uploaded Python 3

File details

Details for the file omni_agent_memory-0.1.1.tar.gz.

File metadata

  • Download URL: omni_agent_memory-0.1.1.tar.gz
  • Upload date:
  • Size: 53.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for omni_agent_memory-0.1.1.tar.gz
Algorithm Hash digest
SHA256 85676c857a1b4b170649815c39f793460d8162868fe853fedbc57f8011191a4b
MD5 d537bebb7cc7714982a9e15b388c4799
BLAKE2b-256 ca198b8754aa51f91e83404d0604d752dea2ddf3da6e1e9de010f17f4fc62782

See more details on using hashes here.

File details

Details for the file omni_agent_memory-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for omni_agent_memory-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 89be186746e98a5b9f8495c8b7225d1e48dcfc6343b10032b3fa1e8c62205a7a
MD5 a2fe20fe9fd7792bfffd7ec6571e6d1d
BLAKE2b-256 befd453835c1b0a410fdd8703c099312c2f01591a1bd81286f47580b96cabe06

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