{"slug": "building-ai-agents-in-rust-part-9", "title": "Building AI Agents in Rust - part 9", "summary": "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.", "body_md": "Member-only story\n\n# 🦀 Building AI Agents in Rust - part 9\n\n## Sandboxed code execution\n\nThe 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.\n\nThe 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`\n\n, `awk`\n\n, 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.\n\nThe Claude Code source has the deepest sandboxing surface of any agent in the wild. Their `bashSecurity.ts`\n\nfile 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`\n\ndecides at runtime whether each command needs OS-level sandboxing on top of the pattern filter…", "url": "https://wpnews.pro/news/building-ai-agents-in-rust-part-9", "canonical_source": "https://pub.towardsai.net/building-ai-agents-in-rust-part-9-0fbbaeb1f97a?source=rss----98111c9905da---4", "published_at": "2026-07-19 06:01:26+00:00", "updated_at": "2026-07-19 06:26:49.065539+00:00", "lang": "en", "topics": ["ai-agents", "ai-safety", "ai-tools", "artificial-intelligence"], "entities": ["Eugene", "Claude Code"], "alternates": {"html": "https://wpnews.pro/news/building-ai-agents-in-rust-part-9", "markdown": "https://wpnews.pro/news/building-ai-agents-in-rust-part-9.md", "text": "https://wpnews.pro/news/building-ai-agents-in-rust-part-9.txt", "jsonld": "https://wpnews.pro/news/building-ai-agents-in-rust-part-9.jsonld"}}