Skip to main content

Pluggable memory system with hierarchical recall, FTS search, and multiple backend support.

Project description

orcakit-harness-memory

CI PyPI version Python versions License: MIT

Pluggable memory system for LLM agents — hierarchical memory tree with full-text search and multiple backend support.

Features

  • Memory Tree — Hierarchical summaries (root → branch → leaf) for long-term recall
  • Full-Text Search — FTS5/BM25 powered search across conversations and memories
  • Conversation Records — Standardized chat history storage and retrieval
  • Pluggable Backends — SQLite (default, zero-dep), PostgreSQL, Qdrant
  • Zero Dependencies — Core package uses only Python stdlib + sqlite3
  • Namespace Isolation — Multiple agents share one database safely

Installation

pip install orcakit-harness-memory

Optional backends:

pip install "orcakit-harness-memory[postgres]"   # PostgreSQL backend
pip install "orcakit-harness-memory[qdrant]"     # Qdrant vector backend

Quickstart

from harness_memory import Memory

# Create with default SQLite backend
memory = Memory(namespace="my-agent")

# Store a memory
memory.store("User prefers Python over Java", topic="preferences")

# Recall relevant memories
results = memory.recall("programming language")
for node in results:
    print(f"[{node.topic}] {node.content}")

# Add a conversation record
from harness_memory import ConversationRecord, Message
from datetime import datetime, timezone

record = ConversationRecord(
    id="conv-001",
    thread_id="thread-1",
    user="alice",
    started_at=datetime.now(timezone.utc),
    ended_at=datetime.now(timezone.utc),
    messages=[
        Message(role="user", content="How do I use memory?", timestamp=datetime.now(timezone.utc)),
        Message(role="assistant", content="Just call memory.store()!", timestamp=datetime.now(timezone.utc)),
    ],
    summary=None,
    metadata={},
)
memory.add_conversation(record)

# Search conversations
hits = memory.search("memory")
for hit in hits:
    print(f"[{hit.role}] {hit.message_content}")

Backend Configuration

# SQLite (default) — zero dependencies
memory = Memory(namespace="agent", backend="sqlite")
memory = Memory(namespace="agent", backend_config={"db_path": "/data/memory.db"})

# PostgreSQL — requires [postgres] extra
memory = Memory(namespace="agent", backend="postgres", backend_config={
    "dsn": "postgresql://user:pass@localhost/memdb"
})

# Qdrant — requires [qdrant] extra
memory = Memory(namespace="agent", backend="qdrant", backend_config={
    "url": "http://localhost:6333"
})

# Custom backend — pass any MemoryBackend instance
memory = Memory(namespace="agent", backend=my_custom_backend)

API Reference

Memory

Method Description
store(content, topic=None) Store a memory as a leaf node
recall(query, limit=5) Recall relevant memories via FTS
add_conversation(record) Persist a conversation record
search(query, limit=10) Full-text search across messages
list_conversations(**filters) List conversations with filters
get_conversation(id) Get full conversation by ID
get_tree() Get the complete memory tree

Data Types

  • MemoryNode — A node in the memory tree (root/branch/leaf)
  • ConversationRecord — Complete conversation with messages
  • Message — Single message (user/assistant/tool)
  • SearchResult — FTS search hit with score
  • ConversationSummary — Lightweight conversation listing

Development

make dev          # Install dev dependencies
make lint         # Ruff check + format check
make typecheck    # mypy strict
make test         # pytest
make all          # lint + typecheck + test

License

MIT

Project details


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.1.1.tar.gz (85.0 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.1.1-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: harness_memory-0.1.1.tar.gz
  • Upload date:
  • Size: 85.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for harness_memory-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5595ffb1834f974f2a0419c27dd1417493a7beaafab160524c2eba450c321d4f
MD5 03f2d4d7ca244f5711c12b3ab882e7dd
BLAKE2b-256 eb3508cd72d998e872712be086de93e32581ca4d5ee63ff6ec3fa97133bba49b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: harness_memory-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for harness_memory-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d4f6dc250a718f7817f9cde9a8fe674c82daf6547d8b6c05d79267b3ab964107
MD5 42fdb3c18330f76ee19790ded21af43f
BLAKE2b-256 479ba4da6331debf43b913fd41a0de6511e55888a0f863c9e6be810cc6b134e5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page