Cover illustration for “Agent Isolation Options for Small SaaS Builders”
Building With Agents

Agent Isolation Options for Small SaaS Builders

November 7, 20269 min read2,038 words

Share

Text: Derek Tran

Choose the right sandbox for your agent's risk profile and workload.

A managed platform can give each customer an isolated, persistent AI agent sandbox through a single API call at onboarding, so the team does not have to build its own provisioning infrastructure. For small SaaS builders, the choice is not whether to isolate customers, but which security boundary and operating model fit the workload. Agents that execute code need microVM isolation, while containers with tightly scoped access can be enough for bounded task automation.

Why per-user agent isolation is a real architectural decision, not a security checkbox

An agent deleted a developer’s desktop, documents, and keychain because “the agent runs as you, on your filesystem, with your credentials, and nothing sits between the model’s decision and the shell’s execution”. That is the failure behind the Docker “horror story”. No elaborate intrusion was needed. The agent could act with the developer’s authority, so a bad decision became a destructive shell command.

Ambient authority lets an agent inherit filesystem access, database credentials, and network reach from its environment, whether the task needs them or not. A prompt injection in a document, a poisoned MCP tool, or a hallucinated command can turn that access into credential theft or data exposure. In a multi-tenant SaaS product, the damage can cross customer boundaries if their agents share an unrestricted execution environment.

Meta’s Agents Rule of Two, published in October 2025, spells out this conflict. A session should do no more than two of these three things: process untrustworthy input, access sensitive systems or private data, and change state or communicate externally. A task that needs all three needs a fresh session or human approval. Those tensions remain with per-user isolation, but it stops one customer’s execution environment from becoming a way into everyone else’s.

What a sandbox actually enforces, and what it does not

A sandbox answers a narrow question about execution. When the agent acts, where does the action land? Resource limits constrain CPU, memory, network use, and execution time, while capability controls restrict reachable files, APIs, and network endpoints. Auditability makes actions observable and logged, and deterministic teardown allows the environment to be destroyed without residual state. These enforcement properties work alongside agent permissions, guardrails, and human approval.

The boundary must also cover the right process. Limiting what the assistant can do while letting the code it generates run with full authority leaves the same problem in the code. MCP tool calls need scoping too, because a poisoned server can supply payloads that target credentials accessible in the agent’s environment. For untrusted code, the 2026 operational default is a microVM with its own kernel, secrets held outside the sandbox and injected by a proxy only for allowlisted destinations, and network egress restricted to an allowlist.

The four isolation technologies and what each one actually trades off

Security strength is only one axis of this choice. Startup time, memory overhead, compatibility, and operating effort pull in different directions. The four main approaches are containers, gVisor, microVMs, and V8 isolates, but they do not form a simple best-to-worst ranking. In particular, a fast, tightly bounded JavaScript runtime is not interchangeable with a full development environment.

OCI containers, including Docker/runc, use Linux namespaces and cgroups while sharing the host kernel. They start in approximately 100ms and have very low memory overhead. Their boundary is comparatively thin. They fit trusted workloads, internal tools, and developer environments where the code author and agent operator are the same person. They are not an appropriate boundary for multi-tenant SaaS agents executing untrusted or externally influenced code.

gVisor puts a user-space kernel called Sentry between sandboxed code and the host. Sentry intercepts and validates system calls, handling them itself or proxying a safe subset to mediate access to the host kernel. It takes approximately 300–430ms to start, and each instance has approximately 48–50MB of memory overhead. Compatibility is the price of that stronger boundary. Unsupported operations include ptrace, raw sockets, and some ioctl calls, which also rules out native libraries that depend on them.

MicroVMs give each sandbox its own Linux kernel, with hardware virtualization enforcing separation at the CPU level. Firecracker, built by AWS for Lambda and Fargate, strips away devices a sandbox does not need, including PCI, USB, and legacy devices. It takes approximately 125ms to start, and each instance has approximately 5MB of memory overhead. A separate kernel strengthens containment beyond shared-kernel containers. Kata Containers wraps microVM technology, including Firecracker and Cloud Hypervisor, in a Kubernetes-compatible interface for teams that need VM-grade isolation within container workflows.

V8 isolates take a different route entirely. They separate memory spaces inside one process, with no container, VM, or separate kernel, starting in under 1ms with approximately 1MB of overhead. The execution scope is JavaScript and Wasm only. Their security surface also needs care because V8 bugs are more common than hypervisor vulnerabilities, with mitigations including rapid patching, a second-layer Linux sandbox, Memory Protection Keys, and Spectre defenses. This model fits lightweight workloads that can run entirely within that scope.

Beyond these four approaches, full KVM VMs add broader OS support, full device emulation, and nested virtualization at greater weight. They fit workloads needing features such as GPU access or full Linux environments with systemd and multiple users. Docker-in-Docker does not always require that heavier route. Docker Sandboxes gives each sandbox a dedicated microVM and private Docker daemon, avoiding the need for privileged mode.

Matching isolation model to SaaS use case — three patterns that cover most small teams

The first pattern is lightweight task automation with no arbitrary code execution. These agents use bounded tools to call APIs, send emails, create records, or run scheduled workflows. Composio’s toolkit combinations, including Gmail with Notion and GitHub with Linear, illustrate this workload. Containers are defensible here with strict egress controls and scoped credentials, provided the agent does not execute user-supplied or generated code. An OAuth credential can still authorize a state-changing action, leaving a real risk.

Credential handling therefore deserves as much attention as the runtime. Composio’s managed-auth model stores OAuth credentials centrally in connected accounts, so the agent does not touch a raw token. That reduces ambient authority without requiring microVM overhead for every bounded tool call. The design rule is straightforward. Even a task-only agent should receive no more access than its specific job needs.

The second pattern is a coding or development agent, such as Claude Code, Codex, OpenCode, or Hermes, working against a customer’s codebase. Shell access, package installation, tests, and file changes make microVM-per-session isolation the default. Claude Code’s sandbox is opt-in and needs deliberate configuration, while Codex CLI’s sandbox is on by default. A SaaS host still needs to keep each customer session isolated from other tenants’ filesystems and networks.

Networking is a required part of that boundary. OpenAI blocks internet access by default during the agent phase of Codex cloud tasks, but when access is turned on, it allows domain and method controls for each environment. OpenAI also documents the prompt-injection and exfiltration risks of enabling it. An agent that can install packages or browse external content has more ways to encounter hostile input, even when its own instructions are sound.

The third pattern is regulated or customer-cloud hosting. Data residency, audit requirements, or contracts may mean the agent has to run inside the customer’s cloud account and region. Kubernetes-native deployments using Kata Containers or gVisor fit this requirement, and the open-source Agent Sandbox project under Kubernetes SIG Apps supports both backends. Composio also supports self-hosting in a customer’s cloud account and region. This pattern demands the most operational attention because Kubernetes, sandbox runtimes, and warm pools all need maintenance.

The environment lifecycle question — ephemeral vs. persistent sandboxes and when each fits

Isolation determines the boundary, while lifecycle determines what survives. Ephemeral sandboxes fit testing, isolated code execution, and one-shot analysis where a clean start is useful. A complete teardown clears any state left in that environment. But each new start means setting up again, including installing packages and restoring context, which costs more when the working state is complex.

Persistent sandboxes fit coding agents, research workflows, and multi-step automation that must retain files, packages, and intermediate work. They map naturally to a customer’s private agent, provisioned at onboarding and available for later interactions. Persistence need not mean constant uptime. Snapshots, reusable images, suspend-and-resume support, and persistent storage are the lifecycle features to evaluate. For high-concurrency ephemeral work, warm pools or snapshot-based cloning can reduce startup delays, but operating those mechanisms adds to the self-hosting burden.

What self-managing sandbox infrastructure actually costs a small team

The recurring expense includes engineering time as well as compute. A self-managed microVM setup needs a configured monitor such as Firecracker or Cloud Hypervisor and an orchestration layer such as Kubernetes with Kata Containers. Warm-pool management, snapshot logic, egress controls, and secret injection then have to fit together. None of that ends at launch. Agent frameworks change, vulnerabilities appear, and provisioning, monitoring, patching, and recovery remain ongoing work.

For a small team, those hours take time away from building the product and finding customers. A memory-optimized VPS bill describes only part of the cost, while the time needed to operate it does not shrink as the customer base grows. The useful break-even question is how many engineering hours maintenance consumes each month and what those hours would otherwise produce. Dedicated infrastructure expertise and enough volume can justify building. Without them, cheap compute can hide how much it costs to keep the setup running.

How can each customer get a persistent agent sandbox through one API call?

With managed sandbox hosting, a provider runs the infrastructure, and the same security requirements still apply. A platform built for this model can set up an isolated, persistent per-user agent sandbox through a single API call. The logic resembles using Stripe for payments. A small SaaS team can need what an infrastructure company provides without having to build that company itself.

The provider’s actual isolation is the first evaluation criterion. An environment backed by a microVM differs from one that keeps tenants distinct at the application level on shared infrastructure. The next questions concern persistent state and automated provisioning, because an ephemeral task runner does not provide the same product as a customer’s continuing agent. A provider must fit the intended lifecycle as well as the workload’s security boundary.

Operational checks extend beyond the runtime itself. Encryption in transit and at rest, audit controls, and SOC 2 certification are evaluation criteria that require verification even when a provider uses the word “managed”. Integrations also need scrutiny, especially whether agents can reach Gmail, Slack, GitHub, or WhatsApp without receiving raw credentials. Builders who resell agent capacity also need white-label support. The customer’s private, persistent, branded environment should be activated automatically at onboarding.

A practical decision framework for choosing your isolation model

The decision starts with what the agent can do. If it only makes bounded, predefined tool calls and executes no arbitrary code, containers with strict egress and scoped credentials are defensible. The saved engineering time belongs in credential scoping and audit logging. If it executes user-supplied or generated code, consumes external content, or has shell access, the path changes to a microVM per session.

The next branch is who supplies the workload and what the team can operate. Trusted internal tooling has a different exposure from customer-influenced execution, and multi-tenant customer workloads require per-user boundaries. A team can run a self-managed deployment if it has dedicated infrastructure engineers and enough volume. Otherwise, a managed platform that provisions those boundaries is the operational alternative. When residency or bring-your-own-cloud requirements apply, the team has to choose a Kubernetes-native setup with Kata Containers or gVisor, or a managed provider that supports the customer-cloud deployment it needs.

Customer expectations then decide the lifecycle. A disposable task fits an ephemeral sandbox, while a customer’s continuing agent generally calls for persistent state. In both models, secrets belong outside sandbox images, proxy injection should go only to allowlisted destinations, and egress to the open internet should be off by default. Deterministic teardown remains necessary when an environment is destroyed. With those decisions separated, choosing an isolation model no longer requires becoming an infrastructure expert, because the architecture is understood and managed platforms exist, leaving trade-offs the builder can control.

More in Building With Agents