Skip to content
Blogs

Containment Is the Control Plane for AI Agents

· 19 min read

When an agent can call tools, safety is defined by what the execution environment allows—not what the model says it will avoid. Staff engineers treat agents as potentially compromised workloads: short-lived cells, least-privilege tools, brokered secrets, tamper-evident traces, and kill switches tested like any other production control.

The trust boundary moved

A model that only drafts text is bounded by the application that displays its answer. An agent that can run code, browse the network, retrieve credentials, or mutate external state sits in a different threat model. Its output is no longer the final artifact; the output becomes an instruction to infrastructure. That moves the decisive security boundary from the prompt to the execution environment.

Public incident reconstructions in 2026 reinforced the lesson: capable agents chained tool use, shared infrastructure, and network reach in ways behavioral policy alone did not predict. Customer impact varies by deployment, but the engineering takeaway is stable—design as if the agent runtime can become adversarial without announcing itself in the chat transcript.

MVP teams shipping Expo clients with server-side tool routers should document the same boundary for mobile: on-device prompts are not the control plane when actions execute on Supabase edge functions or Cloudflare Workers with service credentials. Containment follows the credential and the syscall, not the UI copy users see before tapping approve.

Staff reviews should ask where the agent process runs, which identity it borrows, and what happens if that process ignores instructions for thirty consecutive turns. If the answer is only we fine-tuned refusals, the design is not production-ready for tool use.

Behavioral policy is not a security boundary

Instructions, classifiers, and model-side refusals reduce the probability that an unsafe action is proposed. They cannot prove that every future model state, tool response, prompt injection, or infrastructure flaw will preserve intended policy. Security architecture must assume behavioral controls can fail and make the resulting action survivable.

This mirrors mature systems that separate application validation from database authorization. Validation improves normal behavior; authorization limits consequences. For agents, equivalents are capability-scoped tools, isolated filesystems, deny-by-default networking, short-lived credentials, and an external policy engine the model cannot rewrite.

| Layer | What it optimizes | What it cannot guarantee | | --- | --- | --- | | Prompt / system message | Tone, scope, refusals | Tool-output injection immunity | | Model classifier | Obvious abuse blocks | Novel multi-step exfil paths | | Tool schema | Typed inputs | Authorization at the downstream API | | Containment harness | Blast radius | Model creativity |

Put authorization outside model-controlled files. Issue capabilities for one task, one resource set, and one short time window. Separate read paths from write paths so discovery cannot silently become mutation. Make irreversible operations idempotent, reviewable, and independently auditable.

Red-team exercises should include multi-hop plans: read a document, call a tool, exfiltrate via a side channel encoded in tool arguments. Behavioral refusals may catch naive attempts; only containment proves the exfil path is unreachable from the cell you actually deploy Friday night.

Build a disposable execution cell

Each run should begin in a fresh sandbox or virtual machine with an explicit filesystem view. Mount only inputs required for the task; keep host sockets, cloud metadata endpoints, developer home directories, and unrelated repositories unreachable. Destroy the cell after completion and preserve only approved outputs plus tamper-evident telemetry.

Network access deserves the same rigor. A broad internet connection turns every parser, package manager, browser, and tool adapter into an egress path. Resolve destinations through an allowlisting proxy, block raw IP access, bind DNS decisions to the request, cap response size, and record destination plus purpose. When a task genuinely needs open research, run it in a separate read-only tier without production credentials.

```yaml cell: id: task-7f3a ttl_minutes: 45 filesystem: ephemeral mounts: - path: /workspace/input mode: ro network: default: deny allowlist: - api.github.com:443 destroy_on: success | failure | ttl ```

Cells that survive across user sessions accumulate state attackers can probe. Treat reuse as a privileged exception with explicit justification in the runbook, not the default for convenience during demos.

Instrument cell creation and destruction as first-class metrics. Spikes in long-lived cells often precede incidents where someone disabled TTL to debug a flaky tool. Alert when median cell lifetime exceeds the documented standard by more than one standard deviation during business hours.

Broker credentials at the last responsible moment

Long-lived secrets inside an agent process defeat least privilege. The agent should request a narrowly described operation from a credential broker; the broker authorizes the task identity, injects or uses a short-lived token, and returns a structured result. The model never needs the reusable secret.

Tool contracts should be smaller than the underlying API. A support agent may need read_order and propose_refund, not an unrestricted HTTP client holding a commerce administrator token. Typed inputs, server-side authorization, spending limits, idempotency keys, and postcondition checks convert a vague tool call into a governable capability.

Brokers should log grant decisions with correlation identifiers that join user intent, policy version, and executed side effect—without storing raw secrets in the trace. When brokers fail closed, product teams notice quickly; when they fail open to unblock demos, incidents follow in production.

Rotate broker signing keys on the same schedule as API gateway credentials. Agents that cache broker responses in local filesystems inside cells turn those caches into theft targets—write broker results to ephemeral memory where possible and never echo refresh tokens into model-visible tool output.

Human approval is scarce—not a perimeter

Approval prompts help for high-impact decisions but weaken when used as a substitute for containment. Repeated confirmation trains operators to clear queues rather than evaluate risk. Ask for approval only when human judgment can change the decision: show proposed side effects, affected resources, evidence, and rollback path.

Everything else should be enforced mechanically—capability lists, spending limits, destination allowlists, and automatic denials when policy versions mismatch. Shrinking routine prompts by narrowing tools is healthier than adding louder warning text users learn to ignore.

Mobile clients amplify the problem: small screens and interrupt-driven workflows make tap-through approval likely. Prefer server-side enforcement for agent actions triggered from React Native surfaces, and treat on-device approve buttons as audit signals, not authorization.

Operate containment as a production system

Containment is not complete when a sandbox starts. Teams need traces joining user intent, model and prompt versions, retrieved evidence, capability grants, tool inputs, network destinations, outputs, and policy decisions. Alert on capability expansion, unusual destination fan-out, repeated denials, credential requests, and divergence between proposed plan and executed actions.

Rehearse the failure path. A kill switch must revoke credentials, stop active cells, quarantine outputs, and prevent queued work from restarting the incident. Preserve enough evidence for reconstruction without logging secrets or private content indiscriminately. The release gate should test the exact production harness—a safe model inside a permissive environment is still an unsafe system.

Measure blast radius and recovery time, not only refusal rate. Game days should include prompt injection and tool-output injection against real policy enforcement, with success defined as contained impact rather than eloquent apologies in the chat UI.

Publish containment SLOs beside availability SLOs: maximum concurrent cells, maximum destinations per task, and maximum credential lifetime. When product asks to relax a limit for a launch, treat it like raising rate limits without a capacity review—possible for operators, but explicit and time-bound.

Threat-model harness, tools, and environment separately

Checklists that ask whether the model is aligned miss whether the harness exposes admin tokens to a browser tool or whether a filesystem mount includes SSH keys. Decompose reviews into model abuse cases, tool misuse cases, and infrastructure escape cases—with owners for each layer.

Prompt injection via retrieved documents is a tool-layer problem once RAG feeds the agent. Containment limits what a successful injection can touch even when the model complies with attacker instructions. Pair retrieval hygiene—source allowlists, content sanitization—with egress controls so exfiltration requires crossing multiple gates.

Third-party plugins and MCP servers inherit the agent identity unless you broker per-plugin credentials. Treat each connector as a supply-chain dependency with version pinning, integrity checks, and network policy distinct from the core agent cell.

Document which connectors may run in production cells versus research-only tiers. Sales demos love enabling every integration; engineering owns the graph of which plugin combinations share a credential namespace. Unexpected composition is how read-only research tools become write-capable through chained calls.

Operational checklist for agent containment

Document default cell TTL, network posture, and broker policies beside your agent feature flag config. Pull requests that add tools must include authorization tests and containment drill notes, or fail CI.

Promote a new capability only after rollback and kill-switch exercises pass on staging hardware matching production isolation—not only after a green eval on golden prompts. Link observability dashboards for denial rate, credential grants, and destination fan-out to the same on-call rotation that owns API availability.

Pair containment design with logging minimization for LLM traces: metadata-rich, transcript-poor telemetry keeps incident reconstruction possible without turning logs into a second datastore of user secrets. Review sibling guidance on redaction tiers before widening debug capture for agent failures.

Finally, align product copy with reality: if users can approve actions, say what mechanical limits still apply after approval. Trust increases when constraints are visible, not when marketing implies the model is merely well instructed.

Schedule a joint review with legal and support before launch: support macros should not instruct agents to disable sandboxes for VIP customers. Escalation paths that bypass containment for revenue reasons become permanent holes within one quarter.

Frequently asked questions

Is a strong system prompt enough to secure agents?
No. Prompts influence behavior; they do not enforce authorization at the API or network layer. Production safety requires external policy, least-privilege tools, isolated execution, and credentials the model cannot extract or replay. Treat prompt injection and tool-output injection as expected inputs to the harness, not rare accidents. Your release gate should fail when a new tool ships without server-side authorization tests, even if eval prompts look polite in staging.
Can we rely on user approval instead of sandboxes?
Approval complements containment but does not replace it. Operators approve routine actions under pressure, especially on mobile clients where interrupt-driven taps become muscle memory. Use approvals for exceptional, high-impact operations while sandboxes, brokers, and destination allowlists enforce defaults for everything else. Measure approval-to-deny ratios; if almost every prompt is accepted, your capability surface is too wide for humans to meaningfully review.
What must a kill switch do in practice?
Revoke active credentials, terminate running cells, quarantine partial outputs, and stop queued retries from reopening the blast radius. Test it on the production harness quarterly, measure time-to-safe-state, and ensure traces remain sufficient for postmortems without dumping raw user content into logs. The switch should be operable without redeploying the model—policy and infrastructure move faster than weight downloads when incidents start.
How does containment help with RAG prompt injection?
Injection may still manipulate model intent, but egress controls, write-capability limits, and brokered tokens cap what exfiltration or mutation paths remain. Combine retrieval allowlists and content sanitization with cells that cannot reach internal admin networks even when the model follows malicious instructions. Containment turns a successful injection into a contained failure mode with observable telemetry instead of silent lateral movement across your stack.

Sources

Related service

Ship AI features to production: tooling, retrieval, evaluation, safety boundaries, and operable backends.

View hire details


Published on August 27, 2026 by Berktug Berke Ates.