Tiramemsu 0.13: memory you can undo
Agents can already undo their code and their conversation. Claude Code rewinds, LangGraph forks from a checkpoint, sandboxes snapshot and restore. Their memory usually cannot go back. A bad sync, a hallucinated fact or a confused session stays until someone cleans it up by hand.
Tiramemsu 0.13.0 adds checkpoints, so an agent’s memory can be undone as well:
- Tag a moment:
before-sync,start-of-task,v1. - Diff any two moments and get the net change: what was added, what was removed and how, and which statements corrected which.
- Revert to a tag in one transaction. Nothing is deleted. The bad write stays in history, and the revert records itself, so it can be undone too.
Checkpoints work on both engines, SQLite and redb, and in every package: Rust, Python, Node.js, the JSON bridge, the tm command line and the MCP server.
cargo add [email protected] · pip install -U tiramemsu · npm install @tiramemsu/[email protected] · cargo install tiramemsu-cli tiramemsu-mcpCheckpoints in one minute
Take a checkpoint, let something go wrong, look at what changed, and go back:
with db.transact() as tx:
tx.tag("before-sync") # names the last committed transaction
# ... the sync writes things it should not have ...
d = db.diff("before-sync") # to "now" by default
db.preview_revert("before-sync") # a dry run: what would change, and would it commit?
with db.transact() as tx:
tx.revert_to("before-sync", tag_before="bad-sync")
db.diff("before-sync", by_content=True) # added: [], removed: []
db.transact((tx) => { tx.tag("v1"); });
// ... later writes ...
const d = db.diff("v1"); // { added, removed, superseded, complete }
db.asOf({ tag: "v1" }).triples(); // the memory as it was at v1
db.previewRevert("v1").wouldCommit; // true
db.transact((tx) => { tx.revertTo("v1", { tagBefore: "pre" }); });
db.diff("v1", "now", { byContent: true }).added; // []
db.transact(TxOptions::default(), |tx| tx.tag("clean", &TxRef::Now).map(|_| ()))?;
// ... later writes ...
let d = db.diff(&TxRef::parse("clean"), &TxRef::Now, &DiffOptions::default())?;
let preview = db.preview_revert(&TxRef::parse("clean"), &RevertOptions::default())?;
let report = db.revert_to(
&TxRef::parse("clean"),
&RevertOptions { tag_before: Some("oops".into()) },
)?;
// report.retracted, report.restored: [(original, copy)], report.t
$ tm tag mem.db clean
tagged 1 as "clean" (in tx 2)
$ tm import mem.db bad.nt
$ tm diff mem.db clean
diff tx 1 → tx 3: 2 added, 0 removed, 0 superseded
$ tm revert mem.db clean --dry-run
dry run: reverting to tx 1 would retract 2 and restore 0 statement(s); nothing written
$ tm revert mem.db clean --tag-before oops
reverted to tx 1 in tx 4: retracted 2, restored 0
A moment is a transaction number, now, or a tag name. Everything that takes a moment takes any of the three, including as_of, so db.as_of(tag="v1") is the memory as it was at v1.
For agents over MCP
The MCP server has three new tools, on by default:
checkpointtags the current state.checkpointslists the tags.diffreports what changed since a tag.
An agent can mark the start of a task and report at the end exactly what it learned and what it corrected. The fourth tool, revert, can retract a great deal in one call, so the server lists it only when you start it with --allow-revert. Clients see it marked as destructive, and read-only mode refuses it even with the flag.
claude mcp add tiramemsu -- tiramemsu-mcp --db ./memory.db --allow-revert
What a revert does, briefly
A revert is one ordinary transaction:
- It retracts what is live now but was not live at the target.
- It asserts again what was live at the target but is not now, as new statements with their original content and valid time. Each copy links to its original with
sys:restoredFrom, and the layers on it (confidence, sources, graph memberships) come back on the copy. - It records
sys:revertedToon itself.
Every earlier view of the memory stays exactly as it was, so an auditor can still see the bad write, when it happened and what undid it. The memory’s rules still apply: unique predicates, schemas and enforced Datalog and ELPI constraints are checked at commit, and a revert that would break one fails as a whole.
How diff stays cheap, why a restored statement gets a new id, and what the property tests found are in How checkpoints work. A longer walk-through of a bad sync, undone step by step, is in Checkpoints for agent memory.
Also in 0.13.0
- redb 5. The redb engine moves from redb 4.4 to 5.0. redb 4.6 fixed bugs that could lose data, and 5.0 is the current major version. The on-disk layout is unchanged: a file written by the old redb is kept as a test fixture, and the test opens it and compares every row, event and id with a fresh file. New redb files also start at 72 KiB instead of about 1 MiB.
- Rust 1.90 is now the declared minimum. redb already needed it, so the old 1.88 was wrong.
- New errors for checkpoints:
TagExists,TagNotFound,InvalidTagandInvalidTx, with the same codes in every package. - Reserved predicates.
sys:tag,sys:restoredFromandsys:revertedToare written only by the engine. A user write of any of them fails withReservedNamespace, so a tag cannot be forged.
What is not in it
- Branches. A file has one line of history, and a tag names a point on it. Two lines of work will be two files: a fork, merged back later by the planned memory merge.
- Partial reverts. A revert covers the whole memory. To undo one subject, use
diffto find its statements and retract or supersede them. - Erasure. When legal erasure arrives, a revert will not bring erased content back and will list it as
erased. Until then that list is always empty. - Volatile values and embeddings are not statements, so a revert leaves them alone. Restored statements have new ids and show up in
unembeddeduntil you embed them again.
The full list is in the changelog.