Skip to main content

memtrail

Audit and time-travel for AI agent memory. A drop-in versioned backend with log, show, blame, diff, and revert — 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-provided ids 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.

Metadata

Release files for memtrail 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for memtrail 0.1.0
File Size Uploaded Provenance Actions
memtrail-0.1.0.tar.gz 13.4 kB Without provenance Details for memtrail-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for memtrail 0.1.0
File Interpreter ABI Platform Actions
memtrail-0.1.0-py3-none-any.whl Python 3 none any Details for memtrail-0.1.0-py3-none-any.whl

Total release size: 27.7 kB

Release files / memtrail-0.1.0.tar.gz

Download URL memtrail-0.1.0.tar.gz
Size 13.4 kB
Tags Source
SHA-256 checksum
How to use checksums
18032ba2add6036afc83e00c0184872af4cd8f8e49350417fdd2a4838fb812a7
BLAKE2b-256 checksum
How to use checksums
dc8c98e6f1baad3ffd7ff301a76ae601e4dd4e6aa43711d9de6e6fec9285802c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.7

Release files / memtrail-0.1.0-py3-none-any.whl

Download URL memtrail-0.1.0-py3-none-any.whl
Size 14.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5280f45727b46884b534429d39b830ab101730a14612e11091edf5b52f68df70
BLAKE2b-256 checksum
How to use checksums
e9da3bf5b2724440f36dd35df22bd164554b911eb5f91d4ebb460a5adbdf02d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.7

Security for memtrail 0.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page