# Use case: a coding agent that keeps working after you close the laptop

> Running Claude Code, Codex or Gemini CLI inside a Sandscale workspace instead of on your machine: setup with the CLI, attaching from any device, schedules and idle stop, what to give the agent, and when a sandbox or Agent Cloud fits better.

Running Claude Code, Codex or Gemini CLI inside a Sandscale workspace instead of on your machine: setup with the CLI, attaching from any device, schedules and idle stop, what to give the agent, and when a sandbox or Agent Cloud fits better.

November 27, 2026 · 4 min read · The Sandscale team

A coding agent on your laptop stops when your laptop does. Close the lid on the way to a meeting and the long refactor you started is paused until you are back, if the terminal session survives at all. The usual workaround is a cloud VM you set up by hand, with your SSH keys, your tools and your agent installed, which you then forget to turn off.

Sandscale workspaces are built for this case. The [workspaces concept page](https://sandscale.dev/docs/concepts/workspaces) describes one as a persistent cloud computer for coding agents and for you: its files survive, you open it in the browser or over SSH, and it stops when nobody is using it. This post walks through using one for a long-running agent session, based on the [workspace guide](https://sandscale.dev/docs/guides/workspaces) and the [CLI reference](https://sandscale.dev/docs/reference/cli/workspace).

## Workspace or sandbox?

Sandscale has both, and they solve different problems.

- **A sandbox** is a throwaway box. It starts from a template or snapshot, runs, and when it stops its disk is deleted. It is the right place for code you do not trust and for anything you want to start clean every time.
- **A workspace** keeps its disk. Your repository, branch, installed tools and the agent’s session are still there the next time you open it. It is the right place for your own ongoing work, with an agent working alongside you.

For “keep my agent going on this repo while I am away”, a workspace is the fit. For “run this untrusted install script”, a sandbox is.

## Set it up

From the guide, with the CLI installed and signed in:

```bash
sandscale workspace templates list
sandscale workspace create payments-dev --template go-service
sandscale workspace open payments-dev
```

A template is the machine your organization set up: image, size and tools. `templates show NAME` lists any parameters, filled in with `--param KEY=VALUE`. The first build takes a while; `sandscale workspace logs payments-dev` shows it.

`open` starts the workspace if it is stopped, waits until it runs and connects over SSH with a short-lived certificate and a checked host key. `--ide browser` opens it in the browser instead, and editors that connect over SSH, such as VS Code or Cursor, use `sandscale workspace ssh`. The SDKs can list, start, stop and connect to workspaces; creating one is done with the CLI or the console.

## Run the agent inside it

Once connected, install and run your agent in the workspace the way you would locally. The concepts page names Claude Code, Codex, Gemini CLI or your own agent. Run it inside a terminal multiplexer such as `tmux`, so the session belongs to the workspace and not to your SSH connection. Then:

- Close your laptop. The SSH connection drops; the agent’s session keeps running on the workspace.
- Later, from any device, `sandscale workspace ssh payments-dev` and reattach.

The [editors and devices page](https://sandscale.dev/workspaces/editors) puts it as: the agent’s session lives on the workspace, not your laptop.

If the agent runs a dev server, reach it with port forwarding:

```bash
sandscale workspace port-forward payments-dev 3000 5432:5432
```

Each port listens on `127.0.0.1` on your computer and reaches the workspace through SSH until you press Ctrl+C. Nothing is opened to the internet.

## Schedules and idle stop

A workspace that runs all night by accident is the cloud-VM problem again. Workspaces have two controls:

- **Idle stop.** A workspace stops when it has been idle for a while; `sandscale workspace schedule idle payments-dev 30m` sets how long.
- **Schedules.** `schedule start payments-dev "30 8 * * 1-5" --timezone Europe/Berlin` starts it at 08:30 on weekdays, and `schedule stop payments-dev 8h` stops it 8 hours after each start. Your organization’s policy can shorten what you set, and `schedule show` prints the values in force.

Hours count against your plan only while the workspace runs, and stopping keeps the disk. For an agent left working overnight, decide in advance how long it may run, and set the stop schedule to match. Before relying on idle stop during a long unattended task, check with `schedule show` and a short test that the workspace stays up while your agent is busy and stops when it is done; that way the behaviour you depend on is one you have seen.

## What to give the agent

A workspace is your computer in the cloud, so the security question is the same as on your laptop: what can the agent reach?

- **Repository access.** The agent needs to push a branch, not to merge to main. A token or deploy key scoped to the repository, with branch protection on main, keeps a bad night to a bad branch.
- **Secrets.** Put the ones the agent needs in [Vault](https://sandscale.dev/security/vault), not in a dotfile on the disk. A persistent disk is persistent for secrets too.
- **Policy.** [Agent policy](https://sandscale.dev/security/agent-policy) can allow, block or send a step to a person, and [approvals](https://sandscale.dev/security/approvals) route risky calls to a named approver. For unattended work, decide which commands should wait for you in the morning rather than run.
- **Throwaway work in sandboxes.** If the agent needs to run something untrusted, such as a third-party script or an unfamiliar repo’s install, it can use the [Sandscale MCP server](https://sandscale.dev/blog/remote-vs-local-sandscale-mcp-server) to do that in a sandbox instead of on the workspace’s disk.

Starts, stops and wakes are recorded in the audit log, per the [schedules page](https://sandscale.dev/workspaces/schedules).

## When Agent Cloud fits better

If what you want is “give this task to an agent and get a pull request back”, rather than “keep my own session alive”, [Agent Cloud](https://sandscale.dev/agent-cloud) does that on top of workspaces: each task runs in a workspace of its own, you can watch it step by step, and the result is a branch and a pull request, never a push to main. The plans reference lists Agent Cloud on Pro, Team and Enterprise.

## Which plan

The [plans reference](https://sandscale.dev/docs/reference/plans) lists workspaces on every plan. Workspaces use your plan’s vCPU-hours only while they run.

**On this page**

1. Workspace or sandbox?
2. Set it up
3. Run the agent inside it
4. Schedules and idle stop
5. What to give the agent
6. When Agent Cloud fits better
7. Which plan

**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 27, 2026 · **A LlamaIndex.TS data agent that runs its Python in a Sandscale sandbox** · Use LlamaIndex.TS's agent workflow with tools that write and run Python in a Firecracker sandbox, built per sandbox so a run can only reach its own box. Upload data files, answer with the numbers, clean up. Type-checked.](https://sandscale.dev/blog/llamaindex-ts-agent-with-sandscale)
- [November 27, 2026 · **Adding the Sandscale MCP server to Codex: config.toml, OAuth login and approval modes** · Configure the remote or local Sandscale MCP server in OpenAI Codex, sign in with codex mcp login, and use enabled_tools, approval modes and tool timeouts to match what each tool does.](https://sandscale.dev/blog/sandscale-mcp-server-in-codex)

---
Source: https://sandscale.dev/blog/use-case-long-running-agent-in-a-workspace
