# Run parallel coding agents across isolated VMs

Run multiple coding agents at the same time on separate KVM VMs so each task gets its own filesystem, git working tree, ports, and Docker daemon without colliding with other runs.

## Choose between multiple default VMs and one large VM

Every account on the $20 Pro plan starts with these limits: 40 running vCPUs, 80 GB running RAM, 1,530 GB total disk across running and stopped machines, and 30 machines (up to 10 parallel `default` VMs; Max scales to 50 parallel and Ultra to 250 parallel).

| Layout | Resources per VM | Max concurrent VMs on Pro | Combined hourly rate | A full month of all of them | Best fit |
|---|---|---|---|---|---|
| Multiple `default` | 4 vCPUs, 8 GB RAM, 51 GB disk | 10 (40 vCPUs, 80 GB RAM, 510 GB disk) | $0.18/hr for 10 | $131.40 for 10 | Independent PRs, parallel test shards, isolated Docker stacks |
| Multiple `small` | 2 vCPUs, 4 GB RAM, 51 GB disk | 20 (40 vCPUs, 80 GB RAM, 1,020 GB disk) | $0.18/hr for 20 | $131.40 for 20 | Lightweight triage, linting, docs edits |
| Multiple `large` | 8 vCPUs, 16 GB RAM, 111 GB disk | 5 (40 vCPUs, 80 GB RAM, 555 GB disk) | $0.18/hr for 5 | $131.40 for 5 | Heavy monorepo builds, Rust/C++ compiles, big Docker Compose stacks |

The Pro plan's $20 covers the first $20 of that each month. A top-up at the same rates covers the rest.

Note that stopped machines still count toward the 1,530 GB Pro account disk limit, so delete finished worker VMs rather than leaving many stopped copies around.

## 1. Create labeled worker VMs

Tag each batch with `--label` so you can list and clean up every machine in the run together.

```console
$ arvm new --name agent-1 --label batch=pr-audit --idle-timeout 1h
$ arvm new --name agent-2 --label batch=pr-audit --idle-timeout 1h
```

If all workers need the same toolchain or repository cache, set up one machine once, take a snapshot, and boot workers from it:

```console
$ arvm snapshot create calm-river-otter --name before-upgrade
$ arvm new --name agent-3 --from-snapshot before-upgrade --label batch=pr-audit --idle-timeout 1h
```

## 2. Run tasks through `arvm exec`

Drive each worker over the API with `arvm exec` so you do not need interactive SSH sessions. Pass `--timeout` up to `1h` for longer test suites or agent loops.

```console
$ arvm exec agent-1 --timeout 30m -- sh -c 'cd /home/dev && uname -r'
$ arvm exec agent-2 --timeout 30m -- sh -c 'cd /home/dev && uname -r'
```

Use `--json` when an orchestrator script parses `exit_code`, `stdout`, `stderr`, `timed_out`, and `oom_killed`. For jobs longer than an hour, launch them with `sudo systemd-run` and disable idle stop first: see [Run a job that outlives the request](../exec-and-files.md#run-a-job-that-outlives-the-request).

## 3. Track the batch and collect outputs

List all machines in the batch and copy any output files back with `arvm cp`:

```console
$ arvm ls --label batch=pr-audit
$ arvm cp agent-1:/home/dev/result.log ./agent-1.log
```

## 4. Delete worker VMs when the batch ends

Delete ephemeral worker machines as soon as their branches are pushed or logs are collected:

```console
$ arvm rm agent-1 --yes
$ arvm rm agent-2 --yes
$ arvm rm agent-3 --yes
```

Passing `--yes` is required in scripts and agents; without it `arvm rm` exits with code 2 and deletes nothing.

## Worktree-per-agent workflow with `arvm fork`, `arvm focus`, and `arvmd`

Pair each agent's local `git worktree` with its own bound box so parallel agents can edit, build, test, and preview services without port or filesystem collisions:

1. Scaffold `arvm.toml` once at the repo root with `arvm init` so every worktree shares the same `[box]` size/image and `[service.<name>]` definitions.
2. Bind or fork a box per worktree (`arvm new` inside a worktree auto-binds it, or `arvm fork` clones a warm box with dependencies already installed):

```console
$ arvm init
$ arvm bind calm-river-otter
$ arvm dev --detach
$ arvm fork agent-branch-a
$ arvm exec -- uname -r
$ arvm pull
```

3. Run `arvm proxy start` (or `arvmd`) on your workstation. Every bound box is reachable simultaneously at `http://box-<name>.localhost:<port>` (HTTP and WebSockets, waking sleeping boxes via `?wake=true` on hit).
4. Switch which worktree owns bare `http://localhost:<port>` (for OAuth callbacks and shared localhost cookies) at any time:

```console
$ arvm focus calm-river-otter
$ arvm focus --status
$ arvm proxy status
```

5. Clean up forked boxes when a branch merges:

```console
$ arvm rm agent-branch-a --yes
```

## Idle stop and billing

Billing is per second across running machines. Running 4 `default` VMs in parallel for 2 hours consumes 8 machine-hours ($0.144), less than 1% of the plan's $20.

Setting `--idle-timeout 1h` protects your balance if an orchestrator crashes before cleaning up workers. Deleting finished workers releases their 51 GB disks immediately so future batches do not hit `limit_exceeded`. Snapshot storage costs $0.10 per GB a month while the snapshot exists; delete unused snapshots with `arvm snapshot rm`. See [Billing](../billing.md) and [Snapshots](../snapshots.md).

## Troubleshooting

| Symptom | What to do |
|---|---|
| `arvm new` fails with `limit_exceeded` (exit 4) | Check `arvm ls`. Both running and stopped machines count toward your tier's disk and concurrency limits (Pro includes 10 parallel `default` VMs / 1,530 GB disk; Max 50 parallel; Ultra 250 parallel). Delete finished VMs with `arvm rm <name> --yes`. |
| `arvm new` fails with `no_capacity` (exit 9) | Wait for the `Retry-After` seconds printed in the error and retry with the same `--idempotency-key`. |
| `arvm exec` returns exit code 12 (`exec_outcome_unknown`) | The connection ended before the exit result arrived. Inspect the VM state (files, git status, running units) before re-running a non-idempotent task. |
| Worker stopped mid-batch while waiting on network I/O | Raise `--idle-timeout` or set `--idle-timeout never` on the worker, and always delete it in your cleanup handler. |

## Related guides

- [Run Claude Code in the cloud](run-claude-code-in-the-cloud.md)
- [Run Codex CLI in the cloud](run-codex-in-the-cloud.md)
- [For agents](../agents.md)
- [Machines](../machines.md)
