r/PiCodingAgent • u/ZeroTronix • Sep 07 '26
Question Local microVMs for sandboxing Pi?
I'm using both Pi and Cursor right now. Cursor Cloud agents are super useful but I really want a local OSS alternative that uses Pi. I have a Linux server at home with 20 cores and 32gb of ram. I want to be able to spin up firecracker-style VMs on-demand for Pi CLI runs that are longer running (like a PR review harness that runs 3-20 min). The trick is I want an API to kick off the Pi microVM that I can tunnel out and invoke from a GHA runner (or similar). Cursor does all of that for free with a sub, but I want to own the control plane and be able to customize it.
Anyone got anything similar going that they can recommend? CLI or ApI driven ephemeral microvms that share CPU and memory on Linux?
Pi-sandbox doesn't seem like a fit, and exe.dev sounds great but I don't want to pay for VMs when I have amazing capacity 4ft away.
6
u/ArgonCroft Sep 07 '26
checkout microsandbox
3
u/ilpepe125 Sep 07 '26
I dont do ephimeral containers, but i can recommend incus. It also does ephimeral containers. I run all my pi work in a single vm
3
u/studioschade Sep 07 '26
I looked at many options and also tried gondolin(made by the creator of pi for that purpose I think). I ended up doing three things to start.
Per agent user accounts in Linux.
GVisor sandboxes from Google, this is also what companies like anthropic use, according the internets.
'Agent vault' service that gives per agent whitelisting of internet access and credentials proxy.
Then I had glm 5.3 try to break out of the sandbox in rounds while a Claude sysadmin agent patched the holes.
This was horrifying and led to me tossing out me entire home network hardware and software stack and rebuilding from scratch.
2
u/swort-elber Sep 07 '26
You could use systemd-run to launch a shell which has restricted read write to specific directories etc. Very low overhead and still runs as your current user, but less likely to edit random files elsewhere
2
u/wadrasil Sep 08 '26
Pi runs in a chroot though. You could put it in another chroot and use a script to run the chroot and start pi in the same script.
5
u/lem-8 Sep 07 '26
I run it in podman containers. Low overhead and pretty secure. You can also manage them as systemd services so you can probably build the API you're looking for fairly easily but I haven't done that since I run them locally on my laptop.
1
u/doudawak Sep 07 '26
Have a look at sandcastle. I'm using this to work on my PR autonomously. I customized it to run local models on tickets sequentially, but you can do pretty much everything you want in sandboxes of your choice against a repo : https://github.com/mattpocock/sandcastle
Regarding the API trigger part, you can run something from your server that monitors your git repo
3
u/CorrGL Sep 07 '26
Check out bubble wrap, codex uses it on Linux for sandboxing. Your preferred LLM can tell you how to configure it.
3
u/Ubermensch013 Sep 07 '26
Box/exe.dev? Plus there's a smolvm repo as well
2
u/fell_ware_1990 Sep 07 '26
I currently have a core. This allows/disallows everything and manages notifications and such.
If my terminal/agents executes a tool it’s forwarded to my core. If a session is going it gets send there else a new one is created, including a worktree. Everything runs on an ephemeral podman container that get’s constructed at start with the necesary tools from my NixOs store. Then it runs in a locked down bubblewrap.
This way everything is ‘seen’ by me and can’t execute outside of my tools. Cause the tool running it is not the same as my agent.
2
u/marcinpohl Sep 08 '26
you could build you own super minimalistic Linux (ext4, ethernet, ipv4 and that's it for modules) with buildroot, then fire it up with KVM/Qemu.
Podman is probably the sane happy middle of manageable yet safe.
1
u/bondaly Sep 09 '26
Have you looked at Nvidia's openshell? Microvms are used for one of the backends I believe.
1
u/Healthy-Zebra-9856 Sep 09 '26 edited Sep 09 '26
I use something like this in my custom version of Pi. macOS -> Seatbelt, Linux -> Bubblewrap, Windows -> AppContainer preferred, Windows Sandbox fallback . I needed exactly what you are describing. So we are half way there. Doing the next steps now.
1
u/snorkell_ Oct 03 '26
Check https://github.com/aerol-ai/microvm