Skip to content

feat: optional semantic memory search for OpenClaw agents with a local embedding model - #879

Merged
dKaulig merged 6 commits into
mainfrom
feat/openclaw-semantic-memory
Nov 28, 2026
Merged

dKaulig merged 6 commits into
mainfrom
feat/openclaw-semantic-memory

Conversation

@dKaulig

@dKaulig dKaulig commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Problem

An OpenClaw agent finds its notes by keyword only: a note about "Ferien an der Ostsee" is not found by asking for "Urlaub am Meer". OpenClaw can search by meaning with a local embedding model, but AgentPier compiled no embedding provider, and left alone OpenClaw's local provider downloads its server and model at run time (AGENTPIER-507).

Result

An optional, installation-wide owner setting under Agents › Runtime: semantic memory search with Google's EmbeddingGemma 300M running locally. Keyword search stays the default; with the setting off every compiled configuration is byte-identical to before. Nothing leaves the machine and no remote provider is offered. Hermes reports the new capability semanticMemory as unavailable and shows nothing.

Provisioning

  • The provider plugin (@openclaw/llama-cpp-provider) joins the runtime lock. The llama.cpp server (four platform archives) and the model (embeddinggemma-300m-qat-Q8_0.gguf, 329 MB) are pinned by digest in runtime-manifest.js.
  • The server (27 MB) is installed with the runtime. The model is downloaded only when the owner turns the setting on: resumable, used only with the pinned digest, stored under <data>/assistants/embeddings/. The dialog names the Gemma Terms of Use.
  • The Gateway never downloads anything: the configuration carries an absolute model path, AgentPier's own server command and fallback: "none".
  • The Linux installer adds libgomp1.

Switching

OpenClaw 2026.11.6 pauses memory_search after any provider change until the index is rebuilt with the Gateway stopped. Every Gateway start therefore reconciles first: a marker records which search the indexes were built for, and on a mismatch or an unfinished rebuild one offline rebuild runs for all agents. Because a rebuild whose local provider cannot start still exits 0 with a keyword-only index, each local rebuild is verified with memory status --deep. The owner is told that running agent work is interrupted.

A failed download or rebuild, a missing asset, or an AgentPier restart in the middle switches the setting off with a reason and rebuilds the keyword indexes. The marker travels with update snapshots and backups.

States

Off, downloading, rebuilding, on, failed and degraded, over the new live topic runtime.semantic-memory. Degraded means the setting is on but keyword search is answering: detected from a size check of the assets on each status read, a full hash of the model once per Gateway start, and from the provider a memory search reports (AgentPier's own searches, a check search when the owner opens the Runtime tab, and at most every ten minutes after an agent's own search). Repair reinstalls, re-downloads only what is missing or changed, restarts and rebuilds.

Decisions and limits

  • Existing installations must first activate the new OpenClaw runtime (same version 2026.11.6, new lock) under OpenClaw updates; until then the setting says so.
  • Turning the setting off deletes the model.
  • A later release that pins another model switches the setting off with a reason rather than re-embedding unasked.
  • There is no cancel during the download.
  • A broken embedding server is noticed at the next search AgentPier sees an answer of, not at the moment it breaks.
  • Rollback to the previous runtime with the setting on is covered by unit tests only.

Measured with two agents and three short notes: server memory 544 MB (macOS arm64, Metal) and 737 MB (Linux arm64, CPU), freed after ten idle minutes; switching on 15–20 s; first search about 3 s, later ones under 40 ms.

Validation

  • New native contract assistant-semantic-memory-contract against the real Gateway and the real model: a German query without shared words and an English query both find the German note, agents stay isolated, a deleted note is gone, switching off restores keyword search, and a stopped server and a corrupted model lead to degraded and back through Repair. Passes on macOS arm64 and in a Linux arm64 container. Linux x64 first runs in this pull request.
  • CI: the contract runs on pull requests that touch the assistant runtime (Linux x64) and nightly (x64 and arm64), with the assets cached per pin. It is not in the merge queue. If the assets cannot be fetched on a cache miss, a pull request that changes this feature fails; any other run gets a warning annotation and runs its other contracts.
  • npm run check: lint, format, structure and build pass; the only failures are three tests in managed-logins.test.js that come from the local shell environment.
  • Full Chromium suite before the degraded state was added: 3633 passed, 13 skipped, 2 failed in unrelated specs (connections-long-list.spec.js:16, file-explorer-accessibility-fix.spec.js:82) that pass alone. The feature's spec passes 10 of 10 in English, including degraded and repair.
  • Existing golden fixtures are unchanged; German and English catalogs updated and confirmed; the ⌘K index has the new entry.

Docs

Updated: README.md, README.de.md, docs/agents.md, docs/assistant-gateway.md (section "Semantic memory search", including what a release's Upgrade notes must say), docs/assistant-memory-qualification.md, docs/assistant-release-qualification.md, docs/assistant-runtime-updates.md, docs/architecture.md (live topic), docs/installation.md, docs/linux.md, docs/backups.md, docs/hermes-runtime.md, docs/adr/0002-managed-openclaw-assistants.md, THIRD_PARTY_NOTICES.md. Checked without change: docs/ui-guide.md, docs/ui-glossary.md, GLOSSARY.md, docs/testing.md, docs/memory.md.

Screenshots of all states were taken locally and are not attached here.

🤖 Generated with Claude Code

dKaulig and others added 6 commits November 28, 2026 02:16
… model

OpenClaw 2026.11.6 serves memory.search.provider "local" through its llama.cpp
provider plugin, which is not bundled and, left to itself, downloads a
llama-server build and the embedding model at run time.

- The plugin (@openclaw/llama-cpp-provider 2026.11.6) joins the runtime lock
  as embeddingPlugin, verified and recorded in the receipt like a search
  plugin. The lock gains one record; nothing else moved.
- The llama.cpp server (release b10809, the build the plugin names, one
  archive per platform) and the model (EmbeddingGemma 300M QAT Q8_0, 329 MB)
  are pinned in the manifest by URL, size and SHA-256.
- embedding-assets.js installs both below <data>/assistants/embeddings: the
  server with every new runtime installation (never failing it), the model
  on demand, through a download that continues a partial file and lands only
  with the pinned digest.
- On Linux the installer adds the OpenMP runtime the server build needs
  (libgomp1) as an optional library.
- Host backups leave the embeddings folder out.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…eddings

Memory search matched words only. The owner can now switch on OpenClaw's
vector search with a local model (EmbeddingGemma 300M through the llama.cpp
provider plugin), for all agents of the shared Gateway at once. Keyword
search stays the default: with the setting off the compiled openclaw.json is
byte for byte the one from before.

OpenClaw pauses an agent's whole memory search once the configuration names
another embedding provider than its index was built with, and rebuilds an
index only while the Gateway is stopped. So:

- The compile names the plugin, an absolute model file and the installed
  server through a start wrapper, with fallback "none": the Gateway never
  downloads anything and nothing leaves loopback.
- Every Gateway start reconciles before the spawn: a marker in the state
  tree says which search the indexes were built for; when it differs from
  what the start compiles, one offline `openclaw memory index --force`
  rebuilds every agent's index, and a rebuild for local embeddings is checked
  with `openclaw memory status --deep`.
- Switching is therefore: prepare the assets, save, restart the Gateway like
  "Restart now". A failed or unverified rebuild, a runtime without the plugin
  (a rollback), a missing asset or an AgentPier restart in the middle switch
  the setting off with a reason and rebuild the keyword indexes, so memory
  search is never left paused.
- The state (off, downloading, rebuilding, on, failed) is pushed over the
  live topic runtime.semantic-memory.
- An embedding server a killed Gateway left behind is stopped by its pid.
- Hermes reports the new capability semanticMemory as unavailable.

A native contract runs it end to end on the pinned Gateway with the real
plugin, server and model: a German note found by a query without a shared
word, agent isolation, a deleted note leaving the index, the way back to
keyword search, and the fallback after a failed and an interrupted rebuild.
It runs in assistant-runtime.yml, with the model cached per pin, not in the
merge queue's core contracts.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Agents › Runtime gets the group "Semantic memory search". It states what the
setting does and costs (a one-time download of the model's size, the same
disk space, about 550 to 750 MB of memory while agents search), follows the
live topic runtime.semantic-memory through every step (downloading with its
bytes, rebuilding with the agents done, on, or off with the reason of a
failure) and switches through a confirmation that says the agent service
restarts, running agent work is interrupted and the model comes under
Google's Gemma Terms of Use. Where it cannot run, the switch is locked with
the reason.

An OpenClaw agent's memory page says when its search works by meaning; a
Hermes agent's page shows nothing and reads nothing (capability
semanticMemory). The group is in the ⌘K search under its German and English
names.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The owner's view in the agents guide, the design in the gateway guide (what
OpenClaw 2026.11.6 does, what AgentPier pins and compiles, the reconcile at
every Gateway start, failure and crash handling, measured cost on macOS and
Linux, limits and what a release's Upgrade notes must say), the contract in
the memory qualification, the lock addition in the release qualification,
updates and rollbacks in the runtime update guide, the live topic in the
architecture guide, the optional libgomp1 in the installation guides, the
backup exclusion, the Hermes gap, an amendment to ADR 0002 and both READMEs.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…runs

Where the semantic memory contract runs, stated correctly (the message of
ea33a2a37 left out that it is Linux only):
- assistant-runtime.yml, native-contracts, on Linux runners only: pull requests
  that touch the assistant runtime (x64), and nightly, on demand and before a
  release through full.yml (x64 and arm64), in the one shard of four that the
  shard list assigns it to;
- not in the merge queue: assistant-runtime-queue.yml names its core contracts
  itself and does not read scripts/assistant-contract-shards.json;
- not on hosted macOS runners (the server computes on Metal there).

The pinned llama.cpp server and embedding model are cached per pin, runner OS
and architecture. On a cache miss scripts/assistant-embedding-assets.mjs fetches
them from GitHub and Hugging Face. If that fails, a pull request that changes
semantic memory search (or whose changes cannot be read) fails; every other run
gets a warning annotation and runs its other contracts without this one, so it
is never a silent pass for a change of the feature and never a blocked merge
for anything else.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…wers

With the indexes built, a local embedding provider that stops working does not
pause the search: OpenClaw 2026.11.6 answers by keyword alone, and the setting
kept reading "on". Of what that version offers, only a memory search's own
result tells (details.provider "none" instead of "local"); memory.status and
doctor.memory.status report the same either way.

The state is now "degraded" with a reason code, pushed over the same live topic:
- the installed server and model are looked at with every status read (stat and
  receipts, no hash); the model is hashed once per Gateway start, and changed
  bytes fall back to keyword search like a failed rebuild;
- a memory search AgentPier issues reports its answer;
- a check search (a query no note answers, per OpenClaw agent with memory) runs
  when the owner opens the Runtime tab, once per Gateway process, and at most
  every ten minutes after an agent's own memory_search ended. Nothing is timed.

"Repair" (PUT with repair: true) installs the server anew, fetches the model if
it is missing or changed, restarts the Gateway and rebuilds and verifies every
index; a failure takes the existing fallback to keyword search.

The native contract breaks the embeddings of a real Gateway, expects degraded,
repairs and expects search by meaning again (run on macOS arm64 and Linux arm64).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@dKaulig
dKaulig added this pull request to the merge queue Nov 28, 2026
Merged via the queue into main with commit 1ff6dde Nov 28, 2026
28 checks passed
@dKaulig
dKaulig deleted the feat/openclaw-semantic-memory branch November 28, 2026 02:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant