# Build a secure computer for your agent
<!--
ref: @content/youtube/langchain/2026-07-23-build-a-secure-computer-for-your-agent
version: 3
updated_at: 2026-10-31T18:22:54.575Z
-->

From LangChain, 2026-07-23: Agents have moved from answering questions to writing and running code, and the run-observe-fix loop is what separates a demo agent from a production one.

**[Watch on YouTube](https://www.youtube.com/watch?v=DHTnxP6oUIk)**


*Synthesized from Amy and Mukil on LangChain, 2026-07-23.*

Amy, a product manager at LangChain, and Mukil, an engineering manager at LangChain, present the case for giving every agent its own isolated, disposable computer and walk through how LangSmith Sandboxes implement that.

## Core Thesis
Agents have moved from answering questions to writing and running code, and the run-observe-fix loop is what separates a demo agent from a production one. That loop requires a real computer, but agents execute untrusted code by definition, so the computer must be isolated at the hardware level, disposable, fast to start, and scalable to thousands of instances. Containers and personal machines (laptops, Mac Minis) don't meet those requirements; microVM sandboxes with network-level egress control and snapshotting do.

## Key Insights
- **Why code execution changed agents:** Mukil contrasts LLMs of two years ago (failing at "3 + 3" or counting the R's in "strawberry") with today's agents, which handle abstract tasks by writing and running code. They estimate roughly 70%+ of the audience uses a local coding agent.
- **Use cases beyond coding:**
  - *Software engineering:* Open SWE (LangChain's open-source "online software engineering factory"), Claude Code, Devin, Ramp's Inspect agents (tag in Slack, get PRs). Mukil cites Sierra saying one of its agents is responsible for 70–80% of PRs at the company.
  - *Data analysis:* rather than building bespoke SQL or spreadsheet tools, let the agent write Python with pandas, give it direct SQL access via a CLI, and mount files from GCS. Examples: Hex, Julius.
  - *Security testing:* agents running pen tests and exploits (e.g., SSRF attempts) against targets you control; Project Glasswing cited as an example.
  - *Browser and computer use:* driving apps without APIs (Windows, Microsoft Word) via screenshots and simulated desktops; Browserbase and monday.com cited. Mukil notes performance here is still maturing.
- **The risk is concrete, not hypothetical.** Mukil lists recent incidents: a Codex model deleting all files on a user's local machine, the self-propagating Shai-Hulud npm supply-chain worm that stole developer tokens, a remote code execution attack on n8n's sandbox, a config injection attack on Google's Antigravity IDE, and the "Copy Fail" container escape in April.
- **What a sandbox is:** an isolated, disposable environment, separate from your own infrastructure, with three properties:
  1. *Isolated* — its own filesystem and memory, plus granular network control.
  2. *Disposable* — used for one or two tasks, then thrown away; highly parallelizable (you can't throw away or buy a thousand Mac Minis).
  3. *Full environment* — a real shell and package installation, not just a code interpreter or WASM runtime, so the agent can fetch whatever tools a task needs.
- **Four production requirements and LangSmith's answers:**
  - *Speed/scale:* median spin-up around 1 second (Mukil says it's now faster than the slide shows); scales from zero to thousands in parallel and back. Open SWE keeps a warm pool so sandboxes are ready in seconds rather than a ~1-minute cold start.
  - *Security:* every sandbox is a hardware-virtualized microVM with kernel-level isolation, so container kernel escapes don't apply. An **auth proxy** sits man-in-the-middle on all egress: credentials are installed on the proxy and never touch the runtime, and traffic can be restricted to allowlisted destinations (blocking package registries, unapproved MCP servers, etc.).
  - *Long-running, interruptible work:* average agent tasks have grown from 1–5 minutes a few years ago to 10–20 minutes now. Sandboxes keep persistent state, support pause/resume, have a configurable idle TTL (e.g., idle after 15 minutes) with automatic wake on the next request, have no maximum lifetime, and allow multiple concurrent clients on one sandbox.
  - *Recovering from mistakes:* snapshot and restore from any point in the agent lifecycle, roll back, or fork to try multiple approaches in parallel.
- **The demo:** Amy asks Open SWE to add a JSON output flag to a CLI `status` command. With nothing provisioned locally, Open SWE requests a sandbox (own filesystem, shell, package manager), plans, edits files, installs dependencies, runs the test suite, iterates on failures, and returns green tests plus a real PR/commit for human review. The LangSmith Sandboxes view shows each sandbox, with:
  - *Snapshots* to boot from a pre-built image containing exactly the needed tools.
  - *Mounts* for S3 buckets, GCS, or git repos.
  - *Permissions* controlling which people can touch a sandbox.
  - Regions in the US, EU, or APAC for data residency.
- **Why not Docker or local execution:** Amy explains that agent code comes from models, user prompts, cloned repos, and installed packages — none of which you wrote or can fully vet. Containers share a kernel with the host, so they aren't a true isolation boundary for untrusted code. Mukil adds that Docker can be hardened, but only by dropping root and privileges, which cripples tasks like security exploit testing.
- **Network lockdown is the strongest control.** For detonating malware or clicking malicious links, Mukil calls network-level controls "probably the most powerful" protection: if egress is limited to domains you control and no credentials live on the box, an attacker can't exfiltrate data to a webhook or arbitrary site. This mirrors how enterprises lock down employee machines.
- **Kubernetes is a poor fit for user-facing sandboxes.** Scheduling latency can reach about 8 seconds per box. LangChain started on Kubernetes and moved off it in favor of serverless-style infrastructure.
- **Access control:** by default, only the creator (plus admins) can access a sandbox; LangSmith's ABAC/RBAC model can attach tags to grant access to specific groups.
- **Other operational details from Q&A:**
  - Every command gets an ID and runs as its own process, so you can run a full local stack (multiple servers) in one sandbox.
  - stdout/stderr logs are viewable only while the sandbox is up; restart it to see them again.
  - State persists across stop/start. Memory snapshotting saves running processes too, or you can snapshot the filesystem only. Sandboxes can be forked or cloned from a snapshot.
  - You choose attached disk size; GCS, GitHub, and S3 mounts are supported, but custom volumes (your own SSD) are not yet.
  - Bring-your-own images: LangChain builds a VM from your Docker image's dependencies, commonly preloading tools like ffmpeg, Playwright, and agent-browser into an initial snapshot.
  - The sandbox backend class is open and subclassable — implement a few methods like `exec` to target another provider.
  - No GPU support yet; it's hoped for later in the year.
  - A self-hosted sandbox option is in progress for highly regulated or air-gapped environments, ideally running separate from application infrastructure.
- **Roadmap:** local-to-remote session handoff (start a session locally, push it to the cloud), shared volumes, and full execution tracing. Free usage on every plan, including free, was announced, described as roughly 100 minutes of sandbox time.

## Actionable Takeaways
1. **Never run agent-generated code on your laptop or production hosts.** Treat every agent's output as untrusted and execute it in a disposable environment you're willing to see wiped.
2. **Use microVMs, not plain containers, for untrusted code.** Containers share the host kernel. If you must use Docker, drop root and privileges and accept the reduced capability.
3. **Keep credentials off the runtime.** Inject them at an egress proxy, as LangSmith's auth proxy does, so a compromised sandbox has no secrets to steal.
4. **Default-deny network egress.** Allowlist only the domains and MCP servers the task needs. This is the single strongest protection against exfiltration, especially for malware analysis or browsing untrusted links.
5. **Pre-bake images and keep a warm pool.** Package dependencies like ffmpeg and Playwright into a snapshot image, and keep sandboxes warm to avoid ~1-minute cold starts.
6. **Avoid Kubernetes for user-facing sandbox spin-up** if ~8-second scheduling latency is unacceptable; prefer serverless-style provisioning targeting ~1-second starts.
7. **Configure an idle TTL** (e.g., 15 minutes) with pause/resume, so 10–20-minute tasks keep their state without paying for idle compute.
8. **Snapshot at checkpoints.** Roll back after agent mistakes, or fork from a snapshot to explore several approaches in parallel.
9. **Scope access by default.** Limit each sandbox to its creator plus admins, and use tag-based ABAC/RBAC to share with specific groups.
10. **To use a different provider,** subclass the sandbox backend protocol and implement methods such as `exec`.

## Notable Quotes
> "The question isn't whether agents need computers. It's how you give them one safely." — Amy (LangChain)

> "If you told your security team I was allowing something to run arbitrary code, they'd probably roll over in their grave." — Mukil

> "Containers share a kernel with the host… just because you have a container doesn't mean it's an isolation boundary." — Amy

> "If an agent installs something malicious, that blast radius is just that one throwaway VM and nothing else." — Amy

> "Lock down the network of your VM itself… it's probably the most powerful way to protect this sandbox." — Mukil

---

*You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).*

*Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*