Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Read by thought-leaders and decision-makers around the world. Phone Number: +1-650-246-9381 Email: pub@towardsai.net
228 Park Avenue South New York, NY 10003 United States
Website: Publisher: https://towardsai.net/#publisher Diversity Policy: https://towardsai.net/about Ethics Policy: https://towardsai.net/about Masthead: https://towardsai.net/about
Name: Towards AI Legal Name: Towards AI, Inc. Description: Towards AI is the world's leading artificial intelligence (AI) and technology publication. Founders: Roberto Iriondo, , Job Title: Co-founder and Advisor Works for: Towards AI, Inc. Follow Roberto: X, LinkedIn, GitHub, Google Scholar, Towards AI Profile, Medium, ML@CMU, FreeCodeCamp, Crunchbase, Bloomberg, Roberto Iriondo, Generative AI Lab, Generative AI Lab VeloxTrend Ultrarix Capital Partners Denis Piffaretti, Job Title: Co-founder Works for: Towards AI, Inc. Louie Peters, Job Title: Co-founder Works for: Towards AI, Inc. Louis-FranΓ§ois Bouchard, Job Title: Co-founder Works for: Towards AI, Inc. Cover:
Towards AI Cover
Logo:
Towards AI Logo
Areas Served: Worldwide Alternate Name: Towards AI, Inc. Alternate Name: Towards AI Co. Alternate Name: towards ai Alternate Name: towardsai Alternate Name: towards.ai Alternate Name: tai Alternate Name: toward ai Alternate Name: toward.ai Alternate Name: Towards AI, Inc. Alternate Name: towardsai.net Alternate Name: pub.towardsai.net
5 stars – based on 497 reviews

Frequently Used, Contextual References

TODO: Remember to copy unique IDs whenever it needs used. i.e., URL: 304b2e42315e

Resources

Free: 6-day Agentic AI Engineering Email Guide.
Learnings from Towards AI's hands-on work with real clients.
πŸ¦€ Building AI Agents in Rust – part 9
Latest   Machine Learning

πŸ¦€ 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.

πŸ¦€ Building AI Agents in Rust – part 9

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.