local-opencode automatically.
Prerequisites
- Docker Desktop installed and running
- LiteLLM Agent Platform repo cloned
1. Start the stack
- The LiteLLM Agent Platform web/API service
- A Postgres database
- The OpenCode runtime harness
- Registers
local-opencodein the UI automatically
sk-local by default).
2. Add model provider credentials
Before running an agent, add at least one model provider key in Settings β Credentials (e.g. an Anthropic or OpenAI API key). OpenCode routes model calls through your LiteLLM gateway.3. Create an agent
In the UI, click New Agent, chooselocal-opencode as the runtime, select a model, and optionally set a system prompt.
Or via the API:
4. Run your agent
Select your agent in the UI and click Run. Type a message in the chat panel and OpenCode will start executing. Or via the API:Stop the stack
Run alongside other runtimes
You can start multiple runtimes at once:local-opencode and local-deepagents in the UI.
Configuration
OpenCode runtime configuration lives in thecompose.yaml opencode service block. You can override the default model and tool settings via environment variables in that block.
Sandboxed execution with OpenSandbox
By default the OpenCode harness runs agent commands directly on the host container. OpenSandbox routes every command and file operation into an isolated container sandbox instead, so the agent cannot touch host state. When OpenSandbox is configured:- Native bash and file-edit operations are denied at the harness level.
- A
sandbox-execMCP server is injected into OpenCodeβs tool config automatically. - Each session creates a fresh sandbox, executes all commands there, then terminates it.
How it works
Environment variables
| Variable | Required | Description |
|---|---|---|
OPENSANDBOX_API_URL | Yes | OpenSandbox controller base URL (e.g. http://opensandbox-server.opensandbox-system.svc.cluster.local) |
OPENSANDBOX_API_KEY | When auth enabled | API key sent as OPEN-SANDBOX-API-KEY header |
OPENSANDBOX_IMAGE | Yes | execd container image (e.g. sandbox-registry.cn-zhangjiakou.cr.aliyuncs.com/opensandbox/execd:v1.0.18) |
SANDBOX_PROVIDER | No | Defaults to opensandbox. Only opensandbox is supported. |
opencode service and the harness enables sandbox mode automatically. If OPENSANDBOX_API_URL is unset, sandbox mode is skipped and commands run on the host as normal.
Local Docker Compose
For local testing, point the opencode service at an external OpenSandbox instance by adding env vars tocompose.yaml:
Production deployment on EKS
For production, deploy the full OpenSandbox Kubernetes operator alongside the opencode-anthropic-server. The stack runs:- OpenSandbox controller β manages sandbox lifecycle via
BatchSandboxCRDs - OpenSandbox server β HTTP API gateway the harness calls
- opencode-anthropic-server β the OpenCode harness wired to OpenSandbox
- Kubernetes namespace:
opensandbox-system - Helm charts:
opensandbox-controller,opensandbox-server - Sandbox images:
opensandbox/execd:v1.0.18,opensandbox/egress:v1.0.12 - Default sandbox resource limits:
1 CPU,2 GiB RAM