attestari-langchain
LangChain integration for Attestari — the auditable memory layer for AI agents.
Two pieces, both built on stable langchain-core primitives, so instead of
replaying a raw chat transcript your chain stores facts with provenance —
bi-temporal recall, a tamper-evident audit trail, and a signed deletion
certificate, on plain Postgres or zero-dependency in memory:
AttestariRetriever(BaseRetriever) — recall a subject's relevant facts asDocuments, each carrying provenance in its metadata (fact id, source episode, valid-from, confidence). Supports bi-temporalas_ofrecall. The idiomatic way to inject long-term memory into an LCEL / RAG chain or an agent tool.AttestariChatMessageHistory(BaseChatMessageHistory) — a drop-in history forRunnableWithMessageHistory: it learns facts from each human turn (not a raw transcript, and never from the assistant's own words), surfaces the subject's known facts as a system message, and mapsclear()to Attestari's provable deletion (forget).
Install
pip install attestari-langchain # pulls in attestari + langchain-core
Use — inject memory into a chain (AttestariRetriever)
from attestari import Memory
from attestari_langchain import AttestariRetriever
mem = Memory() # or Memory.local() / Memory.postgres()
mem.add("Hi, I'm Alice. I live in Toronto.", subject_id="user_42")
retriever = AttestariRetriever(
mem=mem, # the Attestari engine
subject_id="user_42", # an opaque pseudonym, not raw PII
k=5, # facts to recall
# as_of="2022-01-01", # optional: recall what was true then
)
docs = retriever.invoke("where does the user live?")
# -> [Document("user_42 lives in Toronto", metadata={fact_id, source_episode_id, score, ...})]
The zero-dependency default extractor understands first-person statements ("I live in…", "my name is…"). For arbitrary third-person text, install
attestari[anthropic]and setANTHROPIC_API_KEYfor Claude-powered extraction.
Drop retriever into any LCEL chain the way you would any other retriever; each
returned Document carries provenance in .metadata you can show or audit.
Use — conversational memory (AttestariChatMessageHistory)
from attestari import Memory
from attestari_langchain import AttestariChatMessageHistory
from langchain_core.messages import HumanMessage
history = AttestariChatMessageHistory(mem=Memory(), subject_id="user_42")
history.add_messages([HumanMessage("Hi, I'm Alice and I live in Toronto.")])
history.messages # -> [SystemMessage("Known facts about the user:\n- user lives_in Toronto")]
history.clear() # provable deletion (forget) for this subject
Wire it into RunnableWithMessageHistory as the get_session_history factory:
from langchain_core.runnables.history import RunnableWithMessageHistory
chain_with_memory = RunnableWithMessageHistory(
chain,
lambda session_id: AttestariChatMessageHistory(mem=Memory.local(), subject_id=session_id),
input_messages_key="input",
history_messages_key="history",
)
Constructor reference
AttestariRetriever
| Field | Default | Purpose |
|---|---|---|
mem |
— | The Attestari engine: Memory(), Memory.local(), or Memory.postgres(). |
subject_id |
None |
Scope recall to one subject (opaque pseudonym). |
k |
5 |
How many facts to recall. |
as_of |
None |
Bi-temporal instant — recall what was true as_of this ISO date. |
AttestariChatMessageHistory(mem, subject_id) — add_messages(msgs) ingests each
human turn (assistant messages are conversation, not testimony — they are not
attributed to the user as facts), messages returns the subject's live facts as one system message, and
clear() maps to provable deletion.
A runnable, no-LLM example is in example.py:
python clients/langchain/example.py.
Apache-2.0.
Metadata
Release files for attestari-langchain 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| attestari_langchain-0.0.1.tar.gz | 5.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| attestari_langchain-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.3 kB
Release files / attestari_langchain-0.0.1.tar.gz
| Download URL | attestari_langchain-0.0.1.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
536d18a3fa08f26218d676155b971461e757d0b8d261aeb2276b42e3352cb037
|
|
BLAKE2b-256 checksum How to use checksums |
e4e2796cd5cd3f8034965d8518189112f7bf002b79a337a5cb21314d376b4e02
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / attestari_langchain-0.0.1-py3-none-any.whl
| Download URL | attestari_langchain-0.0.1-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bd7d3d3edb0ba0df6214169eafd8f8c4d7eeafa9b835592c0962f30256184101
|
|
BLAKE2b-256 checksum How to use checksums |
37142904412e58297199eeca0d9822765788897bcc833c1062f50fbbb72ee76d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|