memoryd

What an agent remembered, searchable by meaning.

One fact per file, one embedding per fact, and a search that answers "how was it with the frost protection" with the note that says "coolant down to -25 °C" — even though the word frost never appears in it. Served over MCP, like tasksd and skilld.

memoryd                 # stdio, JSON-RPC per line
memoryd --http 8795     # Streamable HTTP, so every host uses the same store

Storage

One JSON file per memory under $MEMORYDIR (default $XDG_DATA_HOME/memoryd, else ~/.local/share/memoryd):

{
  "id": "m00001",
  "scope": "van/technik",
  "text": "Der Frostschutz steht auf -25 Grad, aufgefüllt wird G12+ blau.",
  "tags": "kühlmittel",
  "source": "konrad",
  "model": "nomic-embed-text",
  "created": 1794147600,
  "embedding": [0.0428, 0.0418, ...]
}

Readable, diffable, backupable without a database. A scope is a free string and selects itself plus its children, so van covers van/technik — the same rule as tasksd.

Tools

tool what it is for
memory_add store one fact: text (required), scope, tags, source
memory_search meaning-based search with scores; scope and limit optional
memory_list what exists in a scope, newest first
memory_get one memory in full
memory_update correct a fact (re-embeds the new text)
memory_delete remove what is wrong or obsolete
memory_scopes which scopes exist, how many memories each

Knowledge bases — a wiki next to the memories

A knowledge base is a named collection of pages. Same mechanics as a memory (title, text, embedding, searchable by meaning), different purpose: memories are what an agent picked up along the way, a knowledge base is what a human wrote down to be read again.

$MEMORYDIR/kb/<slug>/kb.json      {"name","slug","description","created"}
$MEMORYDIR/kb/<slug>/e00001.json  {"id","title","text","tags","source",
                                   "created","updated","model","embedding",
                                   "history":[{"text","updated"}]}
tool what it is for
kb_create a base per subject area (olivia-technik, fleet-junction); "Olivia Technik" becomes the slug olivia-technik
kb_list which bases exist, how many pages, what they are for
kb_write a page; the same title updates it instead of duplicating
kb_read one page in full, optionally with its earlier versions
kb_search by meaning; without kb it searches all bases and ranks globally
kb_entries what a base already covers
kb_delete one page
kb_drop a whole base — needs confirm="yes", otherwise it only says what would be lost

Two decisions that matter:

  • Same title = update, with history. The previous text moves into history (five versions), and the answer says updated … earlier version kept in history. A wiki that silently overwrites is not a wiki.
  • Search ranks globally across bases unless one is named — the best page wins, not the best page per base.

The embedder

OpenAI-compatible /v1/embeddings, EMBED_URL (default http://127.0.0.1:8091/v1/embeddings), EMBED_MODEL (default nomic-embed-text, 768 dimensions).

It is not required to run. If it does not answer, the memory is stored without a vector and the tool says so (WITHOUT embedding); search then falls back to a case-insensitive substring match and labels the result substring match. A store that silently pretends to understand meaning is worse than one that admits it is matching letters.

What does not belong here

Secrets, keys, passwords, long transcripts. The text is the conclusion, not the raw material — one paragraph that still makes sense to an agent who was not there. A store that keeps everything makes every search worse.

Build and test

make            # C99 + POSIX, no dependency beyond libc, libm, and curl at runtime
make test       # 16 checks against the running service (HTTP + stdio), stub embedder
sudo make install

The suite starts its own embedder stub with deterministic vectors, so it does not depend on a model being loaded on this machine.

S
Description
memoryd (from n95, ~/src/memoryd)
Readme
158 KiB
0 Stars 3 Watchers 0 Forks
Languages
C 75.8%
Python 15.9%
Shell 4.7%
Makefile 3.6%