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
- One workspace per agent and task. Each has its own checkout, dependencies and disk, so runs do not step on each other.
- You start each agent in the evening, in a terminal session that survives disconnecting.
- A time to live caps how long each workspace runs after it starts.
- An autostart schedule brings the workspaces back in the morning, with their disks, so you can review.
Create a workspace per task
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 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:
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 and 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
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
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.
To see the workspace as the server has it, after any clamping by your organization's policy:
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-secondsoncreateorupdatesets 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 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 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 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 on its own. In the morning you review a set of branches, not a tangle.
To create your first workspace, start with the Quickstart and the workspace guide.
Originally published on the Sandscale blog.

