---
title: "How to Choose the Right Sandbox for AI Agents"
description: "Agents that write and run code face prompt injection risk, and Willison's \"lethal trifecta\" (sensitive data, untrusted content, external communication) and Meta's \"Agents Rule of Two\" frame when autonomy becomes dangerous."
url: "https://swe.quest/articles/how-to-choose-the-right-sandbox-for-ai-agents-9eb1c4b875269506"
canonical: "https://www.langchain.com/blog/how-to-choose-the-right-sandbox-for-your-agent"
source: "LangChain"
published: "2026-11-18"
difficulty: "easy"
kind: "Opinion"
reading_minutes: 7
tags: ["sandboxing","ai-agents","security","virtualization"]
---

# How to Choose the Right Sandbox for AI Agents

A post on [LangChain](https://swe.quest/sources/langchain.md), published 2026-11-18, 7 min read, Opinion. Original: [https://www.langchain.com/blog/how-to-choose-the-right-sandbox-for-your-agent](https://www.langchain.com/blog/how-to-choose-the-right-sandbox-for-your-agent)

## Summary

Agents that write and run code face prompt injection risk, and Willison's "lethal trifecta" (sensitive data, untrusted content, external communication) and Meta's "Agents Rule of Two" frame when autonomy becomes dangerous. A good sandbox narrows that exposure with an isolated filesystem, egress allowlists, resource limits, controlled reuse, and kernel-level isolation via microVMs, since container-only setups like a default Kubernetes Agent Sandbox deployment share the host kernel. Running the sandbox as a tool rather than putting the agent inside it keeps API keys and agent state out of the execution environment at the cost of network latency. The piece closes by pitching LangSmith Sandboxes, which use per-sandbox microVMs and an auth proxy that injects credentials outside the sandbox.

Written by swe.quest, not by the author.

**Difficulty:** Easy: no special background needed; explains what something is and why it matters

## Topics

- [Sandboxing & isolation](https://swe.quest/tags/sandboxing.md) (Security)
- [AI agents](https://swe.quest/tags/ai-agents.md) (AI & ML)
- [Security](https://swe.quest/tags/security.md) (Security)
- [Virtualization](https://swe.quest/tags/virtualization.md) (Infrastructure)

## Prerequisites

- prompt injection ([easy posts on Application security](https://swe.quest/tags/appsec.md?difficulty=easy))
- LLM agents and tool calling ([easy posts on LLMs](https://swe.quest/tags/llms.md?difficulty=easy))

## Keywords

LangSmith Sandboxes, lethal trifecta, Agents Rule of Two, microVM, Deep Agents, Kubernetes Agent Sandbox, prompt injection

## Related posts

- [Docker Sandboxes vs. Containers: Choosing the Right Isolation for AI Agents](https://swe.quest/articles/docker-sandboxes-vs-containers-choosing-the-right-isolation-for-ai-agents-9c74485ae65a1b1c.md): Docker · 2026-11-06 · Medium · 14 min read · Sandboxing & isolation, AI agents, Containers, Virtualization, Security
  Containers are isolated processes sharing the host kernel. Docker Sandboxes are microVMs with their own kernel, filesystem, network and private Docker Engine, designed for autonomous coding agents that accumulate state for hours and act on untrusted instructions.
- [How to Secure AI Agents: A Practical Overview for Development Teams](https://swe.quest/articles/how-to-secure-ai-agents-a-practical-overview-for-development-teams-8ef3e4fd91efa459.md): Docker · 2026-06-02 · Easy · 9 min read · AI agents, Sandboxing & isolation, Identity & auth, Security, Observability
  AI agents need a different security model than traditional services because they select tools, chain actions and act on credentials autonomously, widening the blast radius of prompt injection or tool poisoning.
- [The Untrusted Autonomous Workload: How AI Coding Agents Reshape What Isolation Has to Do](https://swe.quest/articles/the-untrusted-autonomous-workload-how-ai-coding-agents-reshape-what-isolation-af433bee97ff8809.md): Docker · 2026-05-26 · Medium · 16 min read · Sandboxing & isolation, Virtualization, AI agents, Containers, Supply chain security
  AI coding agents are untrusted, autonomous workloads that containers were never designed to isolate, so Docker Sandboxes runs each agent in a microVM (custom VMM on Hypervisor.framework, WHP or KVM) with its own kernel and private Docker Engine.
- [AI Agent Security Risks: What Can Go Wrong When Agents Act on Their Own](https://swe.quest/articles/ai-agent-security-risks-what-can-go-wrong-when-agents-act-on-their-own-82a7bec191494a72.md): Docker · 2026-10-14 · Easy · 7 min read · AI agents, Security, Sandboxing & isolation, Identity & auth
  AI agents introduce risks that traditional application security wasn't designed for, because they choose tools at runtime, chain actions and often run with the launching user's credentials.
- [Why AI Agents Need Isolation](https://swe.quest/articles/why-ai-agents-need-isolation-2e7b1a6342af3236.md): Docker · 2026-07-01 · Easy · 9 min read · Sandboxing & isolation, AI agents, Virtualization, Containers, AI for coding
  AI coding agents that run commands, install packages and handle credentials should execute behind an isolation boundary rather than directly on the developer's host.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
