sandbox_exec
This remote connection cannot read or upload files from the person's computer. A local path such as /Users/me/project is not accessible from a box. Do not start a box or run commands merely to probe that laptop path; ask for an accessible repository or an authorized transfer first. Run a bash command on the box. Foreground returns stdout, stderr (the last 16 KB of each; when truncated, outputUrl has it all), exitCode and an execId; background returns a bgId and a log path. pkill -f and pgrep -f match any other job whose command line holds the pattern; sandbox_procs stops one background job by its bgId. Secret and setting values come back as ****. A foreground command's screen changes are recorded, with a screenshot at the end, and shown to the person beside that step (the recording for 7 days, the screenshot for 30); browser and app tests run headed on the display (DISPLAY=:99 is set) show up in that recording. Commands run as root, so Chromium and Electron need --no-sandbox; tests of programs that switch uid need user: "tester". Output is not a TTY, so test runners print CI formats (node --test prints TAP). The clock is UTC and browsers default to en-US: start Chromium with TZ= and --accept-lang= (Playwright: timezoneId, locale). A Chromium window is at least 500 px wide; on the portrait screen (390x844) use --force-device-scale-factor=0.78 --window-size=500,1082 --window-position=0,0 to fill it (only for you; hand over a tab recording). For a page narrower than that, add --remote-debugging-port=9222 and call sandbox_shot target tab with width: the box keeps that viewport. Containers resolve names through the box's DNS at 172.17.0.1: give that to nginx's resolver (127.0.0.11 exists only on user-defined networks). With an environment's AWS role, docker run -e AWS_CONTAINER_CREDENTIALS_FULL_URI -e AWS_REGION gives containers its credentials. The browsers match Playwright 1.56.0: for another version run npx playwright install chromium first. A test starting its own ibus-daemon needs env -u IBUS_ADDRESS.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"id": "<id>",
"cmd": "<cmd>",
"note": "<note>"
},
"name": "sandbox_exec"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Box id from sandbox_start | |
| cmd | Yes | bash command line. To write a file, use a quoted heredoc (cat > f <<'EOF' … EOF): nothing inside it is expanded and backslashes stay as written. Send big files or many files with sandbox_sync instead of putting them in cmd | |
| cwd | No | Relative to /work (default /work) | |
| note | Yes | One short sentence, in the language requested by the person (English by default), saying what this step is for ("build the refund service"). The person watching sees it in their app instead of the raw command, as what the box is doing right now. It stays on the box's timeline for 7 days (30 when the step leaves a screenshot), shown to everyone who opens the box: if you will hand it to someone who reads another language (a reviewer, a client), write it in theirs. sandbox_review with clearActivity hides the earlier steps | |
| user | No | Default root. tester runs the command as a non-root user with its own HOME, TMPDIR (/tmp/u<uid>), GOPATH and npm cache; root-owned files under cwd are handed to it so it can write there. Use it for tests of programs that switch uid (setpriv, per-user isolation) or refuse to run as root | |
| strict | No | Prepend set -eo pipefail, so exitCode is that of the first failing command or pipeline stage. Without it exitCode is the last command's only: a failing test piped to tee, or followed by another line, reports 0 | |
| baseline | No | Run the same command in cwd and then in the same place in <dest>-baseline, the earlier tree sandbox_sync baseline sent, and compare the failing tests (go test, node --test, jest, vitest, pytest), timings and numbering ignored: onlyMine fails only with your changes, alreadyFailing in both, fixedByMine only before them. cwd must be inside a dest you synced with baseline. Both full outputs stay in /work/.sbx/logs | |
| readOnly | No | For a foreground command that only reads (logs, files, status): it runs without DISPLAY and records nothing. Do not use it to look at or drive the screen | |
| readyLog | No | With background: a regular expression (RE2); the job counts as ready once a line of its log matches it, e.g. "Listening on|ready in" | |
| readyPort | No | With background: the job counts as ready once this port accepts connections on 127.0.0.1 or ::1; sandbox_procs wait with until "ready" returns then | |
| tailBytes | No | Foreground: keep only the last this many bytes of stdout and of stderr (default and max 16384). What comes before is cut: truncated is true and outputUrl links the complete output, both streams in order | |
| background | No | Return a bgId; the process keeps running after the call, output at /work/.sbx/logs/<bgId>.log. Use it for anything that keeps running (dev servers, watchers, emulators): a foreground call returns once its shell exits and does not track what it started with & or setsid (leftoverChildren), and those lose this call's output. sandbox_procs lists, waits for and stops these jobs by bgId. Programs buffer output written to a file: PYTHONUNBUFFERED=1 is set, but put sed -u, grep --line-buffered or stdbuf -oL in a pipeline, or its lines reach the log only when the buffer fills or the job ends. Wrap long scripts' steps in psbx-step <name> -- <command> to see in sandbox_procs which step runs, failed and how long each took | |
| timeoutSec | No | Foreground timeout, default 600, max 3600. On timeout the whole process group gets SIGKILL, including anything the command started with &. If the call itself is cut off (the connection drops), the command keeps running until it ends or this runs out: the result has an execId, and sandbox_procs wait with bgId set to it returns the result. Over a remote connection from ChatGPT or Codex, which ends a tool call after about 5 minutes, a foreground command still running after about 270 seconds returns stillRunning: true with that execId and keeps running |