Infrastructure Review Stack
FeaturesLong read

How Coding Agents Use Sandboxes to Test Their Own Output

Sandboxes let agents run and verify code without host risk.

· 8 min read
Cover illustration for “How Coding Agents Use Sandboxes to Test Their Own Output”
Features · November 15, 2026 · 8 min read · 1,824 words

Coding agents use sandboxes to test their own output without giving generated code unrestricted access to host systems. But safe execution is only the beginning. To complete the write-test-fix loop, an agent also needs an environment that preserves its work and lets it verify the software against the services it actually depends on.

Why coding agents need a live execution environment, not just a linter

A coding agent clones a repository, installs packages, runs terminal commands, edits files, and makes network requests. These are actions with real side effects. A package installation changes the environment in which later commands run. A file edit changes what the next test evaluates.

Static analysis cannot show that the result works. Syntax correctness and functional correctness are different claims, and a linter cannot catch every missing dependency, broken API call, or logic error that becomes evident during code execution. The agent needs to generate code, execute it, observe the output, diagnose a failure, and try again. A sandbox gives that process a controlled execution environment.

Could the agent simply submit its code for human review? It could, but that leaves the reviewer responsible for discovering whether the proposed solution runs at all. Autonomous coding helps by closing that feedback loop before the code goes to review. Human judgment still has a place, while execution gives the reviewer something more substantial than an untested artifact.

Why letting an agent execute code on the host system is not a viable option

Unrestricted host access makes the consequences of generated code depend on the permissions of the machine running it. That risk does not disappear with a more capable model. Andronchik and Lokhmakov’s comparative security study treats insecure AI-generated code as a risk to expect, including XSS and log injection vulnerabilities whose rates stay the same across model sizes. Hallucinated package names introduce a separate supply-chain risk because consistently repeated nonexistent names create opportunities for package squatting.

The problem extends beyond the code itself. Once execution passes to a child process, application-level controls can no longer see what happens, so the agent’s host application cannot enforce the rules on its own. A model’s decision to permit an action is not an independent authorization boundary.

Uchibeke’s pre-action authorization paper documents that distinction through adversarial testing. Social engineering succeeded in a large majority of sessions under a permissive policy but dropped to zero under a restrictive out-of-process policy. The paper also describes sensitive-data leakage triggered by reframing a single verb for agents with persistent memory and shell access. These are authorization failures. The sandbox’s job is to enforce constraints independently of what the agent decides.

What a sandbox actually does inside the write-test-fix loop

A sandbox restricts filesystem access, network egress, and host interaction below the agent’s own decision-making layer. Generated code cannot be allowed to override that boundary. Within it, the agent writes to an isolated filesystem, executes in a contained VM, receives streamed logs, and uses the results to decide whether to revise or commit its work. The host is not the agent’s working directory.

Copy-on-write makes this separation concrete during file changes. Writes are staged in a shadow copy before they are committed, allowing destructive operations to be tested without permanently altering the original state. Logs then supply the evidence needed for the next iteration.

Koyeb’s 2026 platform guide identifies automatic provisioning, strict permissions and secrets policies, logs, rollbacks, and reproducible builds as functional requirements. Together, these make execution both observable and recoverable. They do not, however, replace authorization before execution. Uchibeke’s paper presents pre-action authorization as a complementary layer that intercepts tool calls and evaluates them against declarative policy. Authorization prevents prohibited actions from starting, while sandboxing limits what permitted execution can affect.

How isolation technology choices shape what a sandbox can safely contain

The execution boundary depends on the isolation engine. Standard containers share the host kernel, making them inadequate for arbitrary AI-generated code in multi-tenant or adversarial settings. Firecracker microVMs instead give each sandbox its own kernel behind a hardware-enforced boundary. Their cold-start cost is measured in tens to hundreds of milliseconds. Kata Containers also provide VM-level isolation, but wrap it in a container interface so that teams can retain container tooling.

The other approaches draw different boundaries around execution. gVisor intercepts syscalls through a userspace kernel without full virtualization, providing stronger separation than a standard container with less weight than a microVM. V8 isolates are appropriate only for JavaScript workloads and are not a general-purpose code execution boundary.

The security study finds that engine classes separate clearly across architectural security axes, while products within a class do not. Patch policy becomes the decisive operational variable. Downstream lag can leave even a microVM exposed to known vulnerabilities, so engine choice alone is insufficient. Layering seccomp profiles, namespace restrictions, and out-of-process policy engines adds further protection where supported. Sub-second microVM startup is achievable, making very high concurrency an infrastructure design constraint compatible with isolation.

What the major agent-native sandboxes can and cannot verify on their own

OpenAI Codex runs parallel coding tasks in isolated sandboxes powered by the codex-1 model. It launched with internet access disabled and later restored access, but writing code and running tests inside that boundary does not verify a deployment against live services. Cursor Cloud Agents use isolated VMs and can return multiple PRs with passing CI and artifact demos. Cursor’s engineering team described building “essentially enterprise IT for agents” to make their working environments usable. Deployment verification against real infrastructure was still missing.

Claude Code’s GitHub workflow runs through an @claude mention on PRs and issues using standard GitHub-hosted runners. That setup supports generation and unit tests without staging access, deployment, or preview URLs. GitHub Copilot coding agent works inside GitHub Actions, with internet access restricted to trusted destinations and human approval required before CI/CD workflows run. Its verification boundary is similarly narrower than a deployed application. Passing tests is not the same as exercising the full system.

Qovery approaches that gap through full-stack ephemeral environments in the team’s own cloud. It works with Claude Code, Codex, Cursor, and Gemini, cloning services, databases, and configuration for each agent-opened pull request. This permits deployment and end-to-end verification.

Why stateful execution is what separates a sandbox from a usable agent runtime

A repository, installed packages, modified files, build artifacts, environment variables, and process state accumulate across many LLM calls. If the environment discards them between steps, the agent must reconstruct its working context before proceeding. Re-cloning and reinstalling can serve short tasks, but repeated setup adds latency and fragility to longer work.

Zhang et al.’s “From Chatbot to Digital Colleague” paper frames persistent workspaces, reusable procedures, and task closure as an architectural shift beyond ephemeral tool calls. Its “Workspace + Skill” paradigm treats continuity as part of the execution model. DeltaBox proposes millisecond-level sandbox checkpoint/rollback for stateful AI agents, addressing the practical need to preserve a known-good state before risky work. Recovery then need not mean restarting the entire session.

LangGraph passed its 1.2 milestone with durable execution and stateful workflows as headline features, reflecting the need for long-running agent processes to remain active and correct. Cloudflare’s Durable Objects and Bedrock AgentCore Runtime address the same need at the infrastructure layer. Suspend-and-resume keeps that state across tasks that last for hours or wait for human review. An ephemeral sandbox is a safety tool, while a stateful runtime lets a multi-step write-test-fix loop reach completion.

How computer-use agents extend the loop to GUI environments with no API surface

Some tasks cannot be done through shell commands or service APIs. Legacy portals, desktop applications, and regulatory submission systems may need the agent to use a graphical interface. Computer-use agents see the screen, decide what to click or type, and act in the live application. The execution environment must therefore include a desktop.

OpenAI shipped Computer Use for Windows in Codex App v26.527.1 on 29 May 2026, giving the agent the ability to see, click, and type inside Windows desktop applications. To contain it, the environment needs an isolated display server, a contained browser or application process, limits on network egress, and audit logging of what happens on screen. That is a broader isolation problem than shell execution.

Alibaba’s Qwen-UI-Agent research infrastructure can run up to 10,000 isolated environments in parallel for large-scale training. The Qwen-UI-Agent source reports success on roughly a third of complex tasks for a fully autonomous desktop agent in 2026. That result applies specifically to those complex tasks. For high-stakes GUI work, human oversight remains part of the loop, and purpose-built virtual desktop infrastructure is necessary but insufficient on its own.

What enterprise security and compliance require from a sandbox that runs AI-generated code

SOC 2 Type II certification does not establish HIPAA compliance. HIPAA requires separate analysis of regulated roles, BAAs, safeguards, risk, permitted uses, and PHI handling. Treating one framework as a substitute for the other leaves a procurement gap. Ventus AI provides a concrete regulated deployment, maintaining SOC 2 Type II and full HIPAA compliance with BAA execution for daily healthcare claim status checks at organizations such as Smilist without exposing PHI.

The agent must be inside the audited system boundary. Its action logs must meet the security and availability requirements that apply to that system, with no exemption for records from an unrelated third-party tool. ISO 27001 adds another general procurement consideration, while the EU AI Act and NIST AI RMF address high-risk AI and federal-adjacent risk contexts respectively. These frameworks shape both runtime selection and documentation after deployment.

Persistence also has consequences for personal data handling. GDPR obligations follow the data, requiring a lawful basis and constraining retained context through data minimization, while preserving applicable rights concerning automated decisions. Customer-managed compute can make residency, sovereignty, and audit ownership easier to satisfy. Open-source, auditable runtimes also let compliance teams supplement vendor attestations by inspecting execution behavior. A stateful environment must therefore preserve useful work without treating indefinite retention as its default entitlement.

What to look for when choosing infrastructure to run the write-test-fix loop in production

For untrusted autonomous code in production, teams should require hardware-enforced isolation rather than ordinary shared-kernel containers, distinguishing microVM separation from a userspace-kernel approach. They should also ask for data on patch cadence and documentation of the pin policy. In regulated settings, teams should check compliance posture and customer-managed compute requirements at this stage, before they narrow their choices by comparing features.

Sub-second provisioning supports responsive parallel work, while persistent environments, snapshots, checkpoint/rollback, and suspend-and-resume support continuity. Neither capability substitutes for verification reach. Teams that need end-to-end evidence should ask whether the agent can supplement unit-test results with deployment, access to real databases, and a working preview.

Teams should give the interface just as much attention because every iteration depends on it. SDKs and APIs need to support environment creation, command execution, output streaming, file transfer, process management, networking, snapshots, and cleanup. Docker-native compatibility allows existing workloads to move without a stack rewrite.

Sources

  1. Before the Tool Call: Deterministic Pre-Action Authorization for Autonomous AI Agents
  2. AI Code Sandboxes: A Comparative Security Study. Part 1 of 2 -- Engine-Level Properties (Attack Surface, Leakage, Stackability, CVE History, Patch Cadence, Fuzzing)
  3. From Chatbot to Digital Colleague: The Paradigm Shift Toward Persistent Autonomous AI

More in Features