π¦ Building AI Agents in Rust – part 9
Last Updated on July 20, 2026 by Editorial Team
Author(s): Enzo Lombardi
Originally published on Towards AI.
Sandboxed code execution
The eight previous parts gave Eugene careful, narrow capabilities: reading files inside a canonicalised sandbox, calling a handful of well-typed skills, talking to other agents, persisting memory, going through an open protocol. None of those let the agent run arbitrary code on the userβs machine. This post does.

After introducing why true code execution is the most dangerous yet most powerful step in building AI agents, the article explains how Eugene implements safe execution via layered sandboxing rather than fragile deny-lists. It contrasts earlier βpath sandboxingβ (restricting what files can be referenced) with βresource isolationβ (restricting what the subprocess can actually do), then details the core Rust design: a small Sandbox trait with execution limits (timeout and output caps) and structured results (success, truncation, timeout). It walks through LocalSandboxβs protectionsβworking-directory confinement, environment scrubbing, null stdin, capped stdout/stderr, and wall-clock timeoutsβthen argues that the denylist is only an early safety net while the sandbox remains the real boundary. The post further shows how this enables practical data-analysis loops (running commands like grep/awk/python against user-provided files) and discusses what LocalSandbox cannot cover (network isolation and stronger resource boundaries), motivating OS-level sandboxing, containers, and microVM approaches like E2B/Modal. Finally, it highlights that sandboxing and permissioning are orthogonal: a separate permission layer decides what the user wants the agent to do, while the sandbox decides what the subprocess is physically allowed to do.
Read the full blog for free on Medium.
Join thousands of data leaders on the AI newsletter. Join over 80,000 subscribers and keep up to date with the latest developments in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming aΒ sponsor.
Published via Towards AI
Towards AI Academy
We Build Enterprise-Grade AI. We'll Teach You to Master It Too.
15 engineers. 100,000+ students. Towards AI Academy teaches what actually survives production.
Start free β no commitment:
β 6-Day Agentic AI Engineering Email Guide β one practical lesson per day
β Agents Architecture Cheatsheet β 3 years of architecture decisions in 6 pages
Our courses:
β AI Engineering Certification β 90+ lessons from project selection to deployed product. The most comprehensive practical LLM course out there.
β Agent Engineering Course β Hands on with production agent architectures, memory, routing, and eval frameworks β built from real enterprise engagements.
β AI for Work β Understand, evaluate, and apply AI for complex work tasks.
Note: Article content contains the views of the contributing authors and not Towards AI.