Execute a shell command in a sandbox
exec_commandExecute a shell command (bash -lc) in a sandbox as root and return {exit_code, stdout, stderr, timed_out, truncated, duration_ms}. Shell operators are fine and never filtered: apt-get update && pip install x | tee log; echo done > out. If you call the server with raw HTTP/curl, the JSON body must be valid — escape double quotes inside command (") or build the body with a JSON library; a broken body returns a JSON-RPC parse error (-32700), not a firewall block. Optional cwd (default /root) and timeout (default 30 s, max 55 per call). For commands longer than 55 s (builds, training, long downloads) set background: true: you get a task_id at once, then poll get_task for output and the exit code; kill_task stops it. Requires: token + live sandbox_id. Typical: timed_out after 55 s → repeat with background: true; 404 → sandbox expired, create a new one.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | No | ||
| env | No | Environment variables for this command only (override the ones set at create_sandbox). | |
| command | Yes | ||
| timeout | No | Seconds. Synchronous: max 55. With background: true: up to the sandbox's remaining lifetime (default). | |
| background | No | ||
| sandbox_id | Yes | Sandbox id as returned by create_sandbox / list_sandboxes, e.g. "sb_3f2a…". |