
Note: pricing and features may have changed since publication. Check each provider’s documentation for current details.
Where an AI agent should run depends on what the agent does.
Many teams need both: a sandbox for running code, and a production-like environment for testing agents against real services before they go live.
Feature | Sandbox | Production-like environment | Production |
| Main purpose | Run untrusted code | Test agents against real services | Serve real users |
| Isolation | Often a microVM per session | Separate copy of the app and services | Shared with the live app |
| Data | Empty unless you add it | Test data or a copy | Live data |
| Cost of a mistake | A discarded sandbox | A discarded test environment | Real users and data affected |
| Typical agents | Code interpreters, coding agents | Agents being built or changed | Approved agents with limited access |
The OWASP Top 10 for LLM Applications 2026 names two risks that matter most for agents. Prompt injection (LLM01) means instructions hidden in content the agent reads, such as an email, a support ticket, or a web page, can change what the agent does. Excessive agency (LLM03) means an agent has more functions, permissions, or autonomy than its task requires, so a mistaken or manipulated output turns into a damaging action.
In practice, the two combine into four kinds of failure:
Typical cases include code interpreters, analysis of files that users upload, coding agents that install packages and run tests, and browser automation on unknown sites. In each case, the code itself is the risk, so the agent needs a boundary that holds even if the code is malicious.
Dedicated sandbox providers give each session its own microVM:
The trade-off is that a sandbox starts without the application's data. The agent can only work with what it is given, which is the point for untrusted code, but a limit for agents whose job is to work with application data.
Upsun Cloud does not offer a microVM sandbox. Its task containers use the same container isolation as applications, and we suggest running untrusted code inside bubblewrap within the task. For VM-level isolation, a task can call a sandbox provider.
A sandbox shows whether an agent's code runs. It does not show how the agent behaves against the real database schema, the real services, and realistic data. A production-like environment does, because it runs the same application and services as production without touching live users.
Use one whenever something about the agent changes:
To keep the test environment safe:
OWASP's guidance on excessive agency comes down to one idea: do not rely on the model to behave. Put the limits in the systems around it.
On Upsun Cloud, an agent runs as a task container, is tested in a branch environment, and reaches production with a Git merge, using the same configuration in both places.
A task container is declared under tasks: in .upsun/config.yaml. Its relationships list the only services it can reach and run.timeout stops runs that go on too long.
tasks:
ticket-triage:
type: "python:3.14"
hooks:
build: "pip install -r requirements.txt"
relationships:
database: {}
run:
command: "python agent/triage.py"
timeout: 1800
services:
database:
type: "postgresql:18"Each run is recorded as an activity with an ID, a status, and logs. Write the agent as a single idempotent script, so a run can be started again safely if it fails or a deploy stops it.
Each active branch environment runs the apps, services, and tasks defined in that branch’s .upsun/config.yaml, in its own containers, separate from production.
Set the production key on the production environment only, and mark it as non-inheritable so branch environments never receive it. Give each test environment its own key.
# Production key: stays on production, not passed to branch environments
upsun variable:create --level environment -e <production-environment> --name env:MODEL_API_KEY --value "<production key>" --sensitive true --visible-build false --inheritable false
# Test key: set on each environment where the agent runs tests
upsun variable:create --level environment -e <test-environment> --name env:MODEL_API_KEY --value "<test key>" --sensitive true --visible-build falseFor every option, see Set variables.
Tasks cannot pause while they wait for a person. The agent saves its proposed action to a database and exits. When someone approves it, the app starts a follow-up task that carries out the action.
Merging redeploys production, which stops any task already running there, so the agent should save progress and exit cleanly when it receives SIGTERM.
Is a staging environment the same as a sandbox?
No. A sandbox isolates untrusted code from everything, including the application. A staging or preview environment is a separate copy of the application and its services, used to test changes before they reach production. An agent can need both.
Should coding agents run in a sandbox?
The code they write and the tests they run should, because that code has not been reviewed. Their changes should reach production only through review. Upsun Dispatch, a separate Upsun product for coding agents, opens a pull request for each change, and a person owns the merge.
Can Upsun Cloud run untrusted code?
Upsun Cloud task containers use container isolation: namespaces, dropped capabilities, seccomp, cgroups, and network isolation. The Upsun docs recommend running untrusted code inside bubblewrap within the task. For VM-level isolation per run, use a dedicated sandbox provider.
Does an Upsun Cloud branch environment contain production data?
A new environment can clone its parent's data, including databases and files, when it is created, and the push option environment.clone_parent_on_create=False turns this off. Teams that copy production data define their own sanitization script in a deploy hook.