Skip to content
For agents
Browse guides

Work in a sandbox

Open a Linux shell with SSH, run your project’s tests, preview a server over a private HTTP port, then pause or fork the session.

Open Markdown

Open a private Linux machine on your workspace worker. Bring your source files, run your own tools and keep the same machine between commands.

Open a terminal

If you already have a running session, use it here. Otherwise, start a sandbox. In the dashboard, open Sessions and select Terminal on the running session.

For the CLI steps below, sign in and set these two variables in a terminal on your computer. Replace the placeholders with the IDs printed by smolcloud sandbox new.

Shell
ENV_ID=YOUR_ENVIRONMENT_UUID
SESSION_ID=YOUR_SESSION_UUID

On Linux or macOS with OpenSSH, you can open an interactive shell with smolcloud sandbox ssh "$ENV_ID" "$SESSION_ID". Type exit to return to your computer. Closing the shell leaves the session subject to its idle pause and deadline. For a longer run, choose a session duration.

Bring files and run tests

Run these commands on your computer, from your project directory. This example uses a Python project with app.py, tests/test_app.py and Python’s built-in unittest. Use your own source files, tests and a template with the tools they need.

Shell
smolcloud sandbox exec "$ENV_ID" "$SESSION_ID" -- mkdir -p /tmp/project/tests
smolcloud sandbox write "$ENV_ID" "$SESSION_ID" /tmp/project/app.py ./app.py
smolcloud sandbox write "$ENV_ID" "$SESSION_ID" /tmp/project/tests/test_app.py ./tests/test_app.py

For write, the sandbox path comes first and the file on your computer comes last. Run the tests from the project directory inside the sandbox.

Shell
smolcloud sandbox exec "$ENV_ID" "$SESSION_ID" -- /bin/sh -c 'cd /tmp/project && python3 -m unittest discover -s tests -v'

You’ll see the test output in your terminal. A failing test gives the CLI a nonzero exit code, so an agent can check the result too. Each exec starts a new process. Files you edit in the sandbox stay there between commands.

Reach a private port

If your server is already running in the sandbox, use its port and path below. It must listen on 0.0.0.0 for the workspace API to reach it.

To try this on a Python 3 template, open Terminal in the sandbox. Serve a single text file and leave the server running.

Shell
preview_dir=$(mktemp -d)
printf 'Sandbox is ready\n' > "$preview_dir/index.html"
python3 -m http.server 8000 --bind 0.0.0.0 --directory "$preview_dir"

Check from the CLI. On your computer, run the following in the terminal where you set your session IDs. This uses curl inside the sandbox. You should see HTTP status 200 followed by the headers and Sandbox is ready.

Shell
smolcloud sandbox exec "$ENV_ID" "$SESSION_ID" -- curl -siS http://127.0.0.1:8000/

Read the response through the workspace API. On your computer, set WORKSPACE_URL to your HTTPS management address and WORKSPACE_ID to your workspace ID. Your signed-in CLI prints it as tenantId when you run smolcloud doctor. Set WORKSPACE_TOKEN from your secret store using a personal token from Settings → CLI or your agent’s own credential.

This request uses local curl and jq. The API returns the guest server’s status and a base64-encoded body. The last line prints the status and decodes the text.

Shell
SESSION_URL="${WORKSPACE_URL%/}/api/sandbox-environments/$ENV_ID/sandbox-sessions/$SESSION_ID"
printf 'Authorization: Bearer %s\n' "$WORKSPACE_TOKEN" |
  curl -fsS "$SESSION_URL/ports" -H @- -H "X-Innie-Workspace: $WORKSPACE_ID" \
    -H 'Content-Type: application/json' -d '{"port":8000,"path":"/","method":"GET"}' |
  jq -r '"HTTP \(.status)\n\(.bodyBase64 | @base64d)"'

For the server above, expect HTTP 200 and Sandbox is ready. If the guest returns 404, check the path you requested. If the CLI check succeeds but the API cannot reach the server, check its bind address and port. Press Ctrl+C in the sandbox terminal to stop the example server.

Session ports are private. For a team link, deploy the app. For event streams, binary responses or WebSockets, see Private HTTP and WebSockets.

Save your changes

After editing a file in the sandbox, download it on your computer. Choose a new filename so you can compare it with your original.

Shell
smolcloud sandbox read "$ENV_ID" "$SESSION_ID" /tmp/project/app.py > app.from-sandbox.py
diff -u app.py app.from-sandbox.py

diff shows which lines changed. Keep the files you want before you stop the session. You can also save files to a workspace bucket.

Pause, fork or finish

To pick up where you left off, open Sessions, select Pause, and wait until the session shows Paused and a time to resume by. Closing the terminal alone leaves the session running.

Pauses and snapshots live on the worker’s disk. If that disk fails, you can lose both. Copy important files to your computer before pausing.

From your computer, you can request the pause and check its progress with the CLI.

Shell
smolcloud sandbox pause "$ENV_ID" "$SESSION_ID"
smolcloud sandbox sessions "$ENV_ID"

Find your SESSION_ID in the list. Run the second command again until its state is paused. That confirms the save. pauseExpiresAt tells you when it expires.

When you return, select Resume in Sessions, or use the same IDs in the CLI. The second command waits until the session is ready for your next command.

Shell
smolcloud sandbox resume "$ENV_ID" "$SESSION_ID"
smolcloud sandbox wait "$ENV_ID" "$SESSION_ID"

Your files and programs resume where they left off. Reopen your terminal. If the session used database or bucket grants or a named agent credential, reconnect them.

  • Fork to try a change in a second session. The original continues after a brief pause. Your workspace needs room for both.
  • Save snapshot to keep a starting point you can reuse. Once the snapshot is ready, choose Snapshots → Start copy to start a new session from it.
  • Stop when you’ve copied out everything you need. smolcloud sandbox stop "$ENV_ID" "$SESSION_ID" deletes that session’s files.

Snapshot and fork API · How long saved sessions and snapshots last.

A running guest can use a database or bucket through an explicit grant. For model-guided commands with an approved workspace key, use an app-backed agent job. Sandbox capabilities explains limits and access. One-off jobs are also available for commands that only need a final result. The sandbox command reference lists the full CLI syntax.