This release is a pre-release and may not be stable for production use.
harborrag-memory
Scope-aware memory shared by chat and agent orchestration in
HarborRAG. This package owns the memory facade;
storage lives in harborrag-adapters and the contracts live in harborrag-core.
It is a required dependency of harborrag-runtime, so any HarborRAG install already has it.
pip install harborrag-memory
Three tiers, one facade
| Tier | Holds | Lifetime |
|---|---|---|
| Short-term | conversation turns | the session |
| Working | per-run scratch state | the run, bounded by a TTL |
| Long-term | durable memories in a repository | until deleted |
MemoryManager is the single facade chat and agent code imports. Each tier is optional -
pass only the ones you configured, and calling into an unconfigured tier raises
MemoryConfigurationError.
Everything is scoped by MemoryOwner
Every public operation takes a MemoryOwner: the isolation key a memory is written under,
or the identity a query is issued as.
from harborrag_memory import MemoryOwner
owner = MemoryOwner(
tenant_id="tenant-1",
project_id="handbook",
principal_id="user-1",
session_id="session-1",
run_id="run-1",
)
How much of that owner is load-bearing depends on the memory's MemoryScope:
| Scope | Owner fields that must match |
|---|---|
GLOBAL |
none |
TENANT |
tenant_id |
PROJECT |
tenant_id, project_id |
USER |
tenant_id, principal_id |
SESSION |
tenant_id, principal_id, session_id |
RUN |
every field through run_id |
Security rule. Build the owner from authenticated request context. Never pass user-supplied owner fields through - doing so lets a caller read another tenant's, project's, or user's memory.
snapshot()enforces this by rejecting a query whose owner does not match the authenticated caller.
Worked example
import asyncio
from harborrag_memory import (
InMemoryWorkingMemoryStore,
MemoryManager,
MemoryOwner,
WorkingMemory,
)
async def main() -> None:
owner = MemoryOwner(
tenant_id="tenant-1",
principal_id="user-1",
session_id="session-1",
run_id="run-1",
)
memory = MemoryManager(working=WorkingMemory(InMemoryWorkingMemoryStore()))
await memory.update(owner, {"step": "retrieval", "candidates": 12})
print(await memory.scratch(owner)) # {'step': 'retrieval', 'candidates': 12}
snapshot = await memory.snapshot(owner) # recent turns + working state + memories
print(snapshot.working_state)
asyncio.run(main())
Facade surface
| Tier | Methods |
|---|---|
| Short-term | recent(owner, limit=...), append(owner, turn), clear(owner) |
| Working | scratch(owner), update(owner, state, ttl_seconds=...), clear_working(owner) |
| Long-term | save(caller, memory), get(caller, memory_id), search(caller, query), delete(caller, memory_id) |
| Combined | snapshot(owner, query=..., recent_limit=...) |
Module ownership
tiers/short_term.py- conversation history facade.tiers/working.py- per-run scratch state facade and local store.tiers/long_term.py- canonical repository facade for durable memory.manager.py-MemoryManager, the single facade chat and agent import.schemas.py- stable re-exports of the core-owned memory contracts.config.py-MemoryManagerConfig, including the default recent-turn limit.errors.py-MemoryError,MemoryConfigurationError,MemoryScopeError.
Development
Tests for this package live in packages/harborrag-memory/tests/. Run them from the
repository root:
uv run pytest packages/harborrag-memory/tests
Licensed under the Apache License 2.0.
Release files for harborrag-memory 2.0.0a1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| harborrag_memory-2.0.0a1.tar.gz | 13.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| harborrag_memory-2.0.0a1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.4 kB
Release files / harborrag_memory-2.0.0a1.tar.gz
| Download URL | harborrag_memory-2.0.0a1.tar.gz |
|---|---|
| Size | 13.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d09e97006ab02371558799c05a6473de36d27292cfc7be0ba402ca489ea9812c
|
|
BLAKE2b-256 checksum How to use checksums |
49833df603b5d5cb1531010740467b5f21f0d31168571bef173383f6f3b530f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 10, 2026.
Transparency logRelease files / harborrag_memory-2.0.0a1-py3-none-any.whl
| Download URL | harborrag_memory-2.0.0a1-py3-none-any.whl |
|---|---|
| Size | 13.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f569dba26211b3a00a304078bf012a73e6135c5a368ff230d5fae794ab7a6b3e
|
|
BLAKE2b-256 checksum How to use checksums |
827b4061bed3c9f39b7789dd9796ce967dad64d6045e5b1d42e6e368edf3507c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 10, 2026.
Transparency log