cd /news/ai-agents/building-ai-agents-in-rust-part-9 · home topics ai-agents article
[ARTICLE · art-65075] src=pub.towardsai.net ↗ pub= topic=ai-agents verified=true sentiment=· neutral

Building AI Agents in Rust - part 9

Eugene, an AI agent built in Rust, gains the ability to execute arbitrary code on a user's machine in part 9 of a series, introducing sandboxed code execution. The post details the dangers and power of letting a language model run shell or Python commands, referencing Claude Code's extensive sandboxing techniques as a benchmark.

read1 min views2 publishedJul 19, 2026
Building AI Agents in Rust - part 9
Image: Pub (auto-discovered)

Member-only story

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.

The reason it took eight parts to get here is the reason this post is the longest in the series. Letting a language model produce shell or Python and then run it on your laptop is the single most dangerous thing an agent can do. It is also the most powerful: a data-analyst agent that can write grep

, awk

, or a Python one-liner against your data is qualitatively different from one that has to navigate a fixed menu of tools. The whole craft of code-execution skills is keeping the second property while neutralising the first.

The Claude Code source has the deepest sandboxing surface of any agent in the wild. Their bashSecurity.ts

file is 1,500 lines of pattern detection and tree-sitter AST analysis, scanning every bash command for command-substitution, process-substitution, Zsh expansion tricks, PowerShell comment syntax, and binary-hijack environment variables. Their shouldUseSandbox.ts

decides at runtime whether each command needs OS-level sandboxing on top of the pattern filter…

── more in #ai-agents 4 stories · sorted by recency
── more on @eugene 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/building-ai-agents-i…] indexed:0 read:1min 2026-07-19 ·