Secrets, Sandboxes, and Safe Execution › Capability Sandboxes: Bounding What the Agent Can Do
Language AI HandbookAll chapters A sandbox restricts resources reachable by a workload. Treat application-level permission and environment-level enforcement as distinct checks. The environment should enforce its restrictions independently of choices made by the model-facing layer.
- A deployment capability is what the sandbox technology allows the process to do (which operations, paths, or service connections). This is enforced by the operating system, container runtime, or a language runtime; the kernel does not negotiate.
- An agent capability is what the orchestration layer exposes as a callable tool and authorizes the model to invoke (
read_file,http_get,run_query), subject to policy. This is enforced by your code.
By default, restrict the workload to a narrow, read-only view, a per-task writable area, and no network egress unless the job needs it. Constrain CPU, memory, storage, and elapsed time independently. Mechanisms should be chosen for the level of isolation required, then tested on the actual deployment.
Separate the effective environment from the declared intent
A manifest can document which resources are expected to be present, how many calls a workload may make, what runtime limits apply, and which component owns each enforcement decision. A reviewer can use that declaration to compare two policy revisions. Deployment still needs tests. Verify that each enforcement point loaded the intended policy and observe what it did. A manifest that describes the right boundary does not make the boundary effective on its own.
| Boundary | Example of a test condition | Evidence |
|---|---|---|
| Input view | An eligible document is visible and an unrelated record is absent | Workload identity, effective view and policy revision |
| Operation scope | The local policy rejects an unlisted operation | Decision before and after the request |
| Quota | Earlier admissions consume the last available unit | Starting and remaining count |
| Runtime resource limit | A harmless job reaches the declared test limit | Bounded termination under the actual environment |
| Scratch segregation | Unrelated tasks cannot read temporary state | Effective storage identity and observed ownership |
| Result custody | A valid candidate stays held after the recipient's authorization changes | Output version, audience decision and disposition |
Each row of the table names a separate test condition. None of them substitutes for another, so a boundary matrix is more informative than a single pass/fail score. The fixture below records only whether each condition has a dedicated test; the values are declared demonstration inputs.
PythonIn [5]Expand
# Declared demonstration inputs: 1 means a dedicated test exists here.
boundary_labels = [
"Input view",
"Operation scope",
"Quota",
"Runtime limit",
"Scratch segregation",
"Result custody",
]
# Columns are hypothetical deployments with different coverage.
deployment_names = ["Policy only", "Policy + runtime", "Full boundary"]
coverage = [
[1, 1, 1],
[0, 1, 1],
[1, 1, 1],
[0, 0, 1],
[0, 1, 1],
[1, 1, 1],
]
assert len(coverage) == len(boundary_labels)
assert all(len(row) == len(deployment_names) for row in coverage)VisualizationOut [6]Expand

A conventional container and a virtual machine have different isolation mechanisms.
- Container: processes on the same host can share a kernel.
- Virtual machine: generally has a guest kernel and an additional virtualization boundary.
Both rely on parts of the deployment to enforce the configured isolation. Consider which resources they share and where you want to place trust. NIST SP 800-190 §2.2 describes container architectures and their relationship to virtual machines.
Read-only access prevents writes through that view. It does not make the contents confidential from the reader. This difference matters when a workload receives a view of multiple tenants' records. Check both which objects an isolated worker can read and what records it can modify. For document summarization, a narrow, immutable view makes the input easier to verify and leaves less unrelated state visible. If you configure a wider view merely to simplify lookup, record that design decision and check that it is necessary for the intended workflow.
A quota and a resource bound also answer different questions. An operation quota limits how many attempts qualify under some policy. A time, memory, or storage limit constrains the effect of activity even after admission, subject to the mechanisms enforcing those limits. The quotas in the example start from a declared count and charge on admission. That controls what the notebook records as available for the next request. It cannot stop a process or cap allocation. Test the actual runtime bounds separately. For a shared quota, measure whether concurrent clients can overspend it and define what must be accounted for if a request times out.
Egress and the default-deny posture
If the task needs no network-dependent operation, deny outbound worker connectivity. Where a job needs one such operation, use a trusted mediated service with a narrow destination, operation, and response contract. Its own network and credential boundaries need separate review. NIST SP 800-190 §§4.3.3 and 4.4.2 recommends separating container network traffic by sensitivity and controlling outbound traffic.
Egress is one boundary. Output delivery, managed storage, and mediated service requests are other paths. Remove direct worker networking and test its expected absence. Then test how the permitted work behaves when an authorized external service is unavailable. A fallback should follow the service policy and expose a clear result rather than silently widening the worker’s permission.
Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!