Should OpenCode Run Per Job or Stay Available?

Prototype one representative job with local Docker Sandboxes, Cloudflare Sandboxes, or E2B. Verify the required workspace and network reach, then compare measured per-job costs with a quote for a standing worker.

Start with the smallest workspace that can produce a diff

Use a synthetic repository with one source file, one passing test, and a requested one-line behavior change. Docker’s local OpenCode setup supports a project workspace and a mountless sandbox. Try the mountless path with a disposable copy of the fixture, then see whether the exported diff applies cleanly to a fresh copy. Try a project-backed session if your workflow needs interactive edits in a working directory. Put a harmless marker beside the project, document which paths should be visible, and check that exposure independently of the agent’s approval prompts. Include one project setting with a visible effect, such as a rule governing the fixture’s test command. Docker documents that this integration gets project-level configuration from the working directory. Verify the observed behavior before interpreting a difference between local TUI runs and a hosted runner as a model-quality difference.

OpenCode | Docker Docs

Use a dependency fixture before quoting hosted capacity

Cloudflare’s documented OpenCode example routes inference through AI Gateway and limits sandbox network reach to the gateway and GitHub. Put a representative dependency in the acceptance test alongside the diff. A repository with vendored dependencies can qualify with a build from checkout and a verified diff. For a job that needs an approved private package registry during execution, explicitly identify how that dependency would reach the sandbox and verify the resulting build against the same fixture. Record launch-to-diff time, total metered duration, and whether a second attempt needed a fresh checkout or dependency restore. A standing worker can remove repeated setup if it preserves the needed state. Compare the observed time savings with fixed charges and per-job charges, and measure first-job latency after a quiet period separately from the average across a burst.

Run OpenCode in a sandbox · Cloudflare Sandboxes docs

Test approvals and isolation independently

OpenCode’s security policy says the agent has no built-in sandbox. Before setup, list the checkout, writable output directory, and network destinations the job needs. Set the runtime to expose only those resources. Check the installed OpenCode version and use its matching permission documentation when deciding which actions require a person’s approval. Review any delegated agent’s effective permissions independently.

Use harmless fixtures to test both controls. Put one sample file in the workspace and another outside the paths you intend to expose. An approved task should be able to edit the first, while the runtime should prevent it from reading the second. If approval changes which host files are reachable, fix the mount or runtime policy before running the real job.

opencode/SECURITY.md at dev · anomalyco/opencode · GitHub

Pick the local workspace exposure

Docker’s local OpenCode guide documents sbx run opencode ~/my-project for launching against a project directory. Substitute the path to a disposable checkout and select the model provider in the terminal interface. For a trial that needs no project files, Docker also documents creating a sandbox without a workspace path and attaching by name.

Use the project-backed option when you want to inspect a change in your checkout immediately. In an illustrative trial, make a small README edit and confirm the diff contains only the requested lines. Use the mountless option when the task only needs supplied inputs or fixtures. If the mounted trial exposes sibling projects or fails because it depended on host-specific setup, revisit the workspace and bootstrap before expanding access.

OpenCode | Docker Docs

Test whether a narrow hosted route fits

Cloudflare’s OpenCode example routes model calls through AI Gateway. The Worker adds the gateway token to those requests, and the documented sandbox can reach the gateway and GitHub. Start with the sandbox coding-agent runner project, apply the OpenCode guide’s image, model, and Durable Object changes, and configure the provider credentials in AI Gateway.

For an illustrative smoke test, use a fixture GitHub repository and ask for one documentation correction. Collect the resulting diff and confirm that a request to a harmless domain you control outside the allowed destinations fails. If a clean build requires a package registry, the documented configuration will need a different dependency strategy. Try packaging the required dependencies in the image, then repeat the build under the same egress policy.

Run OpenCode in a sandbox · Cloudflare Sandboxes docs

Sources