Sandboxes
Isolated code execution for AI agents and tool-use loops.
Concepts
Term
What it is
How to use it from a step
from zenml import step
from zenml.client import Client
@step
def agent_step(prompt: str) -> str:
sandbox = Client().active_stack.sandbox
if sandbox is None:
raise RuntimeError("No sandbox configured in the active stack.")
with sandbox.create_session() as session:
process = session.exec(["python", "-c", "print(1 + 1)"])
output = "".join(process.stdout())
process.wait()
return outputStreaming output
Snapshots, restore, and attach
Closing vs destroying
Configuration
Per-step settings
Setting
Purpose
Sandbox logs
Security considerations
Available flavors
Develop a custom Sandbox
Last updated
Was this helpful?