Resources / AI agents

Sandboxing AI agents: limit what an agent can touch

How to sandbox AI agents: isolate their code, restrict network and file access, scope their tools and credentials, and keep a human in the loop for risky actions.

An AI agent is a model in a loop: it reads, decides, calls tools, and reads the results. Every tool it can call is something it can do — on purpose, by mistake, or because a web page it read told it to. Sandboxing an agent means shrinking that "anything" to "exactly what this job needs".

1. Isolate where its code runs

If the agent can execute code, that code runs in a disposable sandbox — never on a developer laptop with real credentials, never on a production server. See sandboxing for AI code for the options.

2. Restrict the file system

Mount only the directory the task needs, read-only where possible. No home directory, no SSH keys, no cloud credentials files.

3. Restrict the network

Deny outbound traffic by default and allow-list the hosts the task requires. This is the single best defence against data exfiltration through prompt injection.

4. Scope the tools

Give agents narrow tools instead of broad ones:

Narrow tools are easier for the model to use correctly, too — see designing MCP tools.

5. Scope the credentials

Each tool uses a credential that can do only what that tool does: a read-only database user, an API key limited to one resource, a short-lived token. The agent never holds the credential itself.

6. Put limits on everything

Rate limits and daily quotas on each tool, a maximum number of steps per task, and a budget for model and API spend. Runaway loops then stop on their own.

7. Keep a human in the loop for irreversible actions

Payments, deletions, emails to customers, production deploys: require confirmation, or route them through a review queue.

8. Log every step

Record each tool call with its inputs, outputs and the model's stated reason. When something goes wrong you can see exactly what happened.

Building agent tools on Wisp

Each Wisp project is an MCP server whose tools are your endpoints — each one narrow, isolated per project, behind API keys and per-client rate limits, with every call logged. Secrets stay in Wisp, never in the agent, and the tools scale automatically when an agent fans out hundreds of calls.

Build it with Wisp — describe an API, get it live.

Related