# When the laptop sleeps or the connection drops, the coding agent should keep working

> A coding agent started in a terminal on a laptop stops when the lid closes, the power goes, or the office connection drops for ten minutes. What actually breaks, how to set up an agent on its own cloud machine so a disconnect is only a disconnect, and what to check before you rely on it.

A coding agent started in a terminal on a laptop stops when the lid closes, the power goes, or the office connection drops for ten minutes. What actually breaks, how to set up an agent on its own cloud machine so a disconnect is only a disconnect, and what to check before you rely on it.

December 2, 2026 · 5 min read · The Sandscale team

Most coding agent sessions start the same way: someone opens a terminal on their laptop, starts Claude Code or Codex, gives it a task, and watches. That works until the laptop goes to sleep, the battery runs out, the power goes, the office Wi-Fi drops, or the VPN reconnects. Then the agent stops in the middle of whatever it was doing, and someone has to work out what state it left the repository in.

For one developer this is an annoyance. For a team that has started handing agents longer tasks (a dependency upgrade across a monorepo, a migration, a large test-fixing pass), it is the main reason those tasks fail. This post is about separating “my connection to the agent” from “the agent’s work”, so the first can drop without killing the second.

## What actually breaks

It helps to be precise, because the fixes are different.

- **The process dies with the machine.** If the agent runs on the laptop, sleep or a power cut stops it. Nothing on the laptop can fix that.
- **The process dies with the terminal.** If the agent runs on a remote machine but in the foreground of an SSH session, a dropped connection can take it down with the session.
- **The task is lost even if the process survives.** An agent that was halfway through edits, with nothing committed, leaves a working tree nobody can read with confidence.
- **The person cannot see what happened.** Without a way to reconnect to the same session or read its output, people restart the task from scratch.

## Move the agent off the laptop

The structural fix is to run the agent on its own machine that does not sleep when your laptop does. With Sandscale that is a [workspace](https://sandscale.dev/workspaces): a persistent cloud computer per agent, with its own disk. The docs say an agent running in a workspace keeps working when your laptop is closed, and that the repository, branch, installed tools and the agent’s session are still there the next time you open it.

Setting one up with the Sandscale CLI (1.4.1):

```sh
sandscale workspace templates-list
sandscale workspace create --name agent-upgrade --template-id TEMPLATE_ID
sandscale workspace ssh agent-upgrade
```

`create` asks before it runs and answers with the workspace id. Inside, clone the repository and sign the agent in, the way you would on a new laptop. The disk is kept, so you do this once. If the CLI on the workspace needs to sign in, `sandscale login` uses a code you approve on your phone or laptop, because there is no browser there.

## Keep the agent out of the SSH session’s lifetime

Running the agent on a workspace removes the laptop from the picture. The SSH session is still a thread that can break. Start the agent inside a terminal multiplexer such as `tmux` or `screen` on the workspace (install it in the template, or once on the workspace, if it is not there), so the session lives on the workspace and your SSH connection only attaches to it:

```sh
tmux new -s agent
# start Claude Code or Codex here, give it the task, then detach with Ctrl+B D
```

When the connection drops, reconnect and reattach:

```sh
sandscale workspace ssh agent-upgrade
tmux attach -t agent
```

`workspace ssh` uses the system `ssh` through Sandscale with a short-lived certificate, so a reconnect after a network change is a new connection, not a stale one.

## Check on it without attaching

Sometimes you only want to know whether the agent is still going, from a phone hotspot or a slow connection. Two commands help:

```sh
sandscale workspace get --ws-id WORKSPACE_ID
sandscale workspace exec --ws-id WORKSPACE_ID --command '["sh", "-c", "cd ~/app && git log --oneline -5 && git status --short"]'
```

`get` shows the workspace’s state and its agent status. `exec` runs one command as you and answers with its exit code and output, and asks before it runs. Only the workspace’s owner can run commands, with their own sign-in, and every run is in the audit log without its command text.

## Make the task survive, not only the process

A process that survives a disconnect is half the fix. The other half is how you write the task, usually in the `AGENTS.md` the agent reads:

```markdown
## Long tasks
- Work on a branch named agent/<task>.
- Commit after each step that passes the focused tests, with a message that says
  what the step was. Push after each commit.
- Keep a short progress note in NOTES.md: done, in progress, next.
- If a command fails twice for reasons outside the code (network, registry),
  stop and write that in NOTES.md instead of retrying forever.
```

Small pushed commits mean that even if everything else goes wrong, the work so far is on the remote, readable by anyone on the team.

## What to check before you rely on it

- **The idle timeout.** A workspace stops after it has been idle for a while: the organization’s default is 30 minutes, and you can set it per workspace (at least 300 seconds, within your organization’s maximum) with `sandscale workspace update --ws-id WORKSPACE_ID --idle-timeout-seconds N`. Before leaving a long unattended run, try a short one: start the agent, disconnect, and confirm with `workspace get` that the workspace is still running a while later.
- **The time to live.** `--ttl-seconds` caps how long the workspace runs after it starts. Set it to fit the task with some margin; your organization’s lifecycle policy can shorten it.
- **Usage.** A running workspace counts toward your plan’s hours whether the agent is working or waiting. Stop it when the task is done: `sandscale workspace stop --ws-id WORKSPACE_ID`. The disk is kept.
- **Your own connection for review.** Reviewing still needs a connection. It just no longer has to be up for the whole run.

## The result

The laptop becomes what it should be for this kind of work: a window. Close it, lose power, change networks, and the agent carries on, on its own machine. When you are back, you reattach, read `NOTES.md` and the commits, and decide what happens next. When a team runs several agents this way, one per machine, nobody’s laptop is the bottleneck any more.

For the cost side of running agents on laptops, see [what it costs a team when coding agents run on laptops](https://sandscale.dev/blog/coding-agents-on-your-laptop-what-it-costs-the-team). For runs that should start and stop on a schedule, see [overnight coding agent runs](https://sandscale.dev/blog/scheduling-workspaces-for-overnight-agent-runs).

**On this page**

1. What actually breaks
2. Move the agent off the laptop
3. Keep the agent out of the SSH session’s lifetime
4. Check on it without attaching
5. Make the task survive, not only the process
6. What to check before you rely on it
7. The result

**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

- [December 2, 2026 · **Auditing the MCP tool calls your team's coding agents make** · When Claude Code, Codex, Cursor or Gemini CLI call MCP tools, the record of what happened can live in three places: the client, the MCP server, and the system behind it. What each layer can see, which one to trust as the record, whether to keep arguments, and how to read Sandscale's audit log for agent calls from the CLI.](https://sandscale.dev/blog/auditing-mcp-tool-calls)
- [December 2, 2026 · **Coding agents on client projects: a team lead's checklist for one machine per agent** · Services teams run Claude Code, Codex and Cursor across several client codebases at once. When those agents share developer laptops, client code, credentials and history mix. A checklist for team leads: one machine per agent per client, secrets kept per client, who can start and stop what, the audit record a client may ask for, and a clean exit at the end of the engagement.](https://sandscale.dev/blog/client-projects-one-machine-per-agent-checklist)

---
Source: https://sandscale.dev/blog/coding-agents-keep-working-when-the-laptop-sleeps
