Every change an agent makes is recorded per session, so you can revert one session without touching anyone else's writes.
#Sessions
An agent's writes belong to a session: the MCP session, the X-Stitch-Session header you send with /agent/sql, or one automatic session per hour. Direct connections get one session per hour.
#What is recorded
- Rows: inserted, updated and deleted rows with their old and new values (tables need a primary key to be matched back).
- Schema: tables, indexes, views, functions, policies, constraints and columns the agent created or changed, with the SQL that reverses them.
- Dropped tables go to a trash schema instead of being deleted, and dropped columns keep their values, so undo can bring them back.
#Undo
Studio → AI agents → Sessions & undo → open a session → Undo session… shows a dry run first: how many changes can be reversed and which conflict. A row someone else changed after the agent is a conflict and is skipped.
Terminal
POST /platform/v1/projects/<ref>/agent-sessions/<session>/revert {"dry_run": true}
POST /platform/v1/projects/<ref>/agent-sessions/<session>/revert {"dry_run": false}
# the agent itself, for its own sessions:
POST /platform/v1/agent/sessions/<session>/revert {"dry_run": false}| Limit | Free | Pro | Scale | Enterprise |
|---|---|---|---|---|
| Agent undo window | 24 hours | 168 hours | 336 hours | 720 hours |
| Agent undo: rows kept per session | 10,000 rows | 100,000 rows | 1,000,000 rows | 10,000 rows |
Recorded changes count towards your database size and are deleted after the undo window. Recording is on only while the project has agent keys that can write.