A well-isolated agent can still make an unauthorized refund. Imagine it reads a malicious file inside a sandbox, follows an instruction in that file and calls an allowed refund API for another tenant’s order. The sandbox may successfully protect the host. The refund is still wrong. If your agent executes code and can reach business systems, you need two independent boundaries: one around execution, and another around every action the agent proposes.
What a sandbox can contain—and what it cannot authorize
A sandbox answers questions about reachability. Which files can code read or change? Which network destinations can it contact? How much CPU and memory can it consume? How long can it run? Those controls matter. A compromised run should not be able to inspect host credentials, overwrite unrelated files or exhaust shared resources.
Authorization answers a different question: may this authenticated actor perform this operation on this resource, with these parameters, now? A network rule that allows requests to a refunds service cannot determine whether the caller may refund order 123, whether that order belongs to the caller’s tenant or whether the amount is valid. The service must decide using trusted identity and authoritative business state—not an assertion written by the model.
OWASP’s excessive-agency guidance separates excessive functionality, permissions and autonomy. Its advice to use least-privilege integrations and downstream authorization is useful because it keeps permission decisions out of the model’s reasoning loop. The malicious file in our example is also a plausible indirect prompt-injection route: OWASP describes external content such as files and websites as injection surfaces. You should reduce the chance that the agent follows such instructions, but you cannot make that your only line of defense.
The architecture should show both paths explicitly:
Untrusted input → agent → isolated code runner
Proposed business action → trusted adapter → actor/resource policy check
→ business API recheck → audit result
The first path limits damage from code execution. The second makes an unauthorized action fail even when the agent can produce a syntactically valid request. This distinction is worth keeping visible in design reviews: a sandbox pass is not an authorization pass.

Draw the execution boundary before choosing a sandbox
Start with every way an agent can touch the environment, not with a product labelled “sandbox.” LangChain’s sandbox evaluation guide calls out filesystem isolation, network limits, resource limits, controlled reuse and kernel-level isolation. Turn those into questions about your actual workflow.
For files, document each per-run mount, its access mode and who owns its contents. Default to read-only where a write is unnecessary; give generated output a separate writable area. A read-write workspace mount means code can damage anything in that mounted folder. For networking, list required destinations and consider whether methods or paths can be constrained as well as hosts. For resources, set CPU, memory and time limits appropriate to the job. Decide when an environment is destroyed or reused, and what state could survive between runs.
Check the underlying isolation rather than accepting “containerized” as a complete answer. Kubernetes documents seccomp, AppArmor and SELinux controls and warns that privileged containers override several constraints. Likewise, Node.js says node:vm is not a security mechanism for untrusted code. An illustrative JavaScript execution snippet is not a production isolation design.
There are two reasonable placement patterns. Running the agent inside a sandbox can fit a stateful workflow that needs close access to its execution environment. Keeping the agent outside and invoking a sandbox as a tool can keep agent state and some secrets outside the code runner, at the cost of another network boundary and its latency. Neither pattern decides business permissions. Choose based on the workload and the exposure you can actually constrain.
The routing detail is easy to miss. Prime Radiant’s external-sandbox prototypes keep the agent outside a sandbox reached through a localhost API. In their Claude Code integration, Bash commands are redirected, but native Read and Edit tools still operate on the host. A team that tests only Bash could conclude that all file access is isolated when it is not. These are experimental prototypes, not audited components for sensitive workloads; the general lesson is to trace every agent tool to its real execution location.
Do the same for network defaults. Prime Radiant’s prototypes default to no external network access, while LangSmith’s auth-proxy documentation says sandbox TCP egress is broadly reachable without access_control unless organization-level restricted egress applies. Those statements describe different systems. Verify the configuration you deploy, including direct egress and traffic through a proxy. Credential injection is not an egress policy.
Put business permissions where the action crosses the boundary
Give each integration an action-boundary contract. The trusted adapter should know the authenticated actor and tenant from the application session, the requested operation, constrained parameters and whether approval is required. The policy decision should use current, authoritative resource state. Do not accept an actor ID, tenant ID or approved: true supplied by the model as proof. Deny when the required context is missing.
Open Policy Agent’s agent-tool-calling guidance places enforcement in the harness, which sends proposed tool calls and parameters to a policy decision point before execution. That is the right location for a first check, but it is not the last one. The business API should recheck access at the point of change, including any rights or resource state that may have changed since the proposal was approved. A permitted tool name does not establish permission to modify a particular record.
Prefer a task-specific refund_order(order_id, amount) adapter over a general authenticated HTTP client when you can. The narrower surface makes it easier to constrain operations and inspect proposed arguments. If the product instead exposes an exec(code) interface that chains tools, policy must run on every underlying business-tool call, not just once when execution starts. Schmid’s Code Mode discussion describes that chaining pattern; it does not establish that every agent needs one general-purpose execution tool.
Treat proxies and mounts as separate controls. Prime Radiant describes a proxy that substitutes a host-held credential into an allowed request, but cautions that an allowed host could echo the credential back. Keeping a token out of sandbox files reduces one exposure; it does not limit what the token can do. Give the integration the narrowest credential available and authorize each request downstream. LangSmith documents an especially clear counterexample: a read-only S3 mount does not prevent direct S3 API writes when the role supplied to its AWS auth proxy permits them.
Use human approval for consequential actions, not every read or draft. Bind approval to the exact actor, resource, operation and parameters proposed. If the amount or target changes after approval, require a new decision. Approval fatigue makes blanket review a poor substitute for policy, and a human click must never turn an authorization denial into permission. For a fuller treatment of actor-, resource- and action-level rules, see our agent permissions guide.
Test isolation and authorization as separate failure suites
Test the boundaries directly with deliberately hostile inputs and actual execution. Do not count a model refusing a request as evidence that the runner or API would deny it. Model behavior can change; the controls should hold when the agent attempts the forbidden action.
The isolation suite should try to read host files, write outside permitted mounts, reach destinations through both direct networking and the proxy, contact metadata endpoints, and consume excessive CPU, memory or time. Exercise every tool route, including file tools that do not invoke the code runner. Record whether the attempt was denied, where the denial occurred and whether any side effect happened. A blocked shell command says nothing about an unrestricted host-side Edit tool.
The authorization suite should attempt a cross-tenant read or write, replay an action after rights are revoked, change parameters after approval and call an integration through any path that bypasses the trusted adapter. Add a prompt-injected file that asks for an unauthorized business action; verify that the downstream check rejects it even if the agent complies. Exercise allowed actions too, so a blanket integration failure cannot masquerade as a successful security test.
Keep the evidence useful without copying customer files, secrets or complete tool arguments into traces. Record the run and policy decision identifiers, the tool route, a minimal description of the operation, the denial reason and the API result. Our guide to debugging agents without customer data covers the related observability trade-off. The release question is not merely “did the agent behave?” It is “which boundary stopped a bad attempt, and can we demonstrate it again?”
A release gate for a code-executing business agent
Start with one workflow and make its permissions reviewable. Before granting a write-capable integration, require the following:
Execution inventory: List every tool and where it runs; document per-run mounts, read-only defaults, writable paths, network routes, resource limits, lifecycle, kernel controls and secret handling.
Action contract: For each business tool, specify the trusted actor and tenant source, permitted operation, authoritative resource check, parameter constraints, credential scope and fail-closed behavior.
Approval rule: Identify consequential actions, bind review to the exact proposal and reject changes or underlying authorization denials.
Two passing denial suites: Run isolation attacks against the real runner and authorization attacks against the real adapter and API, including a direct-integration bypass attempt.
Change trigger: Repeat the relevant tests when a tool route, credential, sandbox image, mount, proxy rule or business integration changes. Assign an owner to each boundary.
For an agent being added to an existing product, this inventory is also the useful starting point for AI agent development: it exposes where current tools, data access and authorization need to meet the new execution boundary. Do not expand from reads to writes until both suites show where an attempted mistake will stop.