# Overnight coding agent runs: one workspace per agent, started by you, stopped and woken on a schedule

> How a team can leave several Claude Code or Codex runs going overnight, each on its own cloud machine, with a time to live to cap the run and an autostart schedule to bring the machine back for review. What these settings do, what they do not do, and what to check first.

How a team can leave several Claude Code or Codex runs going overnight, each on its own cloud machine, with a time to live to cap the run and an autostart schedule to bring the machine back for review. What these settings do, what they do not do, and what to check first.

November 30, 2026 · 5 min read · The Sandscale team

Some agent work does not need anyone watching: a dependency bump across packages, a test suite to get green, a refactor with a clear spec. Teams that use Claude Code or Codex often want to hand that work to agents at the end of the day and review the result in the morning.

On a laptop, that means leaving the laptop open, awake and online all night, running one agent at a time. With one cloud machine per agent, it means starting a few runs, closing the laptop, and finding a branch on each machine when you are back. This post covers how to set that up with Sandscale workspaces, using the forms in the `--help` of the Sandscale CLI (version 1.4.1).

## The shape of it

1. One [workspace](https://sandscale.dev/workspaces) per agent and task. Each has its own checkout, dependencies and disk, so runs do not step on each other.
2. You start each agent in the evening, in a terminal session that survives disconnecting.
3. A time to live caps how long each workspace runs after it starts.
4. An autostart schedule brings the workspaces back in the morning, with their disks, so you can review.

## Create a workspace per task

```sh
sandscale workspace templates-list
sandscale workspace create --name agent-deps --template-id TEMPLATE_ID
sandscale workspace create --name agent-tests --template-id TEMPLATE_ID
```

`create` answers with each workspace’s id, which the settings below take as `--ws-id`. `sandscale workspace list` shows them again. Connect to each one, clone the repository, and sign the agent in, the way you would on a new laptop. A workspace keeps its disk, so you do this once. The [workspace concepts page](https://sandscale.dev/docs/concepts/workspaces) says your repository, branch, installed tools and the agent’s session are still there the next time you open it.

## Start the runs

Connect to the workspace and start the agent inside `tmux` (install it first if your template does not have it), so the run keeps going when you disconnect:

```sh
sandscale workspace ssh agent-tests
tmux new -s run
```

In the tmux session, start the agent non-interactively with the task, for example with `claude -p` or `codex exec`. Each one has its own flags for what the agent may do without asking, which matters when nobody is there to answer. Our posts on [Claude Code headless in a cloud workspace](https://sandscale.dev/blog/claude-code-headless-in-a-cloud-workspace) and [codex exec in a cloud workspace](https://sandscale.dev/blog/codex-exec-in-a-cloud-workspace) cover those flags. Ask the agent to commit to a branch and push it, so the result does not depend on the machine at all.

Detach with `Ctrl-b d`, close the connection, and repeat for the next workspace.

## Cap the run with a time to live

```sh
sandscale workspace update --ws-id WORKSPACE_ID --ttl-seconds 36000
```

The CLI’s help describes the time to live as the maximum runtime in seconds since the workspace started, checked against and clamped to your organization’s lifecycle policy; 0 uses the organization’s maximum. Choose a value that fits the task. You can also set it when you create the workspace. A running workspace uses your plan’s vCPU-hours whether the agent is busy or waiting, so a cap matters. When it stops, the disk is kept.

## Bring it back in the morning

```sh
sandscale workspace update --ws-id WORKSPACE_ID --autostart-schedule "CRON_TZ=America/New_York 30 8 * * 1-5"
```

This is a cron expression with an optional `CRON_TZ=` prefix, and it starts the workspace at 08:30 on weekdays, New York time. The help calls this the legacy form of `--autostart`, which takes a JSON schedule evaluated in an IANA time zone (your profile’s zone, else UTC, when none is named); we use the cron form here because its format is spelled out. Name the zone when the team spans zones. When you arrive, the workspace is running with the agent’s checkout and the tmux session’s history on disk. Forward the dev server to look at the app, as described in our post on [port-forwarding a dev server from a workspace](https://sandscale.dev/blog/port-forwarding-a-dev-server-from-a-workspace).

To see the workspace as the server has it, after any clamping by your organization’s policy:

```sh
sandscale workspace get --ws-id WORKSPACE_ID
```

Check it before you rely on a schedule.

## Check these before the first overnight run

The docs leave some things for you to confirm, so test them with a short run before trusting a whole night to them:

- **Idle stop.** A workspace also stops when idle. `--idle-timeout-seconds` on `create` or `update` sets how long, at least 300 seconds and within your organization’s maximum; 0 uses the organization’s default. The docs do not say what counts as activity, so we do not know whether an agent working in a detached tmux session keeps a workspace from being treated as idle. Start a short run, disconnect, and see whether it is still running later.
- **Session length.** The [pricing page](https://sandscale.dev/pricing) lists a session length per plan. Check how it applies to your workspaces before you plan a long run around it.
- **Hours.** If your plan’s included hours run out, the pricing page says running boxes stop on Free, and on paid plans they stop unless you have turned on usage beyond your included hours. Workspaces keep their disk when they stop.
- **Approvals.** If your organization’s [policies](https://sandscale.dev/docs/concepts/approvals) put an approval gate on starting workspaces or running agents, a scheduled start may wait for a person. That is the gate doing its job, so plan for it.

## Or hand the tasks to Agent Cloud

If you would rather not manage the tmux sessions yourself, [Agent Cloud](https://sandscale.dev/docs/concepts/agent-cloud) gives coding tasks to agents running in your workspaces, lets you watch them work, and returns a branch and a pull request for each. A lead agent can hand out tasks to other agents and collect the pull requests. It comes with Pro and up, because it needs network access, which Free does not have.

## Why one machine per agent

Several overnight runs on one shared machine compete for its ports, dependencies and disk, and one bad run can break the others. One workspace per agent keeps each run separate, gives each its own schedule, and puts each in the [audit log](https://sandscale.dev/docs/concepts/audit) on its own. In the morning you review a set of branches, not a tangle.

To create your first workspace, start with the [Quickstart](https://sandscale.dev/docs/quickstart) and the [workspace guide](https://sandscale.dev/docs/guides/workspaces).

**On this page**

1. The shape of it
2. Create a workspace per task
3. Start the runs
4. Cap the run with a time to live
5. Bring it back in the morning
6. Check these before the first overnight run
7. Or hand the tasks to Agent Cloud
8. Why one machine per agent

**Run your agents in a box of their own**

Each sandbox is a Firecracker microVM. Free includes 100 awake vCPU-hours a month.

[Start free](https://cloud.sandscale.dev/auth/signup)

## Keep reading

- [November 30, 2026 · **MCP servers your team's agents install: run them on the agent's own machine, not the laptop with everyone's keys** · A local MCP server runs with the same rights as the client that starts it. What the MCP spec's security guidance says about that, and how to put the coding agent and its MCP servers on a microVM of their own, with no code to write.](https://sandscale.dev/blog/running-untrusted-mcp-servers-in-a-microvm)
- [November 30, 2026 · **MCP tool annotations explained: what readOnlyHint and destructiveHint mean for teams approving agent tool calls** · What each MCP tool annotation means according to the spec, what Claude Code, Codex and Cursor do with them according to their docs, and how a team using coding agents can decide what to auto-approve and what a person must see.](https://sandscale.dev/blog/mcp-tool-annotations-explained)

---
Source: https://sandscale.dev/blog/scheduling-workspaces-for-overnight-agent-runs
