EN
Lesson 4.3Pro - Part of Agentic School Pro

Sandboxes: Safe Code Execution with E2B, Daytona and Co.

Run agent-generated and untrusted code safely in isolated, disposable sandboxes instead of on your own machine

24 min•Automation and Agentic Systems•Available

What you learn

  • Why running AI-generated or untrusted code locally is genuinely risky
  • What a sandbox is and how E2B and Daytona provide disposable environments
  • The three situations where you must sandbox: user-submitted code, untrusted agent output, parallel experiments

Summary

An agent that can write code is also an agent that wants to run it, and the moment you let arbitrary code execute on your laptop or server, one bad line can delete files, leak secrets from your environment, or open a connection you did not intend. A sandbox solves this by giving the code a fresh, isolated, throwaway computer to run on. If the run goes wrong, you discard the sandbox and lose nothing. This lesson explains the risk honestly, defines what a sandbox is, introduces the main services, and gives you a clear rule for when to use one and when a local run is fine.

What you will learn

You will learn why executing AI-generated code on your own machine is a security and reliability hazard, what a sandbox actually provides (isolation, disposability, resource limits), how managed services like E2B and Daytona spin one up on demand for your agent, and the three concrete situations that always call for a sandbox. You will leave able to decide, per task, whether code can run locally or must be contained.

Prerequisites

Courses 1 to 3, especially the secrets and security material from Course 3. You should understand that your machine holds environment variables, SSH keys and logged-in sessions that any local process can read, because that is precisely what a sandbox protects. The API basics matter too, since you drive these services through their SDKs.

The problem

Agentic workflows generate code and then need to run it to see if it works, transform some data, or fulfil a request. The temptation is to just run it - and for code you wrote and reviewed, that is fine. But agent output is not always correct, and if any input came from a user or the open web, it is not always friendly either. A single rm command, an infinite loop that pins your CPU, a script that reads process.env and phones it home: these are not exotic, they are the default failure modes of running untrusted code with full access to your real system.

Unlocking your Pro lesson

Comments

Loading comments.

Post a comment
CommentsNext
Next step

Ready to put AI to work as a real workflow?

Start with the foundations course, keep your progress locally and sync everything to your free account whenever you like.