If you build an AI agent that writes and runs Python scripts, where does that code actually run? Most teams start by spinning up a regular container worker in Kubernetes and piping generated scripts straight into a subshell.
That setup feels isolated, but it relies on a dangerous assumption. Standard containers share the host operating system kernel NIST container security guide . When an agent executes untrusted, model-generated code, a single prompt injection can turn a worker pod into a complete node takeover.
Here is why standard containers fall short, and how to build a reliable sandbox in Kubernetes across three practical layers.
The default container trap
Traditional microservices run deterministic code that engineers wrote, reviewed, and packaged into an image. In that setup, standard Linux namespaces and cgroups do a good job keeping workloads separated.
LLM agents invert that pattern. They run dynamic, unreviewed instructions generated on the fly.…