← Blog

The agent's machine for the loop, a build host for the full test suite: a lease from the Sandscale CLI

A coding agent edits and runs focused tests on its own machine. The full suite before a pull request is a different job. How to lease a clean build host for it with the Sandscale CLI (1.4.1), run the suite over SSH, bring the results back, and release the host, with the instructions to give the agent.

When every coding agent on a team has its own machine, most of its work fits that machine well: edit a file, run the tests for that file, read the failure, try again. The step that does not fit is the last one before a pull request, the full test suite. It may want far more cores and memory than the agent needs the rest of the time, and it may run as one long job.

You could size every agent’s machine for that one step, and pay for the extra size during all the other steps. Or you can keep each agent’s machine sized for the loop, and lease a build host just for the suite. This post shows the second approach with the Sandscale CLI (1.4.1), run from the agent’s own workspace. For the decision itself, when a step deserves a lease at all, see our earlier post on when a job needs a leased machine instead of a sandbox, which walks through the same flow with the API and the TypeScript SDK.

What a lease is

From the CLI’s help and the build hosts concepts page:

  • A build host is a clean machine leased from a pool for a set time, and released when the task ends.
  • Administrators manage pools in the console. A pool can require approval, in which case the lease is pending_approval until a person approves it.
  • Build host leases come with Pro and up. A lease’s hours, vCPUs times hours, count in the plan’s included hours, the same allowance sandboxes and workspaces use. Leases at once are bounded by your organization’s build quotas.

1. Find a pool and take a lease

sandscale build pools-list
sandscale build lease-create --pool-id POOL_ID --size SIZE --ttl-seconds 7200 \
  --purpose "full test suite before PR" --repo github.com/acme/app

--size must be one of the sizes the pool offers, and --ttl-seconds must be within the pool’s and the plan’s maximum. --purpose and --repo are recorded with the lease, which makes the lease list readable when several agents use the same pool. lease-create asks for confirmation before it sends anything; an agent running it without a terminal needs --yes, which is a good reason to decide in advance whether your agents may lease on their own or must ask you.

Check the lease’s state:

sandscale build lease-get --lease-id LEASE_ID

If the pool requires approval, the state stays pending_approval until someone approves it. Tell the agent to report that and wait, rather than retry.

2. Send the working copy and run the suite

sandscale build lease-ssh connects to an active lease’s host with the system ssh, through Sandscale, using a short-lived certificate signed for the lease. Everything after -- is the command the host runs. Because it is ssh, standard input and output pass through, so the agent can stream its working copy in and the results out:

tar -czf - --exclude=.git --exclude=node_modules . | \
  sandscale build lease-ssh LEASE_ID -- sh -c 'mkdir -p app && tar -xzf - -C app'

sandscale build lease-ssh LEASE_ID -- sh -c 'cd app && npm ci && npm run test:all' > full-suite.log 2>&1
echo "exit: $?"

The first command copies the agent’s current tree, including uncommitted changes, so the suite tests exactly what the agent is about to propose. The second runs the suite on the lease and writes its output to a file on the agent’s own machine, where the agent can read the failures. Pick the commands your project uses; npm run test:all is a placeholder.

If your suite can write a machine-readable report, have it do so and copy that back too. Our post on test results a coding agent can act on shows how, and why a short failure summary beats a long log.

3. Release the host

sandscale build lease-release --lease-id LEASE_ID

The host is wiped on release, so copy out anything you need first. Release is the step that matters most for cost and for credentials: the concepts page and our earlier post explain that SSH certificates and Vault secrets issued for a lease are valid only while the lease lasts, so a released lease leaves nothing usable behind.

What to tell the agent

Put this in the repository’s AGENTS.md, so Claude Code, Codex and Cursor all read it:

## Full test suite
- While working, run only the tests for the files you changed, on your own machine.
- Before opening a PR, run the full suite on a build host:
  1. `sandscale build pools-list`, then lease from the `ci-large` pool with
     `sandscale build lease-create --pool-id <id> --size large --ttl-seconds 7200 --purpose "<task-id> full suite"`.
  2. If the lease is pending approval, say so and stop.
  3. Copy your tree and run `npm run test:all` with `sandscale build lease-ssh`.
  4. Always run `sandscale build lease-release` afterwards, even if the suite failed.
- Put the suite's result in the PR description.

The pool name and size are your organization’s; use the ones your administrator set up.

Why not just make the agent’s machine bigger?

Because the big step is rare and the small steps are constant. A running box counts toward your plan whether it is busy or idle, so a machine sized for the full suite costs that size for the whole session. A lease counts the large size only while you hold it, so release it as soon as the suite is done. It also keeps the agent’s own machine predictable: the same size every time, with no surprise when the suite grows.

The agent keeps its own workspace for the loop, and a clean, larger machine appears for the one job that needs it and disappears afterwards. With several agents finishing tasks at different times, each takes its own lease when it needs one, and the pool’s quotas and approvals keep that in check.

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

Keep reading