Test environments and sandboxes
Where agents and tests run, from sandboxes, network limits, and sandbox escapes to test isolation and staging, and how prompt injection reaches agents.
Start here
What is a sandbox for AI agents?
A sandbox for AI agents is an isolated place to run an agent's commands, with limits on the files and hosts they can reach, so mistakes do less harm.
Concepts
What is test isolation (hermetic tests)?
Test isolation means each test sets up its own state and data, so its result does not depend on other tests, the order they run in, or leftover files.
What is a staging environment?
A staging environment is a copy of production used for final testing before release, running the same build with similar settings but no real users.
What is an ephemeral environment?
An ephemeral environment is a short-lived, full copy of an app made for one change or pull request and then deleted, e.g. a preview environment.
What is a microVM?
A microVM is a small virtual machine that boots quickly and runs one workload with its own kernel, giving stronger isolation than a container.
What is approval fatigue in coding agents?
Approval fatigue is the habit of approving an agent's permission prompts unread, because so many appear that the prompts stop protecting anything.
What is database branching?
Database branching makes a quick, isolated copy of a database for one pull request or agent task, so its writes and migrations never touch shared data.
What is egress control for agent sandboxes?
Egress control, or egress filtering, limits which outside hosts a sandboxed AI agent can reach, usually through an allowlist that a proxy enforces.
What is least privilege for AI agents?
Least privilege for AI agents means giving an agent only the access its current task needs, e.g. a scoped token, and nothing that outlives the task.
What is test data seeding?
Test data seeding is loading a known set of data into a fresh database or app before tests run, so every run starts from the same predictable state.
What leaves your machine when a coding tool runs?
An AI coding tool can send prompts, file contents, command output, and usage data to a model provider or its maker, depending on the tool and its settings.
How-to guides
How to keep secrets away from a coding agent
Keeping secrets away from a coding agent means the project's keys stay outside its sandbox, where a credential proxy adds them to requests that need them.
Comparisons
What is the difference between containers, gVisor, and microVMs?
Containers, gVisor, and microVMs isolate code at different depths, from a shared host kernel to a user-space kernel to a small virtual machine of its own.
What is the difference between Docker, dev containers, and VMs?
Docker, dev containers, and virtual machines put a coding agent behind different boundaries, and each exposes the files, network, and secrets it is given.
Common questions
Why should tests run on a clean checkout?
Testing on a clean checkout means starting from the committed code alone, so results cannot depend on uncommitted edits, untracked files, or build output.
Failures and bugs
What is prompt injection in coding agents?
Prompt injection in coding agents is hostile text in files, issues, web pages, or tool output that the agent reads as instructions and then acts on.
What is a sandbox escape?
A sandbox escape is a failure in which code inside an isolated environment breaks out and reaches the host or other systems it should not touch.
Terms in this topic
- Approval fatigue
- Approval fatigue is a failure in which people approve a coding agent's permission prompts without reading them, because the prompts are so frequent that they stop protecting anything.
- Container
- A container is a packaged process that runs with its own filesystem and limits but shares the host's kernel, which makes it lighter and less isolated than a virtual machine.
- Credential proxy
- A credential proxy is a service between an agent and an API that adds the real credential to each request, so the agent never holds the key itself.
- Data retention
- Data retention is how long a service keeps the data it receives, e.g. prompts and code sent to a model provider, before it deletes that data.
- Database branching
- Database branching is a way of giving each Git branch, pull request, or agent task its own quick copy of a database, so its writes and migrations cannot touch shared data.
- Dev container
- A dev container is a container defined in the repository that provides a ready-made development environment with its tools installed.
- Egress control
- Egress control is a network control that limits which outside hosts a sandbox or agent can reach, usually with an allowlist or a proxy.
- Ephemeral environment
- An ephemeral environment is a short-lived copy of an application that is created for one change or test run and destroyed afterwards. A preview environment is one kind.
- Hermetic test
- A hermetic test is a test that depends only on what it declares and sets up itself, with no shared state, network, or leftover files. It gives the same result anywhere.
- Indirect prompt injection
- Indirect prompt injection is a prompt injection that arrives through content an agent reads during a task, e.g. a web page, instead of from the user.
- Least privilege
- Least privilege is a security principle that gives a person, program, or agent only the access its task needs, for no longer than it needs it.
- Lethal trifecta
- The lethal trifecta is a risk pattern in which an agent has access to private data, reads untrusted content, and can send data out, which lets prompt injection leak data.
- MicroVM
- A microVM is a small virtual machine that starts quickly and gives each workload its own kernel, which isolates it more strongly than a container.
- Prompt injection
- Prompt injection is an attack that hides instructions in content an AI model reads, e.g. a web page, so the model follows them instead of its user.
- Sandbox
- A sandbox is an isolated environment that limits which files and network hosts the code inside it can reach, so a bad command can damage only what the sandbox allows.
- Sandbox escape
- A sandbox escape is a failure in which code inside an isolated environment breaks out of it and reaches the host or other systems the sandbox should keep it away from.
- Staging environment
- A staging environment is a production-like copy of an application that teams use for final testing before release, running the same build with similar settings but no real users.
- Test data management
- Test data management is the practice that creates, refreshes, and cleans up the data tests need, so each run starts from a known state without real personal data.
- Test isolation
- Test isolation is a property of a test that runs with its own state and data, so its result does not depend on other tests, their order, or leftover files.
- Test-order dependence
- Test-order dependence is a flaw that makes a test pass or fail depending on which tests ran before it, usually because they share state.