// How-to · Let agents run safely
Stop agents from deleting files or running dangerous commands
Avoiding irreversible agent mistakes takes three layers: an isolated environment, least privilege, and a checkpoint before acting.
verified 2026-10-103 official sources
Scenario: Let agents run safely →
Symptoms
- The agent ran
rm -rf,git reset --hardor overwrote uncommitted work
Common causes
- The agent runs directly on the host with your user’s permissions
- “Auto-approve everything” is on
- Work was not committed, so there is nothing to roll back to
How to fix
- Run the agent in a container, devcontainer or sandbox (locally Docker, bubblewrap or sandbox-runtime; in the cloud E2B and similar)
- Mount only the project directory, not your home directory, SSH keys or cloud credentials; disable or restrict network access by default
- Use the client’s permission modes and deny rules so deletes, pushes and config changes always need human approval
- Commit or create a branch/worktree before starting so every change can be undone
- Keep backups; never hand the only copy of anything to an agent
Official references
Compiled from official documentation and public discussions on 2026-10-10; not yet reproduced in our own environment. Follow the official docs if they differ.