Sandbox tools
Every sandbox_* tool the sandbox plugin gives your agent, with its arguments.
This is the reference for the sandbox_* tools that @gitterm/opencode-sandbox adds to your local agent. You never call these yourself: you ask in plain words, and the agent picks the tools and arguments. Use this page to read what the agent did, or to write instructions for it. The tools work only after you add a sandbox account; see Setup.
Every tool except sandbox_create and sandbox_list takes a sandboxId, from sandbox_create or sandbox_list. A sandbox belongs to the account that created it. Using it while another account is selected is an error. A managed sandbox that paused while idle resumes when a tool next uses it; see Pausing.
Sandbox output is wrapped in an untrusted block that tells the model to treat it as data, not instructions.
The approval actions and how to pre-approve them are in Setup.
sandbox_create
Creates a sandbox. Billing starts now. No coding agent runs in it.
Creation fails when the account already has maxSandboxes live sandboxes. What happens at the end of the lifetime depends on the account and provider; see Providers.
sandbox_list
Shows the selected account and its live sandboxes, checked against the provider. No arguments.
- For the account: the mode, account, and provider, where the key comes from and whether it is present, who is charged, the limits, and the provider's limitations. It never shows the key.
- For each sandbox: state, age, expiry, who is billed, the last synced snapshot, running jobs, and previews.
sandbox_sync
Uploads the session's working tree as it is on disk to ~/project in the sandbox. This includes uncommitted changes and untracked files that are not ignored. Files you deleted locally are deleted there too. Your local files do not change.
- The approval prompt lists modified, untracked, deleted, and excluded files.
- The result shows the snapshot id and sha256 digest, and confirms the files were verified in the sandbox.
- Ignored files already in the sandbox, such as
node_modulesfrom an earlier install, stay in place. - It refuses a checkout over 100 MiB, with submodules, or with unresolved merge conflicts. It needs a Git checkout.
What is uploaded and what is always left out: Security.
sandbox_exec
Runs a shell command in the sandbox as a job. It returns when the job finishes or after waitSeconds, whichever comes first. A job that is still running keeps going; read it later with sandbox_job.
The result shows the job id, status, exit code, the snapshot it ran on, and the last 8 KiB of output. A non-zero exit is a failed job, not a tool error.
Job statuses, timeouts, and how secretEnv values stay out of output: Jobs and previews.
sandbox_job
Shows a job's status and part of its output, or cancels the job. It still works after OpenCode restarts.
Use either waitSeconds (wait, then show the last 8 KiB) or offset and limit (read a range). With offset set, waitSeconds is ignored. With cancel set, the job is cancelled and the others are ignored.
sandbox_preview
Exposes a port in the sandbox and waits up to 60 seconds for it to answer. If you pass command, it starts that server as a job first.
The result shows the URL, whether it is public or private, the status a request without access gets, and the server job id. The access header is never shown to the model.
Private and public previews, the local proxy, and provider port limits: Jobs and previews.
sandbox_artifact
Downloads one file a job produced into a local staging directory outside your checkout, and checks its hash. Your project files do not change.
The result includes localPath, which sandbox_apply needs.
sandbox_apply
Copies a downloaded file into your checkout. It refuses if the target changed locally since the job's snapshot.
When apply refuses and what to do: Artifacts.
sandbox_destroy
Deletes the sandbox. It reports the sandbox terminated only once the provider confirms it is gone, and closes any local preview proxies for it.
sandbox_snapshot
Saves a sandbox as a setup snapshot that new sandboxes can start from, or deletes one. The tool exists only when the snapshots option is on; see Setup snapshots.