Fresh VM per Agent Task Is Not a Feature It Is the Baseline Architecture for Safe Cloud Runners
VM isolation prevents agent collisions and keeps credentials safe across concurrent coding sessions.

A cloud coding agent runner that supports a bring-your-own API key needs a fresh, isolated VM for each task, session-scoped credentials, and a reproducible environment in which to run and test code. For teams seeking to run Claude Code or Codex in the cloud with their own Anthropic or OpenAI API key, VM isolation is the baseline architecture. The meaningful differences are credential protection, environment completeness, harness flexibility, and operating cost.
Why shared compute is structurally incompatible with concurrent coding agents
Three agents working on three branches can still get in each other’s way when they use the same local database, port bindings, SSH keyring, and credentials file. One agent’s half-finished refactor can break another’s test run, while concurrent writes turn shared files into race conditions. These are collisions in the resources the agents need to work.
Git worktrees solve only part of that problem. They separate working trees but leave host-level services, ports, and credential stores shared. An agent with shell access may still reach credentials belonging to another session. Meaningful concurrency therefore requires a dedicated compute environment per agent, rather than more processes arranged around one shared host.
What "fresh VM per task" actually means at the infrastructure level
With a fresh VM, each task has its own filesystem, network stack, terminal environment, and package manager state. Concurrent sessions do not share that mutable state. The VM clones the repository at the current HEAD of a specified branch, runs setup commands, and begins the task. When the session ends, the VM is reclaimed, with nothing passed to another task unless persistence is explicitly designed into the system.
Within that boundary, file changes, generated artifacts, package installations, and library upgrades belong to the task. A runaway process ends when its VM shuts down rather than remaining in a shared execution environment. Branch isolation adds a separate workflow boundary. The agent works on a new branch from the target, leaving main and other feature branches untouched until a merge.
AWS’s Lambda MicroVMs post gives cross-session contamination as a reason to use isolation, including when tool calls expose sensitive data or reach production resources. Even within a VM boundary, the permissions available still need to be defined. Each run starts clean, executes independently, and produces artifacts without polluting shared state, except that an agent also writes code and iterates on its tests.
How the major cloud agent platforms implement per-task isolation today
Anthropic gives each Claude Code cloud session a fresh Ubuntu VM with the GitHub repository, common toolchains, Docker, PostgreSQL, and Redis. Its cloud environment also has environment variables, a network access level, and a setup script. The environment is more than an empty machine. Sessions can begin through Claude’s web and app interfaces, claude --cloud, Slack, or scheduled tasks, while idle VMs can be paused and later reclaimed.
OpenAI gives each Codex cloud task its own VM, started from a prepared cloud environment. Codex helps inspect repositories, install dependencies, and test the workflow before that environment is published. Tasks can start from web, desktop, or mobile. Mobile can select an existing environment but cannot create one, while Business and Enterprise workspaces can also initiate tasks through mentions in Slack or Microsoft Teams.
Cognition gives each Devin session its own cloud VM with a shell, editor, and browser on the Pro plan. The surrounding product workflows differ across these platforms. Their shared architectural decision is to assign an independent execution environment to the session or task.
The isolation primitive matters: why VMs, microVMs, and containers are not interchangeable
The word “isolated” does not specify the boundary. OS-level mechanisms such as Landlock, seccomp-bpf, namespaces, and cgroups constrain processes while sharing the host kernel. Ordinary containers also share that kernel. For agents that install packages, run services, or drive browsers, this difference shapes which permissions they can have and what granting those permissions puts at risk.
gVisor intercepts system calls in userspace, providing a different boundary from an ordinary container. MicroVMs such as Firecracker instead give each session a guest kernel behind hardware virtualization. Full VMs provide a strong boundary with slower cold starts, while Kata Containers put containers inside microVMs through a runtime compatible with container standards.
Google’s Agent Compute Engine, announced October 22, 2026, aims to close this gap between VM isolation and container speed. Its design assigns each agent session a hardware-isolated microVM with its own guest kernel, root access, and disk. Density remains a legitimate competing concern, however. A dedicated kernel per tenant consumes memory across thousands of instances, which can make gVisor attractive to large-fleet operators. The practical choice balances boundary strength, required permissions, startup latency, and density.
Cold-start latency and idle cost: the engineering trade-offs that shape real deployments
Strong isolation introduces startup work and idle waste. Agents spend much of their time between tool calls waiting for model responses or user input. Keeping a VM active throughout those pauses consumes resources without advancing the task. The operating model therefore needs to account for both the cost of launching a machine and the gaps between tool calls.
Checkpoint and restore make those pauses manageable. Fly.io Sprites supports fast checkpoint and restore with scale-to-zero, while AWS Lambda MicroVMs provides configurable idle policies that preserve disk and memory state during suspension. Inbound traffic can resume the suspended environment. Starting from a captured memory and disk snapshot also skips application initialization, so there is less work to do before the agent can act. Platform claims ranging from tens to a few hundred milliseconds illustrate a platform-specific range of boot or restore times.
Anthropic caches installed setup-script files for about seven days, trading some freshness for faster startup. Codex retains task files, including uncommitted changes, for up to seven days after the last turn without making them the next task’s state. AWS’s reference architecture also recommends webhook-triggered launches over always-on polling, avoiding empty polling and a polling loop that can break when its VM suspends.
What the environment must contain beyond isolation for agents to do reliable work
A shell and filesystem let it install packages, execute code, and run builds and tests. With Git credentials, it can clone the repository, commit changes, and return a pull request. Preinstalled toolchains and services such as Docker, PostgreSQL, and Redis complete that execution context.
Verification depends on the tools available inside the VM. With browser access, an agent can test UI-dependent output and read script-rendered pages that a shell alone cannot check. A reproducible setup script brings the repository into a runnable state before implementation begins.
Environment configuration also needs an explicit owner. The AGENTS.md convention, or an equivalent setup file, gives the team a way to define the correct environment explicitly for the agent. Environment variables and secrets should be set when the session starts and kept out of baked images. Network access policy then governs where the resulting code can connect, complementing credential handling.
Parallelism as the operational payoff of per-task isolation
Independent environments let agents execute tasks concurrently without corrupting each other’s working state. Each task can install dependencies, run services, and test its changes within its own boundary. Isolation lets that test run proceed independently of another agent’s unfinished refactor.
The configured environment makes that independence useful. If each task starts with the services and tools it needs already configured, concurrent agents can spend their time implementing and verifying changes. Parallelism then lets more work happen at once without giving agents more shared state to clash over. It does not remove the need to review what those agents produce or verify behavior beyond their individual environments.
Where the sandbox wall stops and what teams do about it
The boundary that protects live systems also limits verification. An agent confined to its VM cannot validate behavior against staging or production state it cannot access. Local tests can establish correctness within that environment, but they cannot establish that a deployment will behave correctly elsewhere. Fresh compute does not erase that distinction.
This limit shifts work into review and release. Agent-opened pull requests can leave reviewers responsible for environmental verification that the agent could not perform. The practical response is to scope agent tasks to work that can be fully verified inside the VM, including unit tests, integration tests without external state, linting, and documentation. Deployment verification remains a human responsibility.
The security assumption inside the sandbox that teams often miss
A fresh VM provides session separation while leaving credential separation dependent on additional controls. Cloud VMs can expose an Instance Metadata Service, or IMDS, that returns IAM credentials, access tokens, and configuration to processes inside the instance. An agent able to query that endpoint may obtain permissions it was never explicitly given for its task. Prompt influence can therefore become a route to resources beyond the sandbox without requiring a VM escape.
Zenity Labs’ AgentCorruption research demonstrated this distinction with an exposed AgentCore agent. An attacker could direct the agent to the instance’s IMDS endpoint, which returned temporary IAM credentials because the request originated inside the instance. The compute boundary was not the only relevant boundary. The design needed to account for the authority a process inside that boundary could acquire.
Credential hardening must therefore be explicit and separate. AWS controls include IMDSv2 enforcement, a hop limit of 1, and disabling IMDS entirely for agent VMs, according to the deployment’s requirements. AWS’s Lambda MicroVMs reference architecture places execution within the customer’s VPC for control over networking, secrets, and governance. Those controls still need to define what the agent can reach.
Egress restrictions add another layer, but not a substitute. Keeping secrets off the machine prevents local code from reading them, while outbound network policy limits routes for exfiltration. For a bring-your-own-key runner, the decisive security concern is whether the agent can obtain credentials beyond those assigned to its session and use them against resources outside its task.
What should teams evaluate in a bring-your-own API key cloud coding agent runner
Teams should first check which isolation primitive the runner uses. A full VM, a microVM with its own guest kernel, a shared-kernel container, and an OS-level sandbox differ in what they keep apart and what they let an agent do. The provider should make that distinction clear enough to assess root access, service execution, and kernel exposure. A generic claim of sandboxing leaves the central architectural question unanswered.
Credential handling deserves a separate examination from compute isolation. Teams should establish whether metadata endpoints are reachable, whether credentials arrive at session start, and how permissions are scoped, including any inherited from a broader role. Outbound access also needs an explicit policy. Supporting a supplied Anthropic or OpenAI API key is not, by itself, evidence that the runner protects that key from code executed inside the environment.
Whether the repository is ready for work at the start depends on setup scripts, environment variable injection, dependency caches, and service pre-warming. Checkpoint and restore behavior determines idle cost and resume latency. Independent concurrent VMs establish the parallelism model, while attribution to a harness, model, credential, and task lets teams connect agent activity to what actually shipped.
With harness flexibility, Claude Code, Codex, Cursor, and Opencode can use the same environment as task needs change. Depending on the runner’s connections to Slack, Linear, GitHub, or GitLab, background work returns through the team’s existing review paths or through a separate interface. The buying decision therefore calls for a complete execution system, with fresh per-task compute as its starting requirement and a safety case that extends beyond it.


