Skip to main content

Harness Memory Banner

A memory-tree based memory system — tiered recall, pluggable storage, and memory that migrates to OpenClaw / Hermes and beyond.

Python 3.11+ License: MIT PyPI version Code Style: Ruff GitHub stars

Highlights · Overview · Core Technology · Features · Quick Start · Contents

English · 中文


Harness Memory is a pluggable long-term memory system for LLM agents, built around the memory tree model — a hierarchy of root → branch → leaf nodes. It does not talk to an LLM itself; it is a storage-and-recall layer any agent can drop in. What makes it special is portability: the storage backend is abstracted behind a MemoryBackend Protocol, and first-class host adapters let the same memory travel to other agents such as OpenClaw and Hermes.

Harness Memory's design goal: memory is a portable asset, not a lock-in. Capture it once, recall it anywhere — including in a different agent framework.

✨ Highlights

Feature Description
🌳 Memory tree Hierarchical root → branch → leaf nodes for organized recall
🧩 Portable by design MemoryBackend Protocol makes storage swappable
🔄 Agent-agnostic Drop into any agent; OpenClaw & Hermes adapters ship in-box
🚚 Cross-agent migration Pack to .hmpkg, adopt into OpenClaw / Hermes / another agent
🔍 Recall pipeline M4 pipeline: parse → route → gather → rerank → diversify → suppress → budget → render
💾 Pluggable storage SQLite + FTS5 by default; PostgreSQL / Chroma / Qdrant optional
🪶 Zero core deps stdlib + sqlite3; extras add the rest
🧠 Tiered distillation L0 raw → L1 candidate → L2 atom → L3 entity

📌 Overview

A fact is recorded canonically as an AtomCard (L2) grouped under an Entity (L3). The memory tree is a lightweight index over those atoms: root and branch nodes hold directory-style labels, and each leaf points at an atom — its content is projected from the atom at read time, so there is never a second copy of the fact to drift out of sync. Recall walks the tree and surfaces the linked leaves most relevant to a query.

Because storage sits behind a Protocol, the same Memory object can run on a local SQLite file, a Postgres database, or a vector index — and because host adapters exist for OpenClaw and Hermes, the memory you build in one agent can be adopted by another.

🧠 Core Technology

Layer Technology
Language Python 3.11+
Core deps None — stdlib + sqlite3
Model MemoryNode tree + AtomCard
Recall M4 pipeline (pipeline/recall/)
Storage MemoryBackend Protocol — SQLite/FTS5, Postgres, vector (Chroma/Qdrant)
Host adapters adapters/bridge/ host bridge for OpenClaw & Hermes
LangGraph Optional checkpointer (SQLite / Postgres)
Build / quality hatchling · ruff · mypy · pytest

🧰 Features

Memory tree

  • root → branch → leaf hierarchy; leaves reference atoms, content is projected on read.
  • Tiered distillation: L0 raw event → L1 candidate → L2 AtomCardL3 entity page (plus an L2.5 episode/diary layer).

Recall

  • recall_for_prompt(memory, query) returns result.rendered + result.snippets.
  • M4 pipeline routes the query, gathers candidates, reranks, diversifies, suppresses noise, and budgets tokens before rendering.

Pluggable backends

  • Default: SQLite + FTS5 (full-text search).
  • Optional: PostgreSQL ([postgres]), ChromaDB ([chroma]), Qdrant ([qdrant]), local embeddings ([embeddings]), and a LangGraph checkpointer ([langgraph]).

Portability — OpenClaw & Hermes

  • MemoryBackend Protocol keeps storage swappable, so the engine is agent-agnostic.
  • adapters/bridge/ is a shared JSON-RPC bridge reused by OpenClaw; in-process hosts call the same application/runtime.py through MemoryService.
  • plugins/openclaw/ ships a TypeScript shell (harnessmemory); plugins/hermes/ ships a Python plugin — both build on the same bridge.
  • CLI: harness-memory openclaw ... and harness-memory hermes ... manage the integration.

Cross-agent migration

operations/migration/portable/ packs memory into a .hmpkg and adopts it into a target host:

harness-memory portable list-sources                            # discover migratable stores
harness-memory portable pack  --from agent:my-agent --out my-agent.hmpkg
harness-memory portable adopt my-agent.hmpkg --as openclaw
harness-memory portable doctor --host openclaw --compare-with my-agent.hmpkg

adopt resolves the target store and namespace for OpenClaw, Hermes, another agent, or a plain harnessmemory backend — for OpenClaw it defaults to the namespace the installed plugin actually reads (from openclaw.json); override with --as openclaw:<namespace>. Imports are idempotent, back up the target db first, and can rewrite the host field (--host-rewrite target).

🚀 Quick Start

Prerequisites

  • Python 3.11+

1. Install

pip install harness-memory                       # core (SQLite + FTS5)
pip install "harness-memory[postgres]"           # PostgreSQL backend
pip install "harness-memory[chroma,embeddings]"  # vector index + embeddings
pip install "harness-memory[langgraph]"          # LangGraph checkpointer
pip install "harness-memory[cli]"                # CLI (incl. openclaw / hermes)

2. Store & recall

from harness_memory import Memory
from harness_memory.pipeline.recall import recall_for_prompt

m = Memory(namespace="my-agent")  # defaults to ~/.harness-memory/session.sqlite
m.store("User prefers Python over Java", topic="preferences")

# Recall is FTS-based (no stemming) — query with words that appear in the memory.
result = recall_for_prompt(m, "Python preference")
print(result.rendered)

3. Use with another agent

# OpenClaw — wire the plugin slot, then bring your memory along
harness-memory openclaw setup
harness-memory portable adopt my-agent.hmpkg --as openclaw

# Hermes
harness-memory hermes install
harness-memory portable adopt my-agent.hmpkg --as hermes

📑 Contents

🏗️ Architecture

harness_memory/
 ├─ core.py                 Memory facade + backend factory
 ├─ service.py              in-process adapter over application runtime
 ├─ application/            MemoryRuntime, config, host files, path projection
 ├─ pipeline/               extractor · promotion · page · episode · recall · lifecycle
 ├─ storage/                MemoryBackend Protocol · sqlite · postgres · vector
 ├─ ports/                  LLMClient protocol and clients
 ├─ adapters/               bridge · CLI · dashboard
 └─ operations/migration/   export/import/rename/portable pack → .hmpkg → adopt

📖 CLI reference

Command Description
harness-memory openclaw setup / doctor / uninstall / print-config Manage the OpenClaw integration
harness-memory hermes install / doctor Manage the Hermes integration
harness-memory portable list-sources Discover migratable memory stores on this machine
harness-memory portable pack --from <host:name> Export memory to a .hmpkg
harness-memory portable adopt <pkg> --as <host[:ns]> Import a .hmpkg into a target host
harness-memory portable doctor --host <host[:ns]> Health-check the target store, optionally comparing counts with a .hmpkg
harness-memory recall "<query>" Run the recall pipeline from the terminal
harness-memory atom / entity / raw / candidate ... Inspect and maintain the individual memory layers
harness-memory dashboard Launch the local web dashboard ([dashboard] extra)

Every group supports --help; global options --backend, --db, and --namespace select the store.

🛠️ Development

Prerequisites: Python 3.11+, uv

make install          # uv sync --group dev
make all              # lint + typecheck + test

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Run make all before submitting
  4. Open a Pull Request

🔗 Related projects

Project Description
harness-agent Agent runtime that consumes the memory
harness-browser Browser automation for memory-backed agents
harness-gateway Multi-platform IM channel bridge
Octop The self-hosted assistant that composes the Harness stack

📄 License

This project is licensed under the MIT License.

Download files

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

Source Distribution

harness_memory-0.9.3.tar.gz (932.8 kB view details)

Uploaded Source

Built Distribution

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

harness_memory-0.9.3-py3-none-any.whl (316.1 kB view details)

Uploaded Python 3

File details

Details for the file harness_memory-0.9.3.tar.gz.

File metadata

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

File hashes

Hashes for harness_memory-0.9.3.tar.gz
Algorithm Hash digest
SHA256 cb7549113e026b5b33b9734836ea71fcc40a3495a96080a35f4286a3f1b5314c
MD5 6ac1fdab569c965011969fbae76f59fd
BLAKE2b-256 fc3e220f5d35f1fe1d9f1ba06abac33d71f9a85a388552f37d8bbf76ee71c62c

See more details on using hashes here.

File details

Details for the file harness_memory-0.9.3-py3-none-any.whl.

File metadata

  • Download URL: harness_memory-0.9.3-py3-none-any.whl
  • Upload date:
  • Size: 316.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for harness_memory-0.9.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d7831c5bd5e7b9267de93cb34700867f67869fb847e56f43dca79a297ebf3919
MD5 6eade02ee513f7b52ac49ee00bbc338f
BLAKE2b-256 55d20e730fe11180f11f25e95d6fad3ebfdda859c22479cb59e457cf623e4023

See more details on using hashes here.

Release history Release notifications | RSS feed

0.9.9

2 files

0.9.8

2 files

0.9.7

2 files

0.9.6

2 files

0.9.5

2 files

0.9.4

2 files

This release

0.9.3 This release

2 files

0.9.2

2 files

0.9.1

2 files

0.9.0

2 files

0.8.5

2 files

0.8.4

2 files

0.8.3

2 files

0.8.2

2 files

0.8.1

2 files

0.8.0

2 files

0.7.0

2 files

0.2.0

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 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