Governed, on-prem conversation memory for AI agents: per-thread history and semantic recall, with optional PII masking on write and tamper-evident audit. Zero-dependency SQLite by default.
Project description
thread-recall
Part of the Governed Agent Stack: free, on-prem building blocks for an AI agent you can point at a real database and audit.
Governed, on-prem conversation memory for AI agents. It stores what an agent should remember across turns — per-thread history and optional semantic recall — and makes that memory governable: PII can be masked before it is ever written, and every write can be mirrored into a tamper-evident audit log.
The default backend is SQLite with embeddings as JSON and cosine in Python: zero dependencies, works immediately, nothing leaves the building. A Postgres + pgvector backend (for scale) is the next step; the scoring logic is backend-agnostic so it drops in cleanly.
This is the write-side companion to sql-steward. sql-steward is the read-only query gateway and stays read-only; thread-recall is where agent state lives, kept separate on purpose.
Quickstart
pip install thread-recall
thread-recall demo
from thread_recall import Memory
mem = Memory("agent.db") # or ":memory:"; mask=True / audit=True optional
mem.remember("thread-42", "user", "How much MRR did the pro plan make?", embedding=embed(q))
mem.remember("thread-42", "assistant", "Pro plan MRR was 297.")
mem.recent("thread-42", k=10) # last 10 turns, chronological
mem.search("thread-42", embed("revenue"), k=5) # nearest turns by embedding
Why it's "governed"
- PII masked on write.
Memory(..., mask=True)runs content through pii-veil before it is stored, so raw personal data never lands in the memory store. No-op if pii-veil isn't installed. - Tamper-evident audit.
Memory(..., audit=True)mirrors every write into an agent-blackbox hash-chained ledger, so "what did the agent choose to remember" has a checkable answer. No-op if agent-blackbox isn't installed. - On-prem by default. SQLite file on your disk; embeddings generated by whatever local model you choose. Nothing is sent out.
API
| Method | Purpose |
|---|---|
remember(thread_id, role, content, embedding=None, metadata=None) |
Store a turn (PII-masked first if enabled). Returns its id. |
recent(thread_id, k=10) |
Last k turns, chronological. |
search(thread_id, query_embedding, k=5) |
Semantic recall: nearest turns by cosine over stored embeddings. |
forget(thread_id) |
Delete a thread's memory. |
count(thread_id=None) |
Turn count for a thread, or overall. |
Embeddings are supplied by the caller (generate them with any local model). thread-recall stores and scores them; it does not call out to any embedding service itself.
Roadmap
- Postgres + pgvector backend for scale and native nearest-neighbour (the SQLite backend computes cosine in Python, fine for thread-scoped recall, not for millions of rows).
- A thin LangGraph adapter, to use thread-recall alongside a LangGraph checkpointer.
Develop
git clone https://github.com/Pawansingh3889/thread-recall
cd thread-recall
pip install -e ".[dev]"
pytest -q
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file thread_recall-0.1.0.tar.gz.
File metadata
- Download URL: thread_recall-0.1.0.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7464451e4009643a5bb350c320587dda17548fd61ffdf6aab611197ca96cd256
|
|
| MD5 |
2c4000b41efeab08f241762832fd986a
|
|
| BLAKE2b-256 |
9b4840525f503bcca07e2c62f314e14aac6bcab639d599ddb08639c23586357d
|
Provenance
The following attestation bundles were made for thread_recall-0.1.0.tar.gz:
Publisher:
release.yml on Pawansingh3889/thread-recall
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
thread_recall-0.1.0.tar.gz -
Subject digest:
7464451e4009643a5bb350c320587dda17548fd61ffdf6aab611197ca96cd256 - Sigstore transparency entry: 2103135338
- Sigstore integration time:
-
Permalink:
Pawansingh3889/thread-recall@bab0263464f04e2a1f444c680d73a00eac7d400a -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Pawansingh3889
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bab0263464f04e2a1f444c680d73a00eac7d400a -
Trigger Event:
push
-
Statement type:
File details
Details for the file thread_recall-0.1.0-py3-none-any.whl.
File metadata
- Download URL: thread_recall-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99786c39030b7f3fbda214fdfb8a2ad9bba63ec1983062e9b551c68f9df99d90
|
|
| MD5 |
61221d95f70ae1fc1d5a9510a169dc5a
|
|
| BLAKE2b-256 |
ef30754277ca486cc16c0ef5ec693adf682d2deed0808b69ef7a5ea0c8be531d
|
Provenance
The following attestation bundles were made for thread_recall-0.1.0-py3-none-any.whl:
Publisher:
release.yml on Pawansingh3889/thread-recall
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
thread_recall-0.1.0-py3-none-any.whl -
Subject digest:
99786c39030b7f3fbda214fdfb8a2ad9bba63ec1983062e9b551c68f9df99d90 - Sigstore transparency entry: 2103135706
- Sigstore integration time:
-
Permalink:
Pawansingh3889/thread-recall@bab0263464f04e2a1f444c680d73a00eac7d400a -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Pawansingh3889
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bab0263464f04e2a1f444c680d73a00eac7d400a -
Trigger Event:
push
-
Statement type: