Skip to Content
View all events

Sandboxing an AI Agent

Published by O'Reilly Media, Inc.

Intermediate content levelIntermediate

Build an isolated execution layer for your AI agents

What you’ll learn and how you can apply it

  • Understand the sandbox end to end: Learn how the threat model, the isolation spectrum, fast starts, data flow in and out, and the seams fit together as one layer, and why the workload being untrusted shapes each design decision
  • Read and reason about isolation tiers: Go from process-level restriction to containers to userspace kernels to microVMs, knowing what each newly blocks, its escape surface, and its rough cost, so you can tell which boundary a given workload needs
  • Operate and choose sandbox infrastructure: Handle cold starts, snapshots, data flow, egress, secrets, audit, lifetimes, and cost, then compare representative managed providers against self-hosting the open-source stack

Course description

Your agent can run code, read files, fetch URLs, install dependencies, and use credentials. That makes the execution layer around the agent part of your security boundary. Sometimes the model writes the code; sometimes a poisoned repository, malicious package, or prompt injection influences what runs. Containment is the industry’s answer because a strong boundary is what makes autonomous agent modes safe to offer. Sajal Sharma opens up that boundary, shows how each isolation tier works, and teaches you to build, operate, and choose one.

You’ll start with the threat model and real incidents, each mapped to the isolation property that would have contained it. Then you’ll walk the isolation spectrum as four tiers: process-level restriction, the container and when Docker is enough, the userspace kernel, and the microVM. You’ll understand what each tier blocks, what it still exposes, what it costs, and how to decide which boundary a workload needs. Then you’ll learn how to make your sandbox production-ready: fast starts with templates, snapshots, and warm pools; code in and results out without importing credentials; and the seams where boundaries leak, including egress, secrets, identity, and audit. You’ll use two patterns to implement sandboxes: one as a tool backend and one that hosts the whole agent.

This live event is for you because...

  • You’re an AI/ML or platform engineer building or operating agents who wants to understand the execution layer beneath the provider SDKs you already call.
  • You’re a security engineer responsible for agent deployments, and you need to reason about isolation tiers to set policy and evaluate vendors.
  • You’re a technical builder choosing sandbox infrastructure and want enough depth to choose well, operate safely, and defend your choice.

Prerequisites

  • A Python environment—Python 3.12+ with pip/uv available to install packages
  • An Anthropic API key
  • A Modal or Daytona account and API key (free credits suffice for demos)
  • A code editor (VS Code recommended) and terminal access
  • Comfort with Python and the command line
  • A basic Linux mental model (processes, the filesystem, roughly what a syscall is)
  • Basic understanding of LLMs and AI agents (the agent loop, tools, and tool calls)
  • Familiarity with Docker (helpful but not required)
  • All code demonstrated in the hands-on sections will be available in a Github repo

Recommended follow-up:

Schedule

The time frames are only estimates and may vary according to how the class is progressing.

Why agents need a sandbox and how to choose the boundary (60 minutes)

  • Presentation: The agent sandbox threat model; workspace isolation versus execution isolation; where the boundary sits around code, tools, files, network, and credentials; the four isolation tiers from process restriction to microVMs; how to choose the right tier for a workload
  • Hands-on exercise: Build a minimal sandbox boundary around an agent
  • Q&A
  • Break

The shell, the files, and routing (60 minutes)

  • Presentation: The production sandbox as an operating layer—runtime and state (startup latency, templates, snapshots, warm pools); boundary plumbing (code in, results out, filesystem state); control plane concerns (egress, secrets, identity, audit, MCP placement); economics (lifecycle, cost, build-versus-buy, and the reusable decision rubric)
  • Hands-on exercises: Build two managed sandbox integrations—sandbox as tool backend, and sandbox hosting the agent loop
  • Q&A

Your Instructor

Sajal Sharma

Sajal Sharma is an AI engineer and technology leader with over eight years of experience in AI/ML, specializing in natural language processing. He works at Liminal, a venture studio in Singapore, where he focuses on building AI-first products and shaping technology strategies. Previously, he led AI initiatives at various consulting and product companies, developing innovative AI solutions across industries. His on-demand course, Building AI Agents with LangGraph, is available on the O’Reilly learning platform. Sajal has delivered a guest lecture at Yale University and has been a mentor for Udacity and the University of Melbourne, where he guided students in machine learning and AI. He holds a master’s degree in information technology from the University of Melbourne.

Skills covered

  • AI Agents
  • Security Engineering