AI-native

How do you undo an AI coding agent's mistakes?

It depends on where the mistake is. On the agent's own machine, save a checkpoint of the whole disk at each good point and start a fresh machine from the last good one, because git only brings back tracked files. In production, turn off the change behind its feature flag, which takes seconds and needs no deploy. Commits, checkpoints and flags cover different layers, so use all three.

Updated November 21, 2026

Why isn't git enough?

An agent changes more than the repo. It installs packages, fills databases, runs migrations and edits config outside the project, and those files are usually in .gitignore or outside git altogether. In Sandboxer's guide on checkpointing a coding agent's sandbox and rolling back, a scripted agent deleted its source files, broke an installed package and dropped a database table. git checkout brought back the two source files and nothing else: the package and the database stayed broken, so the tests still failed.

How do you checkpoint an agent's machine?

Save a named snapshot at each point the agent can check, such as tests passing or a reviewer approving the diff, and save after the check, not before:

sbx snapshot "$id" app-ckpt-1      # after step 1 passes
sbx snapshot "$id" app-ckpt-2      # after step 2 passes

# a later step breaks things: start again from the last good point
sbx new --type small --from app-ckpt-2

In the guide's run on November 20, 2026, the save took 2.1 seconds and the new sandbox from the checkpoint was ready in 1.2 seconds, with the repo, the working package and all the database rows back. Give each checkpoint its own name: reusing a name replaces the snapshot, which would leave you only the newest one, and the newest may be the bad one.

What doesn't a checkpoint bring back?

Memory. A checkpoint holds the disk, so a server the agent started isn't running in the new sandbox. Start processes again after a rollback, or run them as enabled system services, which start on boot. A fork isn't a rollback either: it copies the disk as it is now, damage included, and is for trying several next steps from a good machine; see forking sandboxes. Named snapshots are kept until you delete them and count toward the plan's included storage, so delete a run's checkpoints when it ends.

What if the mistake reached production?

Then the fastest way back is the flag. If the change shipped behind a feature flag, a kill turns it off for everyone: in Flagger.gg, flagger kill, the flag_kill MCP tool or the console does it, and apps get the change within a second. A deploy rollback is the fallback for changes that can't sit behind a flag, such as a migration. See kill switch or rollback and how to stop an AI agent that's going wrong.

Which way back fits which mistake?

MistakeWay back
Bad edits to tracked filesGit: revert or check out the last good commit
A broken environment: packages, data, configStart a new sandbox from the last checkpoint
A crash partway through a long runResume from a state file that records finished steps
A bad change live in productionKill its feature flag
A bad change that can't be flaggedRoll back the deploy

For long unattended runs, see running AI agents for days in a sandbox.

Frequently asked questions

Can git undo everything an AI agent did?

No. Git restores tracked files only. Installed packages, databases and config outside the repo need a checkpoint of the whole machine.

How fast is a rollback to a Sandboxer checkpoint?

In Sandboxer's November 20, 2026 test on a small sandbox, saving a checkpoint took 2.1 seconds and a new sandbox from it was ready in 1.2 seconds.

Does a checkpoint keep the agent's running processes?

No. It holds the disk, not memory. Restart processes after a rollback, or run them as services that start on boot.

How do you undo an AI agent's change in production?

Turn off its feature flag. With Flagger.gg, a kill reaches apps within a second, with no deploy.