Audit and time-travel for AI agent memory. log, show, blame, diff, revert — callable from inside the agent's reasoning loop.
Project description
memtrail
Audit and time-travel for AI agent memory. A drop-in versioned backend with
log,show,blame,diff, andrevert— callable from inside the agent's reasoning loop.
Install
pip install memtrail
Quickstart
from memtrail import MemTrail
mt = MemTrail("my-agent")
# Commit a fact the agent learned
c1 = mt.commit(
facts=[{"id": "user.tz", "content": "America/Los_Angeles"}],
message="learned user timezone from greeting",
author="agent",
)
# Later, investigate the memory
mt.blame("user.tz") # → which commit introduced this fact?
mt.show(c1.hash) # → full snapshot at that point
mt.log(limit=10) # → recent history
mt.revert(c1.hash) # → roll back to before a bad change
Use as agent tools
memtrail ships tool schemas in two shapes. The schemas describe the same six operations; pick whichever your model provider expects.
from memtrail import MemTrail
from memtrail.tools import anthropic_tools, openai_tools
mt = MemTrail("my-agent")
tools, dispatch = anthropic_tools(mt) # input_schema shape
# or:
tools, dispatch = openai_tools(mt) # function-tool shape
# When the model emits a tool call, route it:
result = dispatch(tool_name, tool_input)
The six tools exposed: memtrail_commit, memtrail_log, memtrail_show,
memtrail_blame, memtrail_diff, memtrail_revert.
CLI
memtrail commit --repo my-agent --fact 'user.tz="PST"' -m "learned tz"
memtrail log --repo my-agent
memtrail show --repo my-agent <commit>
memtrail blame --repo my-agent <fact_id>
memtrail diff --repo my-agent <commit_a> <commit_b>
memtrail revert --repo my-agent <commit>
memtrail facts --repo my-agent # list facts at HEAD
Repo state lives at ~/.memtrail/<repo>.db by default. Override with
--db /path/to.db or the MEMTRAIL_HOME environment variable.
Data model
- Fact:
{id, content, metadata}— the atomic memory unit. Caller-providedids enable targeted blame. - Snapshot: a set of facts at a point in time, content-addressed by SHA-256 of canonical JSON.
- Commit:
{hash, parent_hash, snapshot_hash, author, message, timestamp}— forms an append-only DAG.
commit(facts=...) upserts onto the parent snapshot (matched by id). Use
commit(remove=[...]) to drop facts, or commit_snapshot(facts=...) for full
replace.
Status
v0.1 — alpha. Zero runtime dependencies. Python ≥ 3.9.
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 memtrail-0.1.0.tar.gz.
File metadata
- Download URL: memtrail-0.1.0.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18032ba2add6036afc83e00c0184872af4cd8f8e49350417fdd2a4838fb812a7
|
|
| MD5 |
225e2ec8fe205012806fc2e016411c4e
|
|
| BLAKE2b-256 |
dc8c98e6f1baad3ffd7ff301a76ae601e4dd4e6aa43711d9de6e6fec9285802c
|
File details
Details for the file memtrail-0.1.0-py3-none-any.whl.
File metadata
- Download URL: memtrail-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5280f45727b46884b534429d39b830ab101730a14612e11091edf5b52f68df70
|
|
| MD5 |
2a10e76b6c59e1f624b4e1ccb7741e4a
|
|
| BLAKE2b-256 |
e9da3bf5b2724440f36dd35df22bd164554b911eb5f91d4ebb460a5adbdf02d7
|