# Undo what an agent wrote

> Three ways to take back an agent's database writes in Stolon: drop the branch it worked on, read any table as it was with FOR SYSTEM_TIME AS OF, or restore a branch, main included, to a moment.

Source: https://stolondb.com/guides/undo-agent-writes/ · Page title: Undo what an agent wrote — Stolon

Every past version stays readable, and a branch can be put back to any moment. Cheapest first.

## 1. It worked on its own branch: drop it

```sh
psql "postgresql://app:<password>@db.stolondb.com/acme.main" -c 'DROP DATABASE "agent-9"'
```

`main` never saw any of it ([review guide](https://stolondb.com/guides/review-agent-changes/)).

## 2. See what it was before

Read any table, on any branch, as it was at a moment:

```sql
SELECT * FROM accounts FOR SYSTEM_TIME AS OF '2026-09-26 19:09:27+00' ORDER BY id;
```

Unix seconds work too: `AS OF 1790449767`.

## 3. Put the branch back to a moment

In the console's Time Machine, choose **Restore** at the moment. It keeps the present as a branch first, so the restore can be undone; a dropped table comes back with its rows. [The history guide](https://stolondb.com/guides/history/) walks through it.

## 4. On MCP: `checkout`

Over [MCP](https://stolondb.com/guides/mcp/), `checkout` to an earlier version is undo; the line it leaves stays readable.
