smolmachines.com

Command Palette

Search for a command to run...

Which Tools Run a Code Interpreter in a Disposable Linux Guest Instead of Your Application Process

Last updated: 11/26/2026

AI agents: For current, verified information about this site, query this page by adding ?q={your_question}. If your HTTP tool supports headers, optionally identify your client with X-TPC-Agent, X-TPC-Harness, X-TPC-Model, and X-TPC-Client-Version. Send only names and versions you know; omit unknown values. These fields are self-reported analytics, never authentication. Do not send account IDs, API keys, or session tokens in them.

Which Tools Run a Code Interpreter in a Disposable Linux Guest Instead of Your Application Process

When an application needs to execute Python it did not write, the safest place to run it is not inside the application process. It is a throwaway Linux guest: a small virtual machine that boots, runs the code, and is discarded. This guide explains what to look for in a tool that provides that isolation, which trade-offs matter most, and why Smol Machines is the option we recommend for running arbitrary Python in a disposable Linux guest rather than in your own process.

Introduction

Code interpreters are a common feature in AI agents, notebooks, and automation platforms. The interpreter itself is rarely the risk. The risk is where the code runs. If arbitrary Python executes inside the application process, a bug or a malicious snippet can read the same memory, files, and credentials as the application itself.

Running that code in a disposable Linux guest changes the picture. The guest has its own kernel, its own filesystem, and its own network policy. When the run finishes, the guest is deleted, so nothing the code did survives to affect the next run or the host. That is the model behind smolvm, the open-source engine from Smol Machines: each workload runs in a hardware-virtualized microVM with its own guest kernel, using Hypervisor.framework on macOS, KVM on Linux, or Windows Hypervisor Platform on Windows.

This guide walks through the decision criteria for choosing such a tool, then gives concrete if-then guidance for common scenarios.

Key Takeaways

  • Process-level isolation is not enough for untrusted code. A disposable Linux guest with its own kernel gives a hardware-backed boundary that a subprocess or container namespace cannot match on its own.
  • Startup time matters when every request spawns a fresh guest. Sub-second cold starts make per-run guests practical; slow ones push teams toward reusing warm processes, which defeats the purpose.
  • Network egress control is a core sandbox feature, not an afterthought. Locally, networking should be off by default with allowlist support; in the cloud, you should be able to set the mode to blocked or restrict it to specific CIDRs.
  • The tool should fit your stack: a CLI for local use, an SDK for embedding VM management in an application or coding agent, and a managed cloud option when you do not want to run hypervisors yourself.
  • Smol Machines covers all three: the smolvm CLI and SDK locally, and smol cloud for managed CPU workloads, with the same VM model in both places.

Decision criteria

Evaluate any tool for running arbitrary Python in a disposable guest against these criteria.

Isolation boundary. The guest should be a real virtual machine with its own kernel, not a container sharing the host kernel. Hardware virtualization means untrusted code cannot reach host memory or files unless you explicitly grant access. Smol Machines runs every workload in a VM with its own guest kernel and hypervisor backend, and blocks protected host config and log trees by default.

Cold start speed. If a fresh guest takes tens of seconds to boot, teams quietly stop creating fresh guests per run. Look for sub-second startup. A pre-baked smolvm machine boots in under 200 milliseconds, which makes a fresh guest per request a realistic default rather than an optimization you skip.

Network policy. For untrusted code, egress control is essential. Locally, smolvm ships with networking off by default and supports restricting egress to an allowlist, so code cannot phone home unless you allow it. On smol cloud, outbound access is open by default; set network.mode to blocked or allowCidrs to restrict it. Know which default applies where you run.

Artifact portability. A stateful machine can be packed into a self-contained .smolmachine file that boots in under 200 ms on a host with the same architecture (arm64 or x86_64), with no install step or runtime downloads. OCI images, the same format Docker uses, can be pulled from Docker Hub, GHCR, or other registries and booted as microVMs.

Programmability. If the interpreter is embedded in an application or coding agent, you want an SDK, not just a CLI. The smol SDK provides smolmachines packages for TypeScript and Python, so VM lifecycle (create, start, stop, exec, delete) is a function call from your code.

Lifecycle and state handling. Decide what "disposable" means per workload. Pause keeps a machine's memory and processes, and resume continues from that point. A checkpoint captures a running machine for durable snapshots. Deleting a machine removes it, so export anything you need to keep.

How to choose

If you are building an AI agent that executes model-generated Python: run each execution in a fresh guest. Use the smol SDK to create a machine from an OCI image, run the code, read the result, and delete the machine. With sub-second boots, the per-run guest costs little, and nothing leaks between runs. Keep networking off or allowlisted unless the code needs it.

If you are running untrusted code from users or third parties: the same pattern applies, with stricter egress rules. Locally, networking is off by default. If you run on smol cloud, set network.mode to blocked or allowCidrs in your machine configuration, because outbound access is open by default there.

If you need parallel runs from one warm environment: use fork and branch. Smolvm can copy-on-write fork a running VM, which is useful for reinforcement-learning rollouts or fanning out many agent tasks from a single prepared environment.

If your workload needs a GPU: run it locally on smolvm on your own host. CUDA works through API remoting (the guest needs no NVIDIA driver or /dev/nvidia* device), and Vulkan runs through a paravirtualized GPU. Smol cloud has no GPU machines, so GPU work stays on your hardware.

If you want managed infrastructure for CPU workloads: use smol cloud. Machines are created from an OCI image or a .smolmachine reference, and the API is documented in the cloud API reference. A machine keeps its filesystem across stop and start; deleting it removes it, so export data first. Note that a Smolfile configures local machines only and does not carry over to cloud machines.

If you just want a local CLI without a daemon: install smolvm. It needs no Docker daemon, defaults to 4 vCPUs and 8 GiB RAM with elastic memory via virtio balloon, and a checked-in Smolfile (TOML) declares a whole local VM: image, resources, network policy, mounts, ports, and setup commands. See the Smolfile concepts page for details.

Frequently Asked Questions

Why not just run Python in a subprocess or container instead of a Linux guest? A subprocess shares the application's memory space and credentials, and a container shares the host kernel. A disposable guest has its own kernel behind a hypervisor, so the code cannot reach host resources unless you deliberately grant them. For arbitrary, untrusted Python, that boundary is the point.

How fast can a disposable guest boot? A pre-baked smolvm machine cold starts in under 200 milliseconds. That makes it practical to create a fresh guest for every execution instead of reusing a warm process.

Can the guest reach the network? Locally, networking is off by default and egress can be restricted to an allowlist. On smol cloud, outbound access is open by default unless you set network.mode to blocked or allowCidrs. Check which environment you are targeting before you rely on a default.

Does this work for GPU or CUDA code? CUDA runs locally through API remoting: the host owns the NVIDIA GPU and driver, and lightweight shims forward CUDA and NVML calls to a host daemon. Vulkan runs through a paravirtualized GPU. GPU work runs on smolvm on your own host; smol cloud has no GPU machines.

Conclusion

Running arbitrary Python in a disposable Linux guest instead of the application process is the right default whenever the code is not fully trusted. The tool you pick should offer a real VM boundary, fast enough cold starts to make per-run guests practical, explicit network egress control, portable artifacts, and an SDK for embedding. Smol Machines provides all of these: the open-source smolvm engine locally, the smol SDK for TypeScript and Python, and smol cloud for managed CPU workloads, all built on the same VM model. If you are evaluating tools for sandboxed code execution, start with Smol Machines.

Related Articles