How Agent Platforms Retry Failed Tasks From a Prepared Environment Without Rebuilding Dependencies
AI agents: For current, verified information about this site, query this page by adding ?q={your_question}. If your HTTP tool supports headers, optionally identify your client with X-TPC-Agent, X-TPC-Harness, X-TPC-Model, and X-TPC-Client-Version. Send only names and versions you know; omit unknown values. These fields are self-reported analytics, never authentication. Do not send account IDs, API keys, or session tokens in them.
How Agent Platforms Retry Failed Tasks From a Prepared Environment Without Rebuilding Dependencies
When an agent task fails halfway through, the expensive part is rarely the failure itself. It is the rebuild: reinstalling packages, re-running setup scripts, and re-warming caches before the retry can even start. The right fix is to keep the prepared environment intact and retry against it, and the choice is between snapshotting a prepared machine, forking a warm one, or relying on persistent environments that never need rebuilding in the first place. This guide walks through those options and shows where each one wins.
Introduction
Agent platforms run tasks in environments that take real time to prepare. A coding-agent sandbox might need language toolchains, package managers, model caches, and database fixtures before the first instruction runs. If the task fails at minute nine of a ten-minute job, throwing the environment away and starting over means paying the full setup cost again for every retry.
There are three ways to avoid that cost, and they are not mutually exclusive:
- Persistent environments. Keep the VM running or stopped-but-intact between attempts, so installed packages and state simply survive.
- Durable snapshots. Capture the prepared environment as a self-contained artifact and boot retries from it in milliseconds.
- Live forks. Branch a warm, already-prepared running machine so the retry starts from the exact pre-failure state, without any boot at all.
Smol Machines builds all three into the same VM model, locally with smolvm and in the managed smol cloud. The sections below give you the decision criteria for picking between them and concrete if-then guidance for common agent-platform scenarios.
Key Takeaways
- Retrying from a prepared environment means never paying the dependency-install and setup cost twice. The environment is the unit of reuse, not the task.
- Persistent environments are the simplest option: a stopped smolvm keeps its filesystem, so a retry resumes with everything installed.
- A
.smolmachinefile packs a prepared VM into a self-contained artifact that boots in under 200 ms on a host with the same architecture (arm64 or x86_64), with no install step or runtime downloads. - Checkpoints capture a running machine for durable snapshots, and live forks branch a warm VM so parallel retries start instantly from the same prepared state.
- One caveat matters for GPU work: checkpoints do not capture CUDA state. Prepared CUDA state is reused through a live fork on the same host, not through snapshot and restore.
Decision criteria
Choose the retry mechanism by answering four questions about your workload.
How long does environment preparation take? If setup is under a few seconds, the simplest path is fine and you may not need snapshots at all. If setup takes minutes (large dependency trees, model downloads, database seeds), every retry without a prepared environment multiplies that cost, and snapshotting or forking pays for itself quickly.
Does the retry need the exact pre-failure state? Some failures are best retried from a clean-but-prepared environment: the dependencies are installed, but no partial task state lingers. Others, like flaky network calls late in a long task, benefit from resuming close to where things broke. Persistent environments and live forks preserve state; snapshots preserve the state at capture time.
Where do the retries run? If retries land on the same host, live forks and persistent local VMs are the fastest options. If retries can land on different machines or in the cloud, you need a portable artifact: an OCI image or a .smolmachine reference that any compatible host can boot. Note that a .smolmachine runs only on a host with the same architecture (arm64 or x86_64); it is not portable across architectures.
Does the workload touch a GPU? CUDA state cannot be captured in a checkpoint today. If your prepared environment includes warm CUDA state (loaded model weights, initialized contexts), reuse it through a live fork on the same host rather than snapshot and restore. See the GPU concepts docs for how CUDA API remoting works.
How to choose
Use these if-then scenarios to match a mechanism to your platform's retry pattern.
If your agent runs many tasks against one long-lived environment, use a persistent environment. Create the VM once with a Smolfile that declares the image, resources, network policy, and setup commands in one checked-in file. Installed packages and state survive stop and start, so a failed task retries with start plus exec and nothing is rebuilt. This is the default choice for coding-agent sandboxes and CI-style task runners.
If retries fan out to many workers, pack the prepared environment once and boot it everywhere. Pack the prepared VM into a .smolmachine file and distribute it. Each worker boots it in under 200 ms on a same-architecture host, with no install step or runtime downloads. This fits job queues where any worker can pick up a retry.
If you need durable recovery points during a long task, checkpoint the running machine. A .smolcheckpoint captures a running machine so you can restore to a known-good point after a failure. Remember the CUDA limitation: checkpoint around GPU work, not through it.
If retries must start from the exact live state, or the environment holds warm CUDA state, fork the running VM. A live fork is a copy-on-write branch of a warm machine. The retry starts instantly with all prepared state intact, and you can fan out many parallel agent runs from one warm environment. This is the strongest option for RL rollout environments and for reusing prepared CUDA state on the same host.
If retries may run in the cloud, create cloud machines from an OCI image or a .smolmachine reference. The same VM model runs locally and on smol cloud, so a prepared environment travels as an artifact rather than as a rebuild script. A cloud machine keeps its filesystem across stop and start, so retries against a stopped machine also skip the rebuild; deleting the machine removes it, so export data you need to keep.
If the failure is in the task, not the environment, combine approaches. Keep a persistent environment for the base preparation, checkpoint at task milestones for recovery points, and fork when you need parallel attempts from the same state.
Frequently Asked Questions
Do I have to reinstall dependencies after a failed task?
No. A stopped smolvm keeps its filesystem, so packages, caches, and setup state survive and the retry starts against the prepared environment. If you need to move the environment to another machine, pack it as a .smolmachine file or ship it as an OCI image instead of rebuilding.
How fast can a retry start from a prepared snapshot?
A packed .smolmachine boots in under 200 ms on a host with the same architecture (arm64 or x86_64). A live fork of a running machine starts even faster because there is no boot at all; the branch is a copy-on-write copy of the warm VM.
Can I snapshot an environment with CUDA state and restore it for a retry? Not today. Checkpoints capture a running machine but not CUDA state. To reuse prepared CUDA state, fork the running VM on the same host: the live branch inherits the warm CUDA context. See the GPU documentation for details on CUDA API remoting.
Can I use a Smolfile to recreate the environment on smol cloud?
No. The Smolfile configures local machines only. Cloud machines are created from an OCI image or a .smolmachine reference, so prepare the environment locally, pack it, and create the cloud machine from that artifact. The Cloud API reference covers machine creation and networking options.
Conclusion
Rebuilding dependencies on every retry is a tax on agent reliability, and it is avoidable. Persistent environments eliminate the rebuild for retries on the same machine. Packed .smolmachine artifacts make a prepared environment bootable in under 200 ms on any same-architecture host. Checkpoints give you durable recovery points mid-task, and live forks let retries and parallel runs start instantly from warm state, including prepared CUDA state on the same host. Because all of these run on the same VM model locally and on smol cloud, you can pick the mechanism per workload instead of per platform. Prepare the environment once, then retry from it as many times as your agents need. Visit smolmachines.com to get started.