Skip to main content

loci

Typed long-term memory for AI agents. One core, two adapters.

The name comes from the method of loci — the memory palace technique: every recollection gets a place and a structure. That is the thesis of this project.

An agent that forgets you every session is a search box with manners. This is the layer that fixes that: durable facts about a person, typed and ranked, extracted from the conversation rather than typed into a settings page, consolidated daily so the list does not rot.

Ported from the memory system running in production in Lima, rewritten host-agnostic.

What it does

Eight categories (routine, study, preferences, finance, goals, relationships, constraints, ephemeral), four importance tiers, a status lifecycle. A preference and a deadline are not the same kind of thing and do not age the same way.

Extraction runs on two paths. A model reads the exchange for meaning; regex heuristics catch the phrasings you wrote them for. Merged with model precedence. When the provider is down the regex path still runs.

A write filter keeps the store from becoming a mood diary. Passing mood is the case it exists for — "tired today" is true for hours and wrong for months.

The injection cap keeps context from growing without bound. Twelve facts reach the model, ranked by importance and then by deadline proximity and recency.

Daily consolidation and decay keep the list honest. Exact duplicates merge; guesses nobody confirmed expire on their own; ephemeral facts carry a 24-hour TTL; completed goals expire after 90 days.

The two adapters, and why they differ

MCP server Hermes plugin
Runs in Any MCP client Hermes only
Tools remember, recall, forget the same three
Automatic extraction no yes
Context injection on request before every call

MCP is request and response. Nothing calls a server when a turn ends, so there is no moment for it to read the exchange on its own — through MCP the agent has to call remember on purpose. Automatic extraction needs a hook in the host, and Hermes has one (post_llm_call). Same core underneath; the Hermes adapter just has somewhere to stand.

Install

pip install -e .            # the core
pip install -e '.[mcp]'     # plus the MCP server

MCP client config (after pip install loci[mcp]):

{
  "mcpServers": {
    "loci": {
      "command": "python",
      "args": ["-m", "loci.adapters.mcp_server.server"]
    }
  }
}

Hermes:

hermes plugins install <you>/loci
hermes plugins enable loci

The store is a SQLite file at ~/.loci/memory.db, overridable with LOCI_DB. No server to run, because a memory layer that needs one is not installable.

Use it directly

from loci import Store, extract, should_persist, context_block

store = Store()
for memory in extract("eu prefiro respostas curtas", assistant_text=reply):
    if should_persist(memory):
        store.upsert(memory)

system_prompt += "\n\n" + context_block(store.active())

Where changes go

This repo owns the shape of a memory and its lifecycle. It does not own:

Thing Owner
Model calls, API keys, provider SDKs your app — inject a ModelExtractor
The agent loop, tool dispatch, sessions the host (Hermes, OpenClaw, Claude Code)
Scheduling the daily jobs the host's cron, s6 or systemd
Transport and auth the adapter

The core imports nothing but the standard library. If a change here would make that untrue, it belongs in an adapter.

Tests

pytest -q

92 tests against a real SQLite store on a temp file. Nothing of ours is mocked: a memory layer whose tests pass against a fake store tells you nothing about the one people run.

License

MIT.

Metadata

Release files for mowave-loci 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mowave-loci 0.1.0
File Size Uploaded
mowave_loci-0.1.0.tar.gz 30.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mowave-loci 0.1.0
File Interpreter ABI Platform
mowave_loci-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 57.4 kB

Release files / mowave_loci-0.1.0.tar.gz

Download URL mowave_loci-0.1.0.tar.gz
Size 30.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ec4c3843e261e0fc610bd70be56a278f62287429a79850ecda61b16b724244b9
BLAKE2b-256 checksum
How to use checksums
c0f5137f400dce47b32a97ad448a2130a945677dca8bd7aac5cfbd5885b8fe5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / mowave_loci-0.1.0-py3-none-any.whl

Download URL mowave_loci-0.1.0-py3-none-any.whl
Size 27.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a3017461e1ed5a605444038a547fd77f4d455a6c0834290f943aa59336285819
BLAKE2b-256 checksum
How to use checksums
ba146c6813b294594e576dbfb7f9f0f8a4aec443a3b9f35bff14deb4afc8edd1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page