Why Retries Are Expensive
A coding agent spends its first few minutes on setup. It clones the repo, installs dependencies, starts a database, boots a dev server, runs the test suite once to see what is already broken. Only then does the real work start.
When the run goes wrong at step 40, the usual recovery is to throw the environment away and start over. The model call is cheap to repeat. The setup is not. Neither is the thinking time the agent spent learning the repo, which is gone the moment the environment is.
Snapshots change the unit of recovery. Instead of restarting from zero, you restore to the last good state. Instead of one attempt per task, you run several from the same starting point.
Memory Snapshots vs Disk Snapshots
Not every snapshot is the same primitive. A disk snapshot is a filesystem image. A full VM snapshot also captures memory, so running processes come back running.
| Disk snapshot | Memory + disk snapshot | |
|---|---|---|
| Files and installed packages | Yes | Yes |
| Running dev server / database | No, restart required | Yes, already up |
| Warm caches in RAM | No | Yes |
| Time to useful state | Boot + service startup | Resume |
Freestyle VMs take the second kind, and they take it cheaply: under 1ms of interruption to the source VM, under 50ms until the snapshot is ready to boot from. At that cost you can snapshot before every risky step without thinking about it.
Four Branching Patterns
Checkpoint and roll back
Snapshot before a migration, a dependency upgrade, or any command the agent cannot undo. If it breaks the environment, boot from the snapshot and try something else.
Best-of-N attempts
Fork one prepared environment into several VMs, give each agent the same task, and keep the attempt that passes the tests. Setup runs once.
Golden environments
Build a VM with the toolchain, repo, and services ready, snapshot it, and boot every new task from that snapshot. Agents start working instead of installing.
Time travel for debugging
Keep snapshots at each step of a failed run. When you find the step where it went wrong, boot that exact state and inspect it.
Branches you are not using right now do not need to be running. Pause them. A paused Freestyle VM keeps its memory and disk, stops using compute, and does not count against the concurrent VM limit.
Building a Fork in Practice
On Freestyle, a fork is two steps: snapshot a VM, then create new VMs from that snapshot. The CLI version:
Snapshot a prepared VM and fork it
# capture the prepared environment (memory + disk)
freestyle snapshot create development --slug prepared-repo
# boot parallel attempts from the same state
freestyle vm create --snapshot-id prepared-repo --slug attempt-a
freestyle vm create --snapshot-id prepared-repo --slug attempt-b
freestyle vm create --snapshot-id prepared-repo --slug attempt-csnapshot create returns once the snapshot is ready to boot. The same operations exist in the SDK and REST API. The Freestyle VM CLI docs cover building snapshots from scratch, including running a setup command or script inside the VM before it is captured.
Choosing the Branch Worth Keeping
Forking makes attempts cheap. It also makes judging them the bottleneck. Tests are the best signal when they exist. When they do not, you need something that reads each attempt and flags the ones that went off the rails.
Two places Morph fits here. Reflex runs per-turn classifiers in under 90ms, so a branch that starts looping or drifting can be killed early instead of burning tokens to the end. And when branches produce edits against the same files, Fast Apply merges the winning edit into the codebase at 10,500+ tok/s.
Frequently Asked Questions
What does it mean to fork a VM for an AI agent?
Snapshot a running VM, including its memory and disk, then boot one or more new VMs from that snapshot. Each copy starts in the exact state of the original, so separate agent attempts can diverge from a shared, already-prepared starting point.
How fast is a VM snapshot?
It varies by provider. Freestyle snapshots interrupt the source VM for under 1ms and are ready to boot from in under 50ms.
Why not just snapshot the disk?
A disk snapshot restores files but not processes. Every branch still has to boot, start services, and warm caches. A memory snapshot restores running processes, so a dev server or database the agent started is already up in every fork.
When is forking worth it?
When environment setup is slow relative to the agent's work, when tasks are failure-prone and benefit from rollback, or when you want several attempts at the same problem and a way to compare them.
Catch Bad Branches Early
Reflex classifies every agent turn in under 90ms. Kill looping or off-task branches before they burn the budget.