Skip to main content

🌙 luminary-memory

A lightweight, self-hosted memory layer for AI agents.

PyPI version Python License CI Tests Coverage Stars

Self-hosted · Private · Budget-aware · Self-maintaining


Why luminary-memory

Agents are only as good as what they remember. A stateless agent re-learns the same context every session — paying the same tokens, making the same mistakes. luminary-memory closes that gap with a local memory store that persists between runs, retrieves the right context on demand, and keeps itself tidy over time.

What your agent remembers is what it becomes.

Value proposition

  • Self-hosted and private — all data stays on your machine. No cloud dependency, no API keys to leak, no per-token memory cost.
  • Four retrieval strategies in one recall — semantic (embeddings), keyword (FTS5), temporal (recency × access), and graph (entity co-occurrence) run in parallel and fuse into a single ranked result via Reciprocal Rank Fusion.
  • Zero hard dependencies — the default backend is SQLite + FTS5 (standard library). Embeddings run locally on CPU via ONNX. Ingesting and recalling memories in minutes.
  • Budget-aware by design — results are deduplicated (Jaccard) and truncated to a configurable token budget, so memory injection never blows up your agent's context window.
  • Self-maintaining — a built-in lifecycle handles TTL expiry, near-duplicate consolidation, and low-value pruning, so the store stays lean without manual cleanup.
  • Scales when you do — a pluggable backend lets you move from SQLite to pgvector without changing your code.

Hermes Agent — first-class memory provider

luminary-memory ships a native Hermes Agent memory provider (luminary-memory[hermes]): drop-in, auto-recall every turn, auto-save every session — with zero LLM tokens per turn.

pip install "luminary-memory[hermes]"

Enable it in your Hermes config.yaml:

memory:
  provider: luminary

That's it. From the next session:

  • 🌙 Auto-recall — relevant memories are retrieved in the background and injected into agent context every turn
  • 💾 Auto-save — completed turns are persisted automatically; session boundaries flush buffered turns
  • 🛠️ Explicit tools — the model can call luminary_recall / luminary_ingest / luminary_list on demand
  • 📋 Deterministic indicator — a 🌙 Luminary — recalled N memories status line surfaces memory use

Registers via the standard hermes_agent.memory_providers entry point — no Hermes source changes, no cloud, no LLM API keys. See docs/hermes-integration.md for the full configuration table.

LLM memory curation (optional): set ingest_llm: true in ~/.hermes/luminary/config.json (plus llm_base_url / llm_model / llm_api_key) to have the provider evaluate every turn before saving — chit-chat and trivial turns are dropped, and kept turns are stored as concise factual summaries (e.g. "Deploy target is the staging cluster.") instead of raw User: ... / Assistant: ... transcripts. One small LLM call per retained turn; any OpenAI-compatible endpoint works.

LLM store maintenance (optional): set auto_maintain: true in the same config file to have the provider review the store at every session end — the LLM keeps current facts, updates changed ones, and deletes stale, contradicted, or duplicate memories, so the store never accumulates outdated or redundant facts.


Quickstart

Install

pip install luminary-memory

Python API

from luminary_memory import MemoryClient

client = MemoryClient(db_path="memory.db")

# store a durable fact
client.ingest("The deploy target is the staging cluster", tags=["deploy", "infra"])

# recall — four strategies fused into one ranked answer
result = client.recall("where do we deploy?")
for memory, score in zip(result.memories, result.scores):
    print(f"{score:.3f}  {memory.content}")
# → 0.942  The deploy target is the staging cluster

# maintain the store (TTL cleanup + consolidation + pruning)
client.run_lifecycle()

client.close()

CLI

luminary-memory add "The deploy target is the staging cluster" --tags deploy
luminary-memory recall "where do we deploy?" --json
luminary-memory search "postgresql"
luminary-memory list
luminary-memory lifecycle
luminary-memory stats

How recall works

Four retrieval strategies run in parallel, then fuse into one ranked result:

Strategy What it finds Backend
Semantic Meaning, paraphrase, synonyms ONNX embeddings (384-dim, CPU)
Keyword Exact names, APIs, identifiers FTS5 BM25 (SQLite) / ILIKE (pgvector)
Temporal Recent, frequently-accessed facts Decay curve × access count
Graph Entity co-occurrence, indirect links entities / relations tables

Fusion pipeline: 4 strategies → RRF fusion (k=60) → Jaccard dedup (0.85) → token budget (4096)


Backends

SQLite + FTS5 (default) PostgreSQL + pgvector
Dependencies stdlib + FTS5 PostgreSQL + pgvector extension
Vector search In-process cosine HNSW-ready (<=> operator)
Best for Single-user, edge, <100k memories Scale, concurrent access
Setup Zero-config Running Postgres + LUMINARY_PG_DSN

Switch backends with one setting:

from luminary_memory import MemoryClient
from luminary_memory.config import Settings

client = MemoryClient(settings=Settings(
    backend="pgvector",
    pg_dsn="postgresql://user:pass@localhost/memdb",
))

Configuration

Every setting can be set via a LUMINARY_* environment variable or passed as a Settings object.

Setting Env var Default
backend LUMINARY_BACKEND sqlite
db_path LUMINARY_DB_PATH luminary_memory.db
pg_dsn LUMINARY_PG_DSN postgresql://localhost/luminary_memory
embedding_model LUMINARY_EMBEDDING_MODEL BAAI/bge-small-en-v1.5
embedding_dim LUMINARY_EMBEDDING_DIM 384
ingest_whitelist LUMINARY_INGEST_WHITELIST [] (regex patterns)
ingest_llm LUMINARY_INGEST_LLM false
rrf_k LUMINARY_RRF_K 60
dedup_jaccard_threshold LUMINARY_DEDUP_JACCARD_THRESHOLD 0.85
token_budget LUMINARY_TOKEN_BUDGET 4096
ttl_default_seconds LUMINARY_TTL_DEFAULT_SECONDS null
prune_min_importance LUMINARY_PRUNE_MIN_IMPORTANCE 0.2
consolidate_jaccard_threshold LUMINARY_CONSOLIDATE_JACCARD_THRESHOLD 0.9

Use cases

  • AI coding agents — retain architecture decisions, API choices, and error fixes across sessions.
  • Chatbots & assistants — remember user preferences, history, and conversation context.
  • Automation pipelines — persist execution state, task outcomes, and learned parameters.
  • Personal knowledge & local RAG — a private second brain with zero cloud involvement.

Architecture

ingest(text) ──► whitelist filter ──► (LLM enrich, optional) ──► embed ──► backend
                                                                          │
recall(query) ──► 4 strategies (semantic·keyword·temporal·graph)
               ──► RRF fusion ──► Jaccard dedup ──► token budget ──► ranked results
                                                                          │
lifecycle() ──► cleanup (TTL) ──► consolidate (near-dupes) ──► prune (low-value)

Hermes integration

A ready-to-use skill lives in hermes/SKILL.md: install it, then the agent can ingest durable facts on tool calls, recall context into its system prompt, and schedule lifecycle maintenance via cron. See docs/hermes-integration.md.


Development

git clone https://github.com/alertxsto/luminary-memory.git
cd luminary-memory
pip install -e ".[dev]"

python -m pytest          # run tests
python -m ruff check src tests   # lint

Contributions welcome — see CONTRIBUTING.md.


Documentation

Roadmap

See ROADMAP.md for the full product roadmap — v0.2.2 (LLM memory curation & maintenance), v0.3.0 (intelligence), and v1.0.0 (stable).


License

Apache-2.0 © 2026 Dwiky Candra

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

luminary_memory-0.2.3.tar.gz (135.2 kB view details)

Uploaded Source

Built Distribution

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

luminary_memory-0.2.3-py3-none-any.whl (55.2 kB view details)

Uploaded Python 3

File details

Details for the file luminary_memory-0.2.3.tar.gz.

File metadata

  • Download URL: luminary_memory-0.2.3.tar.gz
  • Upload date:
  • Size: 135.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for luminary_memory-0.2.3.tar.gz
Algorithm Hash digest
SHA256 5ed5bc4ba15dd5a9d9a63ab88fb1dae649a1ac745ee76a577e3c9d701aa86e00
MD5 aedf04cbbdabb87493c26e75e9b587d3
BLAKE2b-256 7f2fdd4b63aa885f1f5a89184febb93e602d934b4a04ad46733203b61d12ffb1

See more details on using hashes here.

Provenance

The following attestation bundles were made for luminary_memory-0.2.3.tar.gz:

Publisher: publish.yml on alertxsto/luminary-memory

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

File details

Details for the file luminary_memory-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: luminary_memory-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 55.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for luminary_memory-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1db1f5f94f4fc38bf45df8eb9bdd1f4faad9f26b84fc82932b8745219f554c1a
MD5 a94bdf1c9745858b5922ac236d6ec167
BLAKE2b-256 5221efbeec8c1c2c2f86f5dda8a9616861f3551fe08e6a8d7d5ea394b92229b3

See more details on using hashes here.

Provenance

The following attestation bundles were made for luminary_memory-0.2.3-py3-none-any.whl:

Publisher: publish.yml on alertxsto/luminary-memory

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 Sentry Error logging StatusPage Status page