# How to Isolate an AI Agent That Runs Code: Dedicated Server vs Container vs MicroVM

> An AI sandbox keeps a coding agent's mistakes away from your real systems. Compare containers, microVMs and a dedicated server, and set one up.

An **AI sandbox** is an isolated place where an AI agent can write and run code without touching your laptop, your production servers or your private keys. There are three common ways to build one: a **container**, a **microVM**, or a **dedicated server** that belongs to the agent alone. Each draws the wall in a different place.

![Diagram comparing the three AI sandbox levels: a container sharing the host kernel, a microVM with its own kernel, and a dedicated server with its own machine](/_landing/blog/isolate-ai-agent-that-runs-code-image-1.png)

Agents such as **Claude Code**, **OpenClaw** and **Hermes Agent** no longer just suggest code. They install packages, edit files and run shell commands, often while you are not watching. If you have been reading about [**what an AI agent is**](/what-is-an-ai-agent/), this is the part that turns a clever chatbot into something that needs a boundary.

This guide explains the three isolation levels in plain words, what each one costs you in setup and money, and the simplest setup that works for most teams: one agent, one server.

## TL;DR

Short on time? Here is the whole guide in a few lines:

- **Container:** fast and light, but it shares the host's kernel. Good for code you mostly trust.
- **MicroVM:** each sandbox gets its own small kernel (Firecracker is the best-known example). Strong isolation, more moving parts.
- **Dedicated server:** the agent gets a whole machine. The easiest wall to understand, and the one xCloud uses.
- **The real risks** are prompt injection, leaked API keys and runaway processes, not sci-fi.
- **Practical rule:** one agent per server, scoped keys, no production secrets on it, and a copy of anything you can't lose.
- **On xCloud**, OpenClaw and Hermes Agent each run on a dedicated server with at least 4 GB RAM, and an agent connected over xCloud MCP can't delete a server without a person's approval.

## The Finding: On xCloud, the Server Is the Sandbox

Most sandbox articles end at "use a container" or "use a microVM". Here is what we can tell you from xCloud's own setup: **when you run an agent on xCloud, the isolation boundary is the server, not a sandbox inside it.**

That is a deliberate trade-off, and we would rather say it plainly. The agent has **full access to its own server**, so it can install what it needs and keep working. What it can't do is reach your other servers, because it doesn't run on them.

| What xCloud does | Where it is documented |
|---|---|
| OpenClaw and Hermes Agent each need a **dedicated server** with at least 4 GB RAM; xCloud refuses a smaller one | [Install Hermes Agent on a VPS](/docs/how-to-install-hermes-agent-on-vps-with-xcloud/), [Install OpenClaw on a VPS](/docs/how-to-install-openclaw-on-vps-with-xcloud/) |
| A Hermes Agent server should not already host sites | [Install Hermes Agent on a VPS](/docs/how-to-install-hermes-agent-on-vps-with-xcloud/) |
| An agent over xCloud MCP can only **ask** to delete a server; a person approves it in the browser | [Approve server deletion requests](/docs/approve-server-deletion-requests-from-ai-agents-in-xcloud/) |
| An API token with **Refuse destructive actions** can never delete, reboot or restore | [Connect xCloud MCP to your AI agent](/docs/how-to-connect-xcloud-mcp-to-ai-agent/) |
| Site users only reach their own site's files and have no sudo password | [Sudo users and site users](/docs/usudo-users-and-site-users-in-xcloud/) |

### What the Agent Actually Sees When It Asks to Delete a Server

Here is exactly what you and the agent see.

When an agent connected over xCloud MCP asks to delete a server, nothing is deleted. xCloud saves the request for **15 minutes** and emails the team owner, the team admins who are allowed to delete servers, and the person whose token the agent used. The email says:

> **Approval requested to delete** *your-server*
> An AI agent requested deletion of *your-server* for team *your-team*.
> Nothing has been deleted. Open the request to review the server and its sites.

A few details worth knowing:

- **If nobody approves within 15 minutes, the request expires** and the server stays as it is. The agent has to ask again.
- **A new request replaces the old one.** If the agent asks twice for the same server, only the latest request can be approved.
- **If the server changed** between the agent's preview and its request, xCloud refuses with: *"This server changed. Ask your agent for a new preview."*
- **Our support team can't approve a deletion for you.** Only a member of your team can.

If the agent's API token has **Refuse destructive actions** turned on, the request is not even saved. The agent is told the deletion did not run, nothing changed, and to use a token without that option or the xCloud dashboard. The real message names the action that was refused.

If you only remember one line: **put the agent somewhere it can break things safely, and keep everything you care about somewhere else.**

## Why an Agent That Runs Code Needs a Boundary

A coding agent runs with the permissions of the user who started it. On your laptop, that usually means it can read your SSH keys, your cloud credentials and every project folder you have.

Anthropic's own docs are honest about this. Claude Code's working-folder boundary is a permission prompt, and the docs note that **a Bash command you approve can still write anywhere your user account can**. They also say that no system is completely immune to prompt injection.

Think of it like hiring a fast, eager contractor who never sleeps. You would give them a workshop with the tools they need. You would not give them the keys to your house, your car and your bank.

## Three Ways to Isolate an AI Agent

Here is the part that trips people up: all three options are called a "sandbox", but they protect you in very different ways.

| | Container | MicroVM | Dedicated server |
|---|---|---|---|
| **What is shared** | The host's kernel | The physical host, not the kernel | Nothing with your other work |
| **Example** | Docker, a dev container | Firecracker, Kata Containers | A VPS or cloud instance just for the agent |
| **Startup** | Seconds or less | Very fast (Firecracker says under 125 ms) | Minutes to create, then always on |
| **Isolation strength** | Good for trusted code | Strong | Strong, and easy to reason about |
| **Setup effort** | Low | High, you run the VM layer | Low to medium |
| **Cost** | Lowest | Low per sandbox, plus engineering time | One server's monthly bill |
| **Best for** | Builds, tests, your own scripts | Running many strangers' code on one host | An always-on agent you own |

### 1. Containers: Light, but the Kernel Is Shared

A container packs an app and its files into one box that runs on the host's kernel. If you are new to them, our guide to [**Docker and its components**](/what-is-docker-understanding-its-components/) covers the basics.

The upside is speed and low overhead. The catch worth knowing: every container on a host talks to the **same kernel**, so a kernel flaw, giving the container control of Docker itself, or sharing too many of the host's folders with it, can let a process get out.

Rule of thumb: a container is a fine AI sandbox for code you wrote or mostly trust. It is a weaker wall for code from strangers.

### 2. MicroVMs: Their Own Kernel, Still Small

A microVM is a tiny virtual machine with its own kernel. [**Firecracker**](https://firecracker-microvm.github.io/), built by developers at Amazon Web Services and open source under Apache 2.0, is the best-known one. As of November 2026, its site says a microVM starts in **under 125 ms** and uses **less than 5 MiB** of extra memory.

Some sandbox services for agents use microVMs for this reason: each run gets its own kernel and is thrown away afterward. The trade-off is that you, or your provider, have to run the VM layer, the images and the networking.

Rule of thumb: pick microVMs when you run many short jobs from many users on shared hardware.

### 3. A Dedicated Server: The Agent Gets Its Own Machine

The simplest wall is a whole server for the agent. It has its own kernel, its own disk and its own network address. Nothing else you run lives there.

This fits always-on agents like OpenClaw or Hermes Agent, which keep memory, run scheduled tasks and answer you on Telegram. They need a place that stays on, not a sandbox that disappears after one job.

Rule of thumb: a dedicated server is the easiest AI sandbox to explain to your team, and the most natural home for a long-running agent.

## What Can Go Wrong When an Agent Runs Code

The real risks are ordinary, which is exactly what makes them easy to miss.

![Diagram of the blast radius of an AI agent: what it can reach on a shared laptop compared with a dedicated agent server](/_landing/blog/isolate-ai-agent-that-runs-code-image-2.png)

- **Prompt injection.** The agent reads a web page, an issue or a README with hidden instructions, and follows them. Anthropic's advice for untrusted content is to use VMs to run scripts and tool calls.
- **Leaked keys.** An agent that can read `~/.ssh` or `~/.aws/credentials` can also send them somewhere. Claude Code's sandbox docs say reads cover most of the machine, credential files included, unless you deny them.
- **Runaway processes.** A loop that fills the disk, eats the memory or calls a paid API thousands of times. On a shared server, your websites slow down with it.
- **Destructive commands.** A wrong `rm -rf`, a dropped database or a deleted server.

For a deeper list aimed at one agent, see our [**OpenClaw security best practices**](/openclaw-security-best-practices/).

## A Practical Setup: One Agent, One Server

You don't need a research lab to get this right. These rules cover most teams.

1. **One agent per server.** Never run an agent on the server that hosts your client sites or your store.
2. **Scoped keys only.** Give the agent its own LLM key with a spending limit, and its own Git token limited to the repos it needs.
3. **No production secrets.** No database passwords for live sites, no root keys to other servers, no payment keys.
4. **Read-only first.** When the agent manages your xCloud account over MCP, start with **Read-only** and widen access later.
5. **Block the dangerous actions.** For an API token, tick **Refuse destructive actions** so delete, reboot and restore are refused before they run.
6. **Keep a copy of what you can't lose.** Back up the agent's configuration and memory somewhere off the server.
7. **Plan the reset.** Know how you would wipe the server and start again. If that is painful, the agent holds too much.

Our guide to [**VPS security**](/maximize-your-vps-security/) covers SSH keys, updates and the other basics every agent server needs.

## Run Claude Code on Your Own Server

Claude Code on your laptop stops when the laptop closes, and it runs next to everything else on that machine. On a server, it keeps working and it is apart from your personal files.

Here is one way to do it on a server you manage with xCloud (see [**Claude Code hosting**](/claude-code-hosting/) for the hosting side):

1. Create a server with enough RAM for your work (4 GB is a safe start): an xCloud Managed server, or your own Ubuntu server from DigitalOcean, Vultr, Linode, AWS or another provider.
2. Open the **web terminal** from your server in the xCloud dashboard, or connect over SSH, and run Anthropic's installer: `curl -fsSL https://claude.ai/install.sh | bash`
3. Run `claude` inside **tmux** and sign in, so it keeps running when you close the terminal.
4. Optionally turn on **Remote Control** to follow and steer the session from the Claude web or mobile app.

Then add Claude Code's own layer. Its sandbox, turned on with `/sandbox`, isolates Bash commands using **bubblewrap** on Linux. It covers shell commands only (file tools, MCP servers and hooks run outside it), so treat it as a second wall, not the first one. Details are in [**Anthropic's Claude Code security docs**](https://code.claude.com/docs/en/security).

## Host OpenClaw or Hermes on a Dedicated Server with xCloud

OpenClaw and Hermes Agent are built to run around the clock. On xCloud, each one gets **a dedicated server with at least 4 GB RAM**, and xCloud refuses a smaller server before it installs anything.

You have two paths:

- **Managed:** xCloud creates and runs the server for you. See [**OpenClaw hosting**](/openclaw-hosting/) and [**Hermes Agent hosting**](/hermes-agent-hosting/).
- **Your own VPS:** connect a server from your cloud account or any Ubuntu VPS, and xCloud installs the agent, the SSL certificate and the updates. 👉 [Install Hermes Agent on a VPS](/docs/how-to-install-hermes-agent-on-vps-with-xcloud/) · [Install OpenClaw on a VPS](/docs/how-to-install-openclaw-on-vps-with-xcloud/)

Not sure which agent fits? Our [**Hermes Agent vs OpenClaw**](/hermes-agent-vs-openclaw/) comparison breaks it down, and [**self-hosted AI agents**](/self-hosted-ai-agents/) lists the other options. All plans are on the [**pricing page**](/pricing/).

**Ready to give your agent a server of its own? [Start with AI agent hosting on xCloud](/ai-agent-hosting/).**

## What xCloud Does Not Do

Honest limits matter more than features here, so here they are.

- **No sandbox inside the server.** xCloud does not add a container or microVM sandbox around your agent. Unless you turn on the agent's own sandbox, it can run any command on its server. For OpenClaw, see [**OpenClaw sandboxing**](https://docs.openclaw.ai/gateway/sandboxing); for Hermes Agent, switch its terminal to the Docker backend as shown in [**Hermes Agent configuration**](https://hermes-agent.nousresearch.com/docs/user-guide/configuration#docker-backend).
- **No guard against prompt injection.** If the agent follows a bad instruction, it does so with the full power of its server. Scoped keys and no secrets are your protection.
- **Not for strangers' code.** If you run untrusted code from many users, a microVM platform is the better tool.

To undo a bad run, delete the server and create a fresh one, then restore the agent's configuration from your copy. Because nothing else lives on that server, you lose nothing else.

## Quick Checklist

- ✅ The agent has its own server, with nothing else on it
- ✅ The LLM key has a spending limit
- ✅ Git and cloud tokens are scoped to what the agent needs
- ✅ No production passwords or root keys on the server
- ✅ xCloud MCP access starts as Read-only, or the token refuses destructive actions
- ✅ The agent's configuration and memory are copied off the server
- ✅ You know how to wipe and rebuild the server

## Give Your AI Agent a Wall It Can't Talk Its Way Past

An AI sandbox is not one product. It is a choice of where to draw the wall: around a process, around a small VM, or around a whole machine.

For most teams running an always-on agent, a dedicated server is the clearest answer. This week, move your agent off the machine that holds your real work, give it scoped keys, and write down how you would reset it.

If you have found this blog helpful, feel free to [**subscribe to our blogs**](https://xcloud.host/blog/) for valuable tutorials, guides, knowledge, and tips on web hosting and server management. You can also join our [**Facebook community**](https://www.facebook.com/groups/xcloud.community) to share insights and engage in discussions.

## Frequently Asked Questions

### What is an AI sandbox?

An AI sandbox is an isolated place where an AI agent can write and run code without reaching your laptop, your production servers or your private keys. It can be a container, a microVM or a whole server set aside for the agent.

### Is a Docker container enough to sandbox an AI agent?

For code you mostly trust, often yes. A container shares the host's kernel, so a kernel flaw or a bad mount can let a process reach the host. For untrusted code or many users on one machine, a microVM or a separate server gives a stronger wall.

### Does Claude Code have a built-in sandbox?

Yes. Claude Code can sandbox its Bash commands with filesystem and network isolation, using bubblewrap on Linux and Seatbelt on macOS. It is off by default and covers shell commands only, so Anthropic also suggests running the whole process in a dev container or VM for more isolation.

### Does xCloud run AI agents inside a container or microVM sandbox?

No. On xCloud the boundary is the server itself: OpenClaw and Hermes Agent each need a dedicated server with at least 4 GB RAM, and the agent has full access to that server. Keep production sites and secrets on other servers.

### Can an AI agent delete my xCloud servers?

Not on its own over xCloud MCP. An agent can only ask, and the server is deleted only after a team member approves the request in the browser within 15 minutes. An API token with Refuse destructive actions cannot even ask.
