Remote sandboxes
Remote sandboxes let OpsCode execute shell commands, file mutations, and validation scripts inside an isolated cloud container rather than on your local workstation. Use remote sandboxes when you need blast-radius isolation, clean-room reproducibility, or ephemeral execution environments in CI/CD pipelines.
Supported sandbox providers
| Provider | --sandbox ID | Default working directory | Best for |
|---|---|---|---|
| AgentCore | agentcore | /tmp | Managed AWS execution environments |
| Daytona | daytona | /home/daytona | Self-hosted and cloud development containers |
| LangSmith | langsmith | /root | Ephemeral agent evaluation sandboxes |
| Modal | modal | /workspace | Fast serverless CPU/GPU containers |
| Runloop | runloop | /home/user | Pre-baked snapshots with sub-second boot times |
| Vercel | vercel | /vercel/sandbox | Ephemeral Vercel code sandboxes |
Launch a sandbox
Pass --sandbox when starting OpsCode to route tool execution to a remote container:
# Launch with the default sandbox provider
ops --sandbox
# Specify a provider explicitly
ops --sandbox modal
# Attach to an existing running sandbox
ops --sandbox-id sb-prod-cluster-98234
# Boot from a pre-baked snapshot and run a setup script
ops --sandbox runloop \
--sandbox-snapshot-name terraform-k8s-base \
--sandbox-setup ./scripts/sandbox-init.sh
Sandbox CLI flags
| Flag | Description |
|---|---|
--sandbox [TYPE] | Enable a sandbox provider (agentcore, daytona, langsmith, modal, runloop, vercel) |
--sandbox-id ID | Attach to an already-running remote sandbox instance |
--sandbox-snapshot-name NAME | Boot from a pre-built container snapshot or blueprint |
--sandbox-setup PATH | Run a local shell script inside the sandbox immediately after container startup |
How workspace sync and routing work
- Workspace upload: When a sandbox starts, OpsCode detects your project root and syncs your repository files into the container while excluding ignored directories (
.git/,node_modules/,.venv/,.terraform/,__pycache__/). - Split tool routing:
- Executed inside the remote sandbox: Shell commands (
execute), file reads/writes (read_file,write_file,edit_file),glob,grep, andls. - Executed on the local host: LLM API calls and web search queries, keeping your model provider API keys off the remote container.
- Executed inside the remote sandbox: Shell commands (
- Automatic teardown: Ephemeral sandboxes are terminated automatically when your OpsCode session exits.
Initialize toolchains with --sandbox-setup
Provide a setup script to install or verify DevOps CLI versions inside the container before the agent begins work:
scripts/sandbox-init.sh
#!/usr/bin/env bash
set -euo pipefail
apt-get update && apt-get install -y opentofu kubectl helm awscli
tofu version
kubectl version --client=true
helm version
ops --sandbox modal --sandbox-setup ./scripts/sandbox-init.sh
CI/CD example
Combine remote sandboxes with headless mode (-n) and Rubrics for zero-trust pull request verification:
ops -n "Run OpenTofu plan and remediate any security group ingress violations" \
--sandbox runloop \
--sandbox-setup ./scripts/sandbox-init.sh \
--rubric "tofu validate and tofu plan succeed with zero 0.0.0.0/0 ingress rules on SSH or RDP ports" \
--quiet \
-y