AI agent sandbox: an isolated container for every agent
An AI agent sandbox is an isolated space where an agent can run any command without touching your server, your network or your other agents. Agenhood gives every agent its own hardened container on your server, with one filtered way out to the internet.
Why AI agents need a sandbox
Agents follow instructions they read. A line hidden in a README or a web page can tell an agent to run a command. Without a sandbox, that command runs with your rights: your SSH keys, your cloud credentials and every service on your network.
A plain docker run doesn't fix this. A default container can still reach your private
network and cloud metadata, change its own system files and use all the memory on the host.
What a sandbox for AI agents should do, and how Agenhood does it
- Keep each agent apart. Every agent gets its own container. It runs as a normal user with almost no system rights, so it can't take over the host.
- Protect the system files. The container's system is read-only. The agent writes only to its own workspace.
- Cap resources. Memory, CPU and processes are limited per agent, so one runaway agent can't slow down the rest.
- Control the network. Agents have no direct route to the internet. All traffic goes through one filter that blocks your private network and cloud metadata.
- Guard your keys. API keys are stored encrypted on your server. An agent only gets the model key for the task it is running.
Every agent gets all of this by default, with nothing to switch on. The settings are in the open source code: see the container setup and the network filter.
One way out to the internet
Agents sit on a private network with no gateway. The only way out is the egress proxy. It blocks private addresses and cloud metadata, and it checks every address a hostname points to, so a DNS trick can't sneak a request onto your network. Every request it allows or blocks is logged.
Test it yourself
Open the terminal on any agent and run:
# No proxy: there is no route out, so this fails
curl -sS --noproxy '*' --max-time 8 https://example.com/
# Through the proxy: cloud metadata is refused (prints 403)
curl -sS -x http://egress-proxy:8888 -o /dev/null -w "%{http_code}\n" \
--max-time 8 http://169.254.169.254/latest/meta-data/ Self-hosted AI agent sandbox or a sandbox API like E2B?
E2B and Daytona are sandbox APIs. Your code creates a sandbox and sends it commands. That fits if you are building your own agent from scratch.
Agenhood is a full self-hosted AI agent platform: the sandbox, the agents, schedules and a web console, on your server. You give an agent a task, not a command. See the Daytona comparison for more.
Running Claude Code? See the Claude Code sandbox. For coding work, see self-hosted coding agents.
What it doesn't do
- A hardened container, not a VM. Agents share the host's kernel. For code from strangers, use a microVM sandbox instead.
- The public internet is open by default. You can block sites for all agents, but there is no allow-only mode.
- For your own team. It is not built to be a public, multi-tenant service.
Questions people ask
What is an AI agent sandbox?
An isolated environment where an AI agent can run code and commands. If the agent follows a bad instruction, the damage stays inside the sandbox instead of reaching your system, files, network or keys.
Is a Docker container enough to sandbox AI agents?
A plain container is not. A hardened one, like Agenhood uses, is a good fit for agents you task yourself, where the risk is a bad command or a prompt injection. For code from strangers, use a microVM sandbox.
Is there a self-hosted E2B alternative?
E2B is a sandbox API you call from your own agent code. Agenhood is different: a self-hosted platform with the sandbox and the agents already included. You give an agent a task instead of sending raw commands.
Can an agent in the sandbox reach my private network or cloud metadata?
No. The agent's network has no gateway, and the only way out is a filter that blocks private addresses and cloud metadata endpoints.
Can an agent see my API keys?
Keys are stored encrypted on your server. An agent only receives the model key it needs for the task it is running, so treat that one key as visible to the agent.
Can I limit which websites an agent can reach?
You can block sites for every agent with one setting. There is no allow-only mode, so other public sites stay reachable.