AivexaNewsSearch
AI news for builders and product teamsChecked every hour

How to Choose the Right Sandbox for AI Agents

Collected Nov 18, 2026

LangChain has published guidance on selecting a sandbox for AI agents that write and execute code, framed around five properties it says a credible sandbox must provide. The company also used the guide to promote LangSmith Sandboxes, a managed execution product built into its LangSmith agent engineering platform, which it says is already used by companies including Monday.com. The post is written by LangChain and carries an explicit product pitch at the end, so the evaluation criteria and the product description come from the same vendor.

The problem being addressed is that code execution is among the most valuable capabilities an agent can have, and also among the riskiest. The guide points to prompt injection as the main vector: there is currently no surefire way to stop it, and hostile instructions can reach an agent through end-user input, responses from external MCP servers, or third-party written skills. The guide cites Simon Willison's "lethal trifecta" — access to sensitive data, exposure to untrusted content, and the ability to communicate externally — as the condition under which an attacker can exfiltrate data through an agent.

LangChain also references Meta's "Agents Rule of Two," which was itself inspired by Willison's trifecta and by Chromium's security Rule of Two. Under Meta's framing, an agent should not run fully autonomously in a session where it can process untrustworthy inputs, reach sensitive systems or private data, and change state or communicate externally. If a task needs all three, Meta recommends human approval or another reliable validation step. The guide's example is an email assistant that reads messages from unknown senders, sees a private inbox, and can send replies — a malicious instruction in an inbound message could turn that combination into data disclosure or an unauthorized send.

Sandboxes are positioned as a way to shrink each leg of the trifecta rather than eliminate it. The guide is candid that isolation does not remove any risk factor outright; the goal is to reduce data access and outbound communication to a level a team can reason about. The five criteria it lists are an isolated filesystem containing only the data the agent needs, network access limited to named external endpoints, compute and memory limits with a time bound, control over whether sandboxes are reused across executions, and kernel-level isolation from the host machine.

The last point carries the most technical weight. The guide notes that operating system kernels frequently contain bugs, and a compromised agent could exploit one to escape the controls meant to contain it. The fix is virtualization: the sandbox runs on its own kernel rather than the host's. MicroVMs are recommended as the efficient form of this, providing kernel isolation without the overhead of a full virtual machine per sandbox.

The guide warns that not every product marketed as a sandbox meets these bars. It singles out the open-source Kubernetes Agent Sandbox as secure only when deployed on a cluster enforcing kernel-level isolation between containers, which it says most Kubernetes clusters do not do. That is a useful caution for teams assuming container boundaries are equivalent to VM boundaries; in practice, containers share the host kernel, so a kernel exploit crosses every container on the node.

A second design question is where the agent itself runs. LangChain describes two patterns, attributed to CEO and co-founder Harrison Chase. In the first, the agent is baked into the sandbox image and runs inside it, which closely mirrors local development but requires rebuilding and redeploying the image on every agent change. In the second, the agent runs on the team's own server and calls the sandbox through an API whenever it needs to execute code. LangChain argues for the tool pattern on three grounds: agent logic can be updated without rebuilding an image, API keys stay outside the sandbox, and agent state remains separate from execution. The trade-off it names is network latency, since each execution crosses the network. Deep Agents supports both patterns.

LangSmith Sandboxes is LangChain's own implementation of the checklist. Each sandbox is backed by a dedicated microVM with its own filesystem, giving kernel-level isolation from other sandboxes and from the underlying infrastructure. Customers control the lifecycle from start through shutdown to eventual destruction, and can reuse a sandbox as much or as little as they want. Network access for processes inside the sandbox is configurable, including none at all. An authorization proxy injects credentials into outbound traffic after it leaves the sandbox, so secrets need not sit inside the environment where untrusted code could read and misuse them. LangChain says the product was subjected to penetration testing and is managed through the same API and authentication used for its observability, evaluation and deployment features; adding it to an agent built with LangChain, LangGraph or Deep Agents is described as a few lines of code.

For developers, the practical takeaway is the checklist itself, which applies regardless of vendor. The credential-injection detail is worth noting: it addresses a gap that filesystem and network controls do not, since an agent often needs to call an authenticated service and the naive approach is to place the key inside the sandbox. The reuse knob likewise encodes a real trade-off, because persistent sandbox state is convenient but lets a single compromise survive across runs.

Why it matters: teams giving agents the ability to write and run code are effectively running untrusted programs on their behalf, and the guide's criteria give them a concrete way to audit whatever sandbox they adopt, including the container-based setups many already have. LangChain's launch signals that sandboxing is becoming a first-class feature of agent platforms rather than something teams assemble themselves. The likely result, as an inference rather than a stated claim, is that buyers will start asking vendors for kernel isolation, egress controls and credential proxying by name.

Read at LangChain

Based on reporting from the original publisher. Visit the source for full context and later updates.

Publisher excerpt

Learn how to choose a secure sandbox for AI agents, with guidance on filesystem isolation, network access, resource limits, and microVMs.