I have been using opencode (and other agent harnesses) on my local ubuntu machine. I usually give permission "always allow" once it asks for things like "ls" and "cat". Recently after doing this it went and read some personal documents and most definitely sent that over the internet to the model provider.
This is the risk and there is nothing stopping it from reading files that are unencrypted while logged in – such as ~/.ssh/id_ed25519 or finding some way to get the browser secrets.
The answer is isolating / sandboxing the place where the agent runs – so one can give it lenient permissions without it exposing data you do not want it to.
What agent sandbox options are there?
These are some sandboxes I could find with a google ai assisted search and looking at the awesome-agent-sandboxes readme, focusing on the self-hosted options.
Evaluated
- Direct docker cli sandbox
- Agentinfra all-in-one sandbox – All-in-One Sandbox for AI Agents that combines Browser, Shell, File, MCP and VSCode Server in a single Docker container
- Arrakis – A fully customizable and self-hosted sandboxing solution for AI agent code execution and computer use
- Bunkervm – Time-travel debugging for AI agent sandboxes with firecracker vm
- Bouvet – Isolated code execution sandboxes for AI agents
- Sandbox AI – Run AI generated code in isolated sandboxes
- Microsandbox – easy, fast, programmable and local-first microVM runtime and library
- nono – A Secure Sandbox for AI Agents
- fence – Lightweight, container-free sandbox for running commands with network and filesystem restrictions
- yolobox – Let your AI go full send. Your home directory stays home.
- Mudroom – Run coding agents in a Linux VM on a clone of your project, then review and apply their changes like a pull request
- Agentbox – Run multiple agents in parallel sandboxed VMs, with a single command, on your PC or in the cloud
- Opensandbox – Secure, Fast, and Extensible Sandbox runtime for AI agents.
- Opencode sandbox – Modified docker based sandbox specifically for opencode
- cplt – Sandbox for AI coding agents. Runs Copilot CLI, Claude Code, OpenCode, Gemini CLI, Antigravity, Pi, goose or a plain shell inside a kernel-level sandbox, with git and gh guards and sandbox policy committed to the repository.
- sandbase-harness – Local-first, self-hosted AI agent runtime and MCP bridge with sandboxed sessions, memory, credentials, audit/replay, and a local Console.
Skipped
- Docker Sandboxes – skipped as it requires a docker account login to use them
- DaytoneSandboxes – appears to require login
- Flintlock – Not a sandbox, used to lifecycle management of microVMs.
- Rivet agents – Not clear if it is fit for purpose from the readme.
- Sandboxer – looks like a playground for a talk that has not been updated recently
Direct docker cli sandbox
Create a project folder and add 3 files…
Dockerfile:
# Use a lightweight, official Python runtime
FROM python:3.11-slim
# Set the working directory inside the container
WORKDIR /app
# Ensure standard system tools are available for Python development
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
curl \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Run the official installation script inside the container
RUN curl -fsSL https://opencode.ai/v2/install | bash
# Automatically map the custom installer binary directory to the global system PATH
ENV PATH="/root/.opencode/bin:${PATH}"
# Keep the container running in the background so you or your scripts can execute commands
CMD ["tail", "-f", "/dev/null"]
docker-compose.yml
services:
opencode-sandbox:
build: .
container_name: opencode_python_sandbox
# Vital flags for interactive command line interfaces (TUI)
stdin_open: true
tty: true
# Mount ONLY the current directory into the container's /app folder
volumes:
- .:/app
# Pass necessary OpenCode and LLM API environment variables from host to container
environment:
- OPENCODE_API_KEY
- OPENCODE_MODEL
- ANTHROPIC_API_KEY
- OPENAI_API_KEY
# Keeps network completely open for external API calls/installations
network_mode: bridge
# web ui ports
ports:
- "4096:4096"
and opencode.json (make edits where needed)
{
"$schema": "https://opencode.ai/config.json",
"disabled_providers": [
"github-copilot",
"anthropic",
"openai"
],
"enabled_providers": [
"opencode",
"opencode-go"
],
"model": "opencode/space-bunny-free",
"small_model": "opencode/space-bunny-free"
}
Steps:
-
Set your ai key on the host env
export OPENCODE_API_KEY="your-opencode-key" -
Build and run the container
docker compose up -d -
Run opencode
docker compose exec -it opencode-sandbox opencode
Rating 6/10 – Simple for simple tasks, more complex when needing skills and plugins for the agent, multiple services and more dependencies. Requires work and a unique set up.