DEV Community

Sandscale
Sandscale

Posted on Originally published at sandscale.dev

A sandbox for Codex: running codex exec in a cloud workspace

Short answer: Codex has its own sandbox modes, but they still run on the machine Codex runs on. To keep the whole run off your laptop, run Codex on a cloud computer and call codex exec there. A Sandscale workspace is a Firecracker microVM with its own kernel and a disk that persists, and sandscale workspace ssh NAME -- COMMAND lets you start the run from your own terminal.

Sources, read in November 2026: OpenAI's Codex non-interactive mode page, and Sandscale's workspaces guide and workspace CLI reference.

Codex's sandbox and a workspace are different layers

Per OpenAI's docs, codex exec runs in a read-only sandbox by default. --sandbox workspace-write allows edits, and --sandbox danger-full-access allows broader access, which the docs say to use only in a controlled environment such as an isolated CI runner or container.

Those modes limit what Codex may do on its host. A workspace changes what the host is. Combining them gives you two independent checks: Codex's mode inside, and a separate microVM with its own kernel outside, so even a run with broad access lands on the workspace's disk.

1. Create a workspace for Codex

sandscale login
sandscale workspace templates list
sandscale workspace create codex-box --template TEMPLATE
sandscale workspace open codex-box
Enter fullscreen mode Exit fullscreen mode

TEMPLATE is a name from templates list. Inside the workspace, install Codex as OpenAI's docs describe, sign in, and clone your repository. The disk persists, so you do this once. Codex calls OpenAI's API, so the workspace needs network access; network follows your plan and your organization's policy, so check that yours lets the workspace reach that API.

2. Run codex exec on the workspace

From inside the workspace:

cd ~/src/my-service
codex exec --sandbox workspace-write "run the tests, fix the first failure, and explain the fix"
Enter fullscreen mode Exit fullscreen mode

While it runs, Codex streams progress to standard error and prints only the final agent message to standard output, so you can redirect it:

codex exec --sandbox workspace-write "update the changelog for the last 10 commits" | tee changelog-notes.md
Enter fullscreen mode Exit fullscreen mode

For machine-readable output, --json turns standard output into a JSON Lines stream of events such as thread.started, turn.completed, turn.failed and item.*. --ephemeral skips writing session rollout files to disk.

3. Start it from your laptop

sandscale workspace ssh runs everything after -- on the workspace, with a short-lived certificate and a checked host key:

sandscale workspace ssh codex-box -- 'cd ~/src/my-service && codex exec --sandbox workspace-write "fix the lint errors"'
Enter fullscreen mode Exit fullscreen mode

Per the CLI reference, ssh joins the words after -- with spaces, as ssh does, so quote the remote command as one string. If the workspace is stopped, sandscale workspace open codex-box starts it first.

For long tasks, start Codex inside tmux on the workspace instead and detach, so the run does not depend on your SSH session.

4. Feed it logs without copying them around

OpenAI's docs show piping input into codex exec, with the prompt as the instruction and standard input as context. On a workspace that is handy for test output that never leaves the machine:

npm test 2>&1 | codex exec "summarize the failing tests and propose the smallest likely fix" > test-summary.md
Enter fullscreen mode Exit fullscreen mode

5. Stop it when the run is done

sandscale workspace schedule stop codex-box 8h
sandscale workspace stop codex-box
Enter fullscreen mode Exit fullscreen mode

The first stops the workspace 8 hours after each start; the second stops it now. Stopping keeps the disk. A workspace also stops when idle, and it uses your plan's vCPU-hours only while it runs.

Project trust and MCP servers

OpenAI's docs say local codex exec runs load project configuration and project-defined MCP servers only for trusted projects, and that project-defined MCP servers can run commands outside Codex's sandbox. On a workspace, "outside the sandbox" still means inside the microVM, which is one more reason to give Codex its own workspace rather than your laptop. If you want Codex on your laptop instead, with only commands going to Sandscale, see adding the Sandscale MCP server to Codex.

FAQ

What sandbox does Codex use by default?

Per OpenAI's docs, codex exec runs in a read-only sandbox by default. --sandbox workspace-write allows edits and --sandbox danger-full-access allows broader access.

How do I run Codex outside my own machine?

Install Codex on a cloud workspace and run codex exec there, either in a shell on the workspace or from your laptop with sandscale workspace ssh NAME -- COMMAND. The workspace is its own Firecracker microVM.

Can I get Codex output as JSON?

Yes. codex exec --json makes standard output a JSON Lines stream of events. Without it, only the final agent message goes to standard output.

Does the workspace keep Codex's sign-in and my clone?

Yes. A workspace keeps its disk when it stops. Deleting it with sandscale workspace delete deletes its disks.

Related

Originally published on the Sandscale blog.

Top comments (0)