← AUTOMATER NEWSROOM

External Sandboxes Let Coding Agents Run Risky Code Outside the Machine

External sandboxes run risky agent code outside the machine. What Nov. 17 guides say about egress limits, secret isolation, and full-repo context for teams.

Diagram showing an agent outside sending code through a localhost API to an isolated sandbox with allow-list proxy and credential replacementDiagram showing an agent outside sending code through a localhost API to an isolated sandbox with allow-list proxy and credential replacement
Original explanatory illustration of the external-sandbox pattern central to the article.

Running code is what makes a coding agent useful, and what makes it risky. When an agent can write and execute programs, it can analyze data, fix tests, and automate chores. The same loop can be steered by prompt injection into reading private data and sending it elsewhere.

Two Nov. 17 reports, alongside LangChain’s Oct. 1 guide, clarify a practical fix. Simon Willison described an external-sandbox pattern built with Prime Radiant, with three runnable servers that execute agent code outside the agent machine. Sourcegraph explained why monorepo agents need server-side search when the local checkout is only a slice. With LangChain’s sandbox selection guide, published Oct. 1, they give operators a posture: isolate execution, gate network and secrets, and supply precise context.

For background, see Automater’s securing AI agents guide and Docker Sandboxes setup for Claude Code.

External execution with guardrails

Willison frames the work as safer experimentation with local models: try models without letting a mistake or prompt-injection attack damage the main machine. The agent lives outside the sandbox. Code it wants to run is sent to a dedicated sandbox through the same localhost API in all three implementations. Operators can configure Pi, Claude Code, or Codex to use that API for execution.

The key controls are an optional HTTP and HTTPS allow-list proxy limiting which hosts agent code can contact, and credential replacement for authenticated calls without sharing secrets with the agent. The proxy can be reconfigured while the sandbox keeps running.

Simon Willison blog post titled External sandboxes for coding agents dated November 17 2026
Simon Willison blog post introducing the external-sandbox pattern and three sandbox server implementations. Source: Simon Willison. · Original source

What to demand from a sandbox

LangChain’s guide, published Oct. 1, starts from the same threat. It cites Willison’s lethal trifecta — access to sensitive data, exposure to untrusted content, and ability to communicate externally — and Meta’s Agents Rule of Two. An email assistant reading unknown senders, accessing a private inbox, and sending replies is the canonical case where all three hold.

Sandboxes do not remove that risk. They shrink data access and external communication until prompt-injection risk becomes manageable. The guide lists five properties:

  • Isolated filesystem with only the data the job needs
  • Limited network access with explicit per-endpoint egress
  • Resource limits on compute, memory, and lifetime
  • Controlled reusability across runs
  • Kernel-level isolation, ideally with microVMs on a separate kernel

It warns some products called sandboxes lack these properties, citing the open-source Kubernetes Agent Sandbox as secure only with kernel isolation most clusters do not enforce. It also contrasts agent in the sandbox with sandbox as a tool. The tool pattern keeps agent logic updatable, keys outside the sandbox, and state separate from execution, at the cost of network latency.

Three servers, one API

The new contribution is runnable code in the sandbox-as-tool shape:

Implementation Server Execution inside
external-sandbox-v86 Node.js Alpine Linux in WebAssembly via v86
external-sandbox-container Python Alpine Linux in Apple Containers
external-sandbox-quicksand Python Alpine Linux via Microsoft Quicksand with QEMU

All three expose the same localhost API. Operators can swap isolation without changing how Pi, Claude Code, or Codex calls execution. Start with the container or Quicksand variant where native container or QEMU support is simplest, and keep v86 for portable WebAssembly trials.

Treat the allow-list as mandatory. List only the registry, model API, and Git hosts the task needs, then review blocked requests before widening:

registry.npmjs.org
api.anthropic.com
github.com

Do not paste long-lived tokens into agent context or sandbox environments. Prefer short-lived credentials injected after traffic leaves the sandbox, so a compromised run yields at most a scoped token.

Diagram comparing v86, container, and quicksand sandbox servers sharing one localhost API and proxy controlsDiagram comparing v86, container, and quicksand sandbox servers sharing one localhost API and proxy controls
Original diagram comparing the three external sandbox implementations and their shared controls.

Monorepo agents still need full context

Sourcegraph’s analysis covers the other half: agents often work half-blind. Grep, IDE find-references, and git status see only the laptop disk. Canva’s example of about half a million files where plain git status took about 10 seconds shows why teams use sparse checkouts. Each developer and agent then sees only a slice.

The post argues for a server-side index of the whole repository, on any branch, without a checkout. Precise navigation separates definitions from references and text matches. For agents, the Sourcegraph MCP server and Code Finder provide full-repo search, go-to-definition, and find-references with smaller and more precise results than raw text search, even with a partial checkout.

The pattern is therefore split: run untrusted code in an external sandbox with deny-by-default egress, but supply trusted context from a full-repo index rather than a wider checkout. Batch changes split by ownership extend the same idea from reading code to changing it safely.

Operator checklist

  1. Map the trifecta for your busiest agent: private data, untrusted inputs, and write or network reach.
  2. Apply the five sandbox checks before trusting any sandbox label.
  3. Pilot one external sandbox for local-model or untrusted-repo work, with the allow-list and credential replacement enabled.
  4. For monorepos, add precise server-side search instead of cloning more.
  5. Log tool calls, first-seen egress domains, sensitive-path reads, and token spikes.

Sandboxes do not solve prompt injection. No reliable prevention exists today. The verifiable gain is narrower: external API-driven execution with allow-listed egress and secret isolation makes failure cheaper, while full-repo search keeps the agent accurate without widening its filesystem.

Sources

Sources

  1. How to Choose the Right Sandbox for AI Agents
  2. External sandboxes for coding agents
  3. Why large monorepos need code search, especially with AI coding agents | Sourcegraph