How to Choose a Sandbox for a Coding Agent
A practical guide to the isolation you get, the resources you rent, and the waiting time you pay for.
Contents
- Start with the job, not the virtual CPU count
- What is a VM? What is a sandbox?
- Containers, gVisor, Firecracker, and general-purpose VMs
- Isolation does not decide what you intentionally expose
- Startup time: measure when work can actually begin
- How sandbox billing works
- Burstable CPU is different from active CPU billing
- CI shares the burst problem, but has a different lifecycle
- Colocation: close to what?
- What to ask before renting a sandbox
- Using the result in Agentastic
- Frequently asked questions
A coding-agent sandbox is a place where an agent can execute code within defined boundaries. Choosing one means answering three separate questions: what can the code access, how quickly can it finish useful work, and what keeps billing while it waits?

The word sandbox does not specify the underlying technology or the price model. Two services can both use virtual machines and charge very differently. Two environments can both run containers and expose very different security boundaries.
This guide explains the tradeoffs before you rent one. Provider billing documentation was checked on November 13, 2026. The worked prices below are explicitly illustrative. For actual measured runs through Agentastic, see our separate cloud sandbox benchmark.
Start with the job, not the virtual CPU count#
A coding agent often alternates between two very different phases. While a remote model reasons or generates a patch, the execution environment may have little to do. When the agent compiles, runs tests, launches browsers, or indexes a repository, demand can jump sharply.
That makes average CPU utilization an incomplete buying guide. A machine can average low utilization and still need substantial CPU and memory for acceptable test times. Conversely, reserving enough capacity for the largest build and paying for it throughout a long conversation can be expensive.
An agent that only calls an application API may not need a general-purpose shell at all. A narrow execution tool can be easier to constrain. But “non-coding agent” does not imply a light workload: browser automation, document conversion, and data analysis can be resource intensive too. Size the tools the agent actually executes.
For coding, write down the complete loop:
- Obtain a specific repository revision and dependencies.
- Start the agent and any required services.
- Wait for model responses and apply changes.
- Build, test, inspect failures, and repeat.
- Export a patch and verification evidence.
- Stop execution and retain or delete state deliberately.
The useful unit of comparison is cost and elapsed time per successfully verified change, with acceptable isolation. A cheap idle hour does not tell you that.
What is a VM? What is a sandbox?#
A virtual machine, or VM, is a computer presented in software: virtual CPUs, memory, disks, and devices. A guest operating system runs inside it. A hypervisor or virtual machine monitor manages the guest and its access to the underlying host.
A sandbox is an execution environment with restrictions. Those might limit files, network destinations, credentials, system calls, process privileges, or resource use. It is a purpose and a set of boundaries, rather than one implementation.
A container packages processes and their filesystem environment. On a Linux container host, containers share the host kernel; they do not each boot a separate kernel. Docker uses mechanisms including namespaces and control groups, with security also depending on capabilities, daemon access, and configuration. A container image describes what to run; it does not establish every runtime restriction by itself. Docker Engine security.
A microVM is a VM designed with a small device model and focused feature set. It still has a guest kernel and a virtualization boundary. “Micro” does not mean that applications inside it use no memory or that the surrounding service provisions instantly.
These layers can be combined. A provider can run containers inside VMs, add network policies, and expose only a restricted command API. Ask which boundary separates your job from other jobs, and which separates untrusted code from your credentials and infrastructure.
Containers, gVisor, Firecracker, and general-purpose VMs#
| Approach | Main boundary | Advantages | Tradeoffs to test |
|---|---|---|---|
| Process restrictions | OS policies around a process and its children | Can keep an existing local toolchain and avoid provisioning another machine | Coverage depends on the policy and every execution path; permitted files and credentials remain accessible |
| Ordinary Linux container | Namespaces, resource controls, capabilities, and other host-kernel policies | Familiar images and tooling; no separate guest-kernel boot | Shares the host kernel; privileged settings and host mounts can undermine isolation |
| gVisor sandbox | A userspace application kernel mediates the Linux system-call interface | Reduces application exposure to the host kernel while fitting container workflows | Verify syscall compatibility and filesystem/network performance for the actual build |
| Firecracker microVM | KVM-backed virtualization with a guest kernel and reduced device model | VM boundary with a small virtualization component | Image, guest, networking, lifecycle, and operator configuration still matter; hardware and device needs must fit |
| General-purpose VM | Guest OS on virtual hardware | Broad OS and system-administration flexibility, subject to the platform | More components to provision and maintain; a full environment may take longer to prepare |
gVisor supplies a Linux-like application kernel in userspace. Its runsc runtime integrates with container tooling. It is more than a list of permitted system calls: it implements an interface between the application and the host. gVisor overview.
That extra software has costs. System-call-heavy, filesystem-heavy, and networking workloads can behave differently from pure computation. gVisor's own performance guide separates architectural overhead from implementation costs. Benchmark your compiler, package manager, and browser tests; one CPU loop cannot predict the whole development experience. gVisor performance guide.
Firecracker is a virtual machine monitor that uses Linux KVM to run microVMs. It deliberately provides a smaller device model than a broad-purpose VMM. The open-source virtualization component and a managed sandbox product built on it are different things: the product adds scheduling, images, storage, networking, credentials, and billing. Firecracker project.
Neither technology is a universal security ranking. Evaluate the deployed configuration, updates, access policy, and threat model. gVisor's security model is a useful example of a project explaining the attacks its boundary addresses rather than promising protection against everything.
Compatibility can eliminate a candidate before price matters#
Try the real workflow before committing to a platform:
- Does it support the required OS and CPU architecture? A Linux sandbox is not a replacement for a macOS environment when the build needs Apple's native toolchain.
- Do tests need browsers, shared memory, particular kernel interfaces, or background services?
- Does the repository assume Docker, nested virtualization, privileged operations, or a local daemon?
- Can you install the exact compiler and runtime versions, and retain a reproducible image?
- Do memory, disk, process, and execution-duration limits accommodate a complete build?
- Can the environment reach required private services without broadening access unnecessarily?
A service may advertise a standard Linux image while restricting an operation your tests require. An ordinary application can work perfectly and its integration test suite still fail.
Isolation does not decide what you intentionally expose#
A sandbox can prevent a process from reading the host's files while still allowing it to upload every file mounted inside the sandbox. That is not an escape: it is use of granted access.
Decide separately which repository directories, secrets, network destinations, and external tools a task receives. Use credentials scoped to the task, keep production permissions out of routine builds, and treat dependency installation as code execution. Network policy needs to cover the actual route commands use, including proxies and additional execution tools.
An approval prompt is a request for a decision; it is not itself the enforcement boundary. A Git worktree separates changes, but does not isolate processes. Our sandbox permission test guide shows how to check allowed and denied operations with harmless fixtures.
Also distinguish tenant isolation from confidentiality against the infrastructure operator. A conventional cloud VM is not, merely by being a VM, a promise that the provider cannot access its data. Retention, access controls, encryption arrangements, and any confidential-computing guarantees need their own review.
Startup time: measure when work can actually begin#
“Startup” can mean a booted guest, an API returning an identifier, an authenticated shell, or a repository ready to test. These are different milestones.
For a coding agent, record:
| Stage | What to measure | What can dominate |
|---|---|---|
| Provision | Request until usable capacity is assigned | Scheduling, quotas, regional capacity |
| Boot or resume | Capacity assigned until execution is possible | Guest initialization, snapshot restore, service startup |
| Prepare | Execution available until the project is ready | Image transfer, Git checkout, dependencies, credentials |
| First useful result | Project ready until a verified command finishes | Compiler caches, browser setup, test databases |
| Repeated work | Subsequent verified builds or tests | Sustained CPU, memory, disk, and cache behavior |
Some stages overlap, so use timestamps for the real critical path rather than blindly adding overlapping timers.
A warm snapshot can remove work, but its contents must still match the repository revision, dependencies, and access policy. Decide what happens to secrets stored in memory, stale network connections, and expired credentials after resume. A fast restore that requires manual repair is not a fast usable start.
For a concrete measurement with stated methodology, our October 21 sandbox benchmark reported median integration createVM call times of 2.0 seconds for Agent37, 3.0 for Modal, 38.6 for Fly shared, and 55.3 for Vercel across three fresh matched-request trials per provider. Requests were approximately two vCPUs and 4 GiB, with one physical core requested on Modal. Those timers include each integration's bootstrap, use the versions and region placement recorded in the report, and are not vendor-only cold-boot measurements or a universal startup ranking.
Use that benchmark's raw results to understand the protocol. Then repeat with your own image and repository, separately recording warm starts, cold starts, failures, and retries. A fresh VM does not necessarily imply an uncached image.
How sandbox billing works#
The isolation mechanism does not determine the billing meter. Understand the bill as several independent terms:
total sandbox cost =
CPU charge
+ memory charge
+ storage and snapshot charges
+ network and storage-operation charges
+ creation, minimum, and platform chargesModel inference charges are separate unless a product explicitly bundles them.
Allocated CPU versus active CPU#
With allocated-time billing, you pay for a machine or requested CPU capacity while it is running, including idle time. Four allocated vCPUs for one hour represent four vCPU-hours of capacity, even if most of the hour is spent waiting.
With active-CPU billing, the meter accumulates CPU execution across processors. Four vCPUs fully busy for ten minutes consume forty vCPU-minutes, or about 0.667 vCPU-hours. Waiting on a network response can reduce this component substantially.
“Active” does not mean “the user is looking at the screen.” File watchers, indexing, development servers, background tests, and polling can consume CPU while the agent appears idle.
Requested minimums create another model: pay at least for the resources requested, and more when measured usage exceeds them. A high request can make a nominally usage-based service expensive during waits.
Memory has its own clock#
With provisioned-memory billing, you pay for the size of the allocation throughout its billable lifetime. Eight GiB held for one hour is eight GiB-hours, even if the application only needs part of it.
Other services meter usage subject to a requested floor. “Usage” requires a precise definition: inspect which memory counters the provider uses and how caching and shared pages are treated.
A machine may couple memory to CPU size. Increasing CPU to speed compilation can then increase the memory charge during model waits. Conversely, too little memory can cause swapping, failed builds, or retries. The right target is enough headroom for the job, with measured reasons for additional capacity.
Three real billing models#
These are documentation-based descriptions checked November 13, 2026, not quotes for a particular account or predictions of an invoice.
| Provider | Documented billing behavior | Consequence for an agent |
|---|---|---|
| Vercel Sandbox | Active CPU sums execution across vCPUs; I/O waiting is excluded. Provisioned memory accrues while running, with a one-minute minimum increment | Model waits can lower CPU charges while memory continues billing |
| Modal Sandboxes | CPU and memory use max(request, actual); explicit requests establish a lifetime floor, and available capacity permits bursting | Check requests separately from limits; asking for guaranteed capacity changes idle cost |
| Fly Machines | Running Machines are billed by time and size; retained root filesystems and volumes have separate charges | Stopping compute does not imply that all retained resources become free |
Sources: Vercel Sandbox pricing and metric definitions, Modal sandbox resources and pricing, Fly resource pricing.
Normalize units before comparing rates. GB and GiB differ, and a provider's CPU setting may refer to physical cores rather than vCPUs. Modal documents its CPU parameter in physical cores, with one core corresponding to two vCPUs. That mapping still does not establish equal performance across different hardware.
An illustrative bill for one agent session#
The following workload and rates are invented to explain the arithmetic. They are not provider prices or measured utilization. Both hypothetical plans use the same rates so that only the billing model changes.
Assume an hour-long session with four vCPUs and eight GiB allocated. It spends fifty minutes with zero CPU execution, then ten minutes using all four vCPUs. Ignore every other charge. Real waiting usually includes some CPU activity.
Assume $0.10 per vCPU-hour and $0.02 per GiB-hour.
| Component | Allocated CPU plan | Active CPU plan |
|---|---|---|
| CPU quantity | 4 × 1 hour = 4 vCPU-hours | 4 × 10/60 hour = 0.667 vCPU-hours |
| CPU charge | $0.40 | About $0.067 |
| Provisioned memory quantity | 8 × 1 hour = 8 GiB-hours | 8 × 1 hour = 8 GiB-hours |
| Memory charge | $0.16 | $0.16 |
| Illustrative total | $0.56 | About $0.227 |
Active CPU makes a large difference here, but memory is most of the second bill. If that second plan required sixteen GiB at the same illustrative memory rate, its total would rise to about $0.387. If its memory rate also differed, the result would change again.
This is why “only pay for active CPU” is insufficient to judge value. Compare the complete shape and all meters. A faster machine can also reduce elapsed time and therefore memory charges, while a slow cheap CPU can keep paid memory allocated longer.
Burstable CPU is different from active CPU billing#
Bursting describes how much execution capacity is available. Active billing describes what usage the provider charges for. A service can offer one without the other.
Fly distinguishes shared and performance CPUs. Shared CPUs accumulate a burst balance and fall back to their baseline quota when it is exhausted; performance CPUs have a different scheduling allowance. The exact quotas can change. Fly CPU performance documentation.
A coding agent's pauses may allow a burst balance to recover. That can suit short checks. A large clean build or long test suite may exhaust it, so measuring only the first few seconds can be misleading. Run both a representative incremental build and the longest important sustained job. Inspect throttling, not just the guest's reported CPU count.
A memory increase will not solve CPU throttling, and additional CPUs will not necessarily fix a serial build step. Find the actual bottleneck before resizing.
CI shares the burst problem, but has a different lifecycle#
A CI worker often has a clearer start and finish than an interactive agent session. It can provision, restore dependencies, run a fixed test graph, upload artifacts, and stop. There may be less model-wait time to benefit from active CPU billing.
Coding-agent sessions mix those CI-like bursts with uncertain waits and repeated edits. Keeping an environment alive preserves caches and processes, but also retains resources. Splitting heavy builds onto a separate worker can help when its startup and synchronization costs are smaller than the savings. It also creates another state boundary to manage.
For both cases, test caching carefully:
- Key reusable caches to the toolchain, platform, and dependency inputs.
- Separate untrusted job writes from caches later consumed by trusted release jobs.
- Preserve logs and the exact tested revision before deleting a failed worker.
- Include cache restore and artifact upload time in the result.
- Set cleanup policies for failed, disconnected, and abandoned jobs.
Auto-stop and auto-suspend policies need a definition of idle that matches the workflow. A quiet terminal is not necessarily a finished build; a model call may be in flight. Evaluate resume behavior and billing state together.
Colocation: close to what?#
For sandboxes, colocation usually means placing interacting services in the same region or nearby network location. It does not necessarily mean sharing a physical host, an availability zone, or a guaranteed private route.
Map the traffic before choosing the region:
| Path | When proximity helps | What else matters |
|---|---|---|
| Developer to sandbox | Interactive terminal, streamed UI, frequent remote tool dispatch | Connection reuse, relay path, transport overhead |
| Agent to model endpoint | Sequential model calls on the critical path | Model queueing and generation time; the API hostname may not reveal inference placement |
| Sandbox to repository and registry | Large clone, image, or dependency transfers | Bandwidth, caching, authentication, rate limits |
| Sandbox to database or service under test | Many small sequential requests | Private connectivity, test data location, cross-region transfer cost |
| Sandbox to cache and artifact storage | Repeated builds, large outputs, many storage operations | Cache correctness, storage throughput, read/write charges |
| Worker to worker | Distributed builds or coordinated agents exchanging substantial state | Placement guarantees, bandwidth contention, failure domains |
Latency matters most when waits accumulate#
A simple illustrative calculation: one hundred sequential remote commands, each adding an 80 ms network round trip, add eight seconds of network waiting before execution or protocol overhead. Batch independent work or move the execution loop closer to the tools when appropriate.
But if the agent process runs inside the sandbox, its ordinary local shell commands do not each traverse the developer-to-sandbox connection. The laptop may receive streamed progress while the agent builds locally. Measuring an SSH command from your laptop does not automatically measure the agent's local tool loop.
Similarly, a large initial repository transfer may be limited by bandwidth or server processing rather than round-trip latency. A chatty integration test may be latency sensitive even with very little data. Measure both.
The nearest model region is not automatically the best region#
A region near your developer may provide a responsive terminal but be far from a private test database. A region near an API ingress point may not be near the model hardware. Often the most useful placement is near the repository's persistent data and caches, with the agent and build tools together.
Region choice also affects available machine types, quotas, and pricing. Data residency requirements can restrict the options before latency enters the comparison. Cross-region transfers can add costs: Fly, for example, documents separate private-network inter-region transfer charges. Fly resource pricing.
Do a representative run from the regions you can actually use. Record the agent location, model endpoint, registry/cache locations, storage region, connection path, and whether the measurements include a relay. “US region” is not enough detail to reproduce a result.
What to ask before renting a sandbox#
Use a small acceptance test that represents your repository, then save its configuration with the results.
| Question | Evidence to request or collect |
|---|---|
| What isolates jobs and tenants? | Architecture description, update policy, access policy, and actual allowed/denied operation checks |
| Will our complete toolchain run? | A clean checkout, dependency install, build, browser tests, and required service startup |
| Is the CPU suitable for sustained work? | Incremental and clean-build timings, throttling metrics, and resource limits |
| How much memory is needed? | Peak use during the largest relevant job and failure behavior at the limit |
| What does startup include? | Timestamps from request through the first verified command, with cache state recorded |
| What survives stop, suspend, resume, and deletion? | A tested lifecycle with documented disk, memory, and credential behavior |
| What keeps billing when quiet? | CPU and memory meters, minimums, retained storage, and the account's actual rate card |
| Can it reach only the right systems? | Private connectivity and permitted egress tested through the real execution path |
| Can we recover and clean up? | Exported patches/logs, retry behavior, termination confirmation, and resource inventory |
| What happens at team concurrency? | Representative simultaneous jobs, quota failures, queue time, and a total spend limit |
A successful single run does not establish reliability or performance under load. Repeat enough to expose variability, preserve failed attempts, and compare equivalent completed work. Keep pricing estimates separate from settled charges.
Using the result in Agentastic#
Agentastic's Cloud Agents can run coding sessions in provider-backed environments while keeping the worktree and review workflow in the app. Choose the provider account and environment based on the job's requirements, then inspect the resulting changes and verification evidence.
An integration does not make all providers equivalent: CPU requests, lifecycle controls, transports, and billing still differ. Local commands or bridges, when enabled, also need to be considered when describing the execution boundary.
Use the cloud benchmark for one documented comparison, the permission test guide for checking access restrictions, and this article's worksheet for your repository. Select the environment that completes the real task with the isolation, responsiveness, and total cost you need.
Frequently asked questions#
What is the difference between a sandbox and a virtual machine?#
A sandbox restricts what a program can access or affect. A virtual machine is one way to build that boundary: it runs a guest operating system on virtual hardware. Sandboxes can also use process restrictions, containers, or an application kernel such as gVisor.
How do gVisor and Firecracker differ?#
gVisor implements a Linux-like application kernel in userspace to mediate application system calls. Firecracker uses KVM to run a guest kernel in a small virtual machine. Their compatibility, resource overhead, and performance depend on the workload and configuration.
Does active CPU billing mean an idle sandbox is free?#
No. Waiting may reduce the CPU portion of the bill, but provisioned memory, minimum resource requests, persistent storage, and other charges can continue. Background processes also consume CPU even when the agent is waiting for a model.
What matters most when renting a sandbox for a coding agent?#
Check toolchain compatibility, isolation and credentials, sustained build performance, memory headroom, startup to first useful command, cache persistence, lifecycle controls, and the total cost of a completed and verified change.
Should a sandbox be close to the model or the developer?#
Place it near the services on its critical path. Interactive remote commands benefit from proximity to the caller; large repositories, package caches, artifacts, and databases can dominate other workflows. An agent running inside the sandbox does not cross the developer-to-sandbox network for each local shell command.
Are Git worktrees a sandbox?#
No. Worktrees separate checkouts and branches, but they do not by themselves restrict filesystem access, network access, credentials, or process privileges. Use an actual execution boundary when those restrictions matter.