POSTEngineering log
All postsWhen an AI Agent Breaks Its Sandbox, Stay in Control
- Written by
- Sandbox0 Team
- Published
An agent has spent an hour preparing a project. It has installed dependencies, changed configuration, and written code. Then a system change goes wrong, and the terminal stops accepting commands.
The files may still be there. Other processes may still be running. But the usual way to investigate the problem is no longer working.
For a product built around long-running agents, deleting the environment and starting again can mean losing useful work and repeating a costly setup. You need a way to manage the sandbox even when the software inside it cannot help.
Sandbox0 now separates sandbox recovery from the health of its internal command service. You can inspect lifecycle state and request recovery from outside the affected environment, without first getting a shell to work.
The internal service is called procd. It handles commands, terminal sessions, and other interactions inside a sandbox. Like other software in an environment where an agent has root access, it can be stopped or affected by changes to the system. Those failures should not take away your ability to manage the environment itself.
Consider an agent experimenting with system tools. It changes a filesystem mount, and the command service can no longer find the programs or paths it expects. Asking that same service to run a repair command may fail for exactly the same reason. Sandbox0's recovery path operates outside that dependency, so the damaged service does not have to acknowledge a successful command before the platform can manage the sandbox's lifecycle.
Keep the work that is already on disk. An explicit runtime restart ends the old processes and starts fresh execution from the sandbox's externally committed filesystem. Installed software, configuration, and saved project files on that filesystem can remain available. A command-service failure does not, by itself, require a new empty environment.
Restarting does not undo changes to files. If the agent deleted a dependency or wrote a bad configuration, those changes can still be present afterward. When you want to return to an earlier filesystem state, use an existing snapshot. Restart and rollback give you different recovery choices.
Choose whether to keep the running state. Sometimes files are enough to continue a task. Sometimes the valuable state includes a running process, an in-memory calculation, or an open file.
Sandbox0's explicit, experimental memory pause and resume can retain supported processes and memory on compatible restores. This path can operate without a healthy procd, allowing you to preserve a supported execution state even when ordinary commands are unavailable. Memory preservation must be selected on both pause and resume; default pause/resume remains filesystem-only.
Preserving a process also preserves its problems. A memory checkpoint can retain a damaged command service rather than repair it, and existing network connections are not guaranteed to survive. The useful choice is whether to keep that state for continuation or investigation, or explicitly discard it and restart.
If a requested memory restore fails, Sandbox0 reports the failure and keeps the retained checkpoint available for recovery. It does not silently replace the operation with fresh processes. You decide when losing the old process state is acceptable. The pause and resume guide explains these modes and their requirements.
See what is actually wrong. A sandbox can still be alive while its terminal is unusable. Its storage can be available while new commands fail. Treating all of those conditions as one “running” flag makes recovery harder.
Sandbox0 reports runtime, supervisor, command-execution, and storage health separately, including when a condition is unknown. That helps your application distinguish a command failure from a broader runtime or storage problem. A completed runtime restart also remains distinct from proof that your application is healthy; you can check it before returning the user to work.
Follow the same recovery through a lost connection. A timeout after a restart request should not leave your application guessing whether to issue another restart. Sandbox0 records the operation and its progress. With the same request key and expected runtime generation, a retry follows the original request instead of restarting a replacement that is already running. Your application can query that operation after reconnecting and see whether it completed or is waiting on a specific condition.
We validated this recovery boundary with deliberately damaged environments, including an unavailable procd and filesystem changes that prevented ordinary command execution. Validation also covered process and memory continuity, recovery after lost replies, and preservation of committed workspace data. These checks establish behavior for the tested failure cases, rather than a promise that every damaged application can be repaired automatically.
The same storage limits still apply: recovery cannot recreate deleted files without an earlier snapshot, or guarantee writes that were never committed. Storage outages and unavailable compute capacity can still block an operation. The improvement is that an unhealthy command service no longer has to be repaired first just to reach the recovery path.
For teams building coding agents and personal cloud computers, this provides more ways to help a user when a task goes wrong. Keep the saved workspace, preserve supported running state when needed, or return to a known snapshot, with a recovery operation your application can track.
Give the agent room to work. Keep the ability to recover when it makes a mistake.
Start building on Sandbox0 Cloud, or read about explicit runtime restart to add recovery to your application.