Guides/Undo for AI Agents

Undo for AI Agents

How to use nono's atomic snapshot system to safely experiment with AI agents and roll back unwanted changes.

4 min read

AI coding agents make changes at scale. A single session can touch dozens of files — refactoring functions, updating dependencies, modifying configuration. When something goes wrong, you need a reliable way to undo everything without manually tracking what changed.

nono's snapshot system captures the filesystem state before an agent session and lets you restore it with a single command. Snapshots are opt-in: pass --rollback to nono run to enable them for a session.

How snapshots work

When you run an agent with nono run --rollback, nono walks every file in the sandbox scope and stores a content-addressed copy. Each file is hashed with SHA-256, and the hash is used as the storage key. This means:

  • Identical files share storage (deduplication)
  • The snapshot database grows only by unique content
  • Verification is built in — corrupted files produce different hashes

After the session ends, a second snapshot captures the final state. The diff between the two snapshots tells you exactly what changed.

Listing sessions

bash
nono rollback list

This shows all recorded rollback sessions with their IDs, timestamps, and number of files changed. Session IDs look like 20260507-231436-10467.

Reviewing changes

Before deciding to restore, review what the agent changed:

bash
nono rollback show <session-id> --diff

This produces a unified diff showing:

  • New files (added by the agent)
  • Modified files (with line-level changes)
  • Deleted files
Tip

Use --side-by-side for a two-column view, or pipe the diff to your preferred review tool: nono rollback show <session-id> --diff | delta.

Restoring a session

To restore all files to their pre-session state:

bash
nono rollback restore <session-id>

This is an atomic operation — either all files are restored or none are.

Previewing a restore

To see exactly what a restore would change before touching any files, use --dry-run:

bash
nono rollback restore <session-id> --dry-run

For sessions with multiple snapshots, restore to a specific snapshot number with --snapshot:

bash
nono rollback restore <session-id> --snapshot 1

Practical workflows

Experiment-and-compare

Run multiple agent sessions with different prompts or configurations, then compare the results:

bash
# Session 1: conservative approach
nono run --rollback --allow ~/projects/myapp -- claude "refactor auth module"
# Grab the session ID from `nono rollback list`, then:
nono rollback show <session-1-id> --diff > approach-1.diff
# Restore and try again
nono rollback restore <session-1-id>
# Session 2: aggressive approach
nono run --rollback --allow ~/projects/myapp -- claude "rewrite auth module from scratch"
nono rollback show <session-2-id> --diff > approach-2.diff

Compare the two diffs and keep the better result.

CI integration

In CI pipelines, capture a snapshot before the agent runs and automatically revert if tests fail:

bash
nono run --rollback --allow . -- claude "fix failing tests"
session=$(nono rollback list --recent 1 --json | jq -r '.[0].session_id')
if ! npm test; then
echo "Agent changes broke tests, reverting"
nono rollback restore "$session"
exit 1
fi
Warning

Snapshots are local to the machine where nono runs. They are not synchronized across CI workers or team members. For shared state, commit the agent's changes to a branch and use standard git workflows.

Storage management

Snapshots accumulate over time. Preview what cleanup would remove with --dry-run:

bash
nono rollback cleanup --dry-run

To prune old snapshots, remove sessions older than a number of days:

bash
nono rollback cleanup --older-than 30

You can also keep only the N newest sessions:

bash
nono rollback cleanup --keep 10

Cleanup preserves the content-addressed store entries that are still referenced by newer snapshots.

Next steps

  • Read the Undo & Rollback infrastructure page for technical details on the snapshot format
  • Read the Audit Trail page to understand how snapshots integrate with the cryptographic audit log
  • Check the full documentation for the complete snapshot CLI reference