r/PiCodingAgent • • Oct 28 '26

Question How do y'all sandbox Pi?

I use a minimal Pi setup for building hobby projects and some light data analysis for work. I initially used NVIDIA's OpenShell in its early days before v0.1.0 but switched to Docker sandboxes since I find them quicker to manage for my use cases. However I've had some issues with installing and accessing Pi extensions with them.

What's your experience with sandboxing tools? Any recommendations for creating secure, reproducible environments? Thanks!

62 Upvotes

102 comments sorted by

7

u/pilibitti Oct 28 '26

which os?

1

u/cade-v Oct 29 '26

Currently using mainly macOS, but I'm also looking for sandbox options on Fedora 44 since sbx doesn't currently work on that

6

u/pilibitti Oct 29 '26

if you are on mac you're in luck. agent-safehouse is pretty amazing.

2

u/cade-v 29d ago

I've never heard of this one, I'll definitely check it out!

2

u/pilibitti 29d ago

please do! no messing with VMs, just a simple command and OS / kernel enforced boundaries. pretty comfortable.

5

u/transhighpriestess Oct 29 '26

Apple has released their own native container app. You can basically make a dockerfile then shell into it and run pi etc. I made a little helper script that copies in whatever secrets etc I need from the host system on launch.

4

u/wooptoo Oct 28 '26

I wrote a basic tutorial a while ago - Sandboxing Pi: Bubblewrap vs Podman https://wooptoo.com/blog/pi-sandbox-bubblewrap-podman/

It's more Linux centric to be honest, I've heard that MacOS folks use different tools: https://www.reddit.com/r/PiCodingAgent/s/bwhP8lih2F

2

u/cade-v Oct 29 '26

Thanks, I'll have to check these out!

25

u/fakeclown Oct 28 '26

I am using Docker Sandboxes. What's the issue with accessing Pi extensions? I use them fine. Probably you just need to add npm and github to the sandbox's network allowlist.

8

u/_RemyLeBeau_ Oct 29 '26

This is the best approach. MicroVMs behind and built in proxy that does header/body/URL rewriting is the best. The VM doesn't even have access to the secrets because those are stored in your Host's credential manager and injected on the fly per request.

3

u/brotlos_gluecklich 29d ago

Do you know a good writeup for this setup? I also think this the most promising/secure approach, but I'm struggling with getting started

2

u/ryanscio 29d ago

sbx does this out of the box. What part are you struggling with?

1

u/ECrispy Oct 29 '26

how do you set all this up? how does the model in a sandbox control your browser/tools if needed?

1

u/_RemyLeBeau_ Oct 29 '26

Those tools run where your harness is installed. Everything will run in the harness. How you connect to an LLM is your choice.

2

u/SalaciousVandal 29d ago

I avoided sandboxes after running in circles with env and podman. Then started using sbx due to the Cloudflare security audit skill. Now my agents live happily in vms, albeit briefly. Basically transparent.

33

u/wildjokers Oct 29 '26

I don't. YOLO.

9

u/DimmedSharpness 29d ago

https://nono.sh/ I've been using this for a bit, but I'm still on the lookout for a better alternative

1

u/aitvann 25d ago

I am looking to try nono.sh my self. Could you describe your experience and why are you looking for alternatives?

EDIT: typo

1

u/DimmedSharpness 25d ago

It works pretty well and I feel like it strikes a good balance between being locked down and still being able to interact with the parts of my system that I need it to be able to.

However, maintaining it as my setup evolves requires very frequent adjustments, which is why I am open to trying something else if it means less complexity if it can satisfy the other requirements I have as well.

16

u/frolgath Oct 29 '26

Don’t fuck around with sandboxes, permission extensions, etc. Whitelists are always too narrow and so will annoy you or too broad and so will be unsafe. Just run it in a VM. Virt-Manager is free, easy to setup and has great performance. Inside the VM you can give it root access and let it install whatever tools it wants. Never copy any credentials or data you wouldn’t want made public into the VM. Always check the results you copy out of the VM. Worst that can happen if it goes rogue or gets prompt injected is that you need to recreate the VM. Recreate it every session if you want to be sure.

6

u/Imatros Oct 29 '26

I mean technically worst case is it escaping the vm or downloading something that does, but at that point your at a level of sophistication that nothing else in this thread Is going to help anyway lol

4

u/InnerToe9570 Oct 29 '26

docker sandboxes (sbx). That way secrets can be kept out of reach for the agent.

6

u/jonas-reddit Oct 29 '26

Docker sandbox (sbx) using a custom container with pi and my dev tools, compilers, etc.

https://docs.docker.com/ai/sandboxes/agents/

With lots of examples on how to make it support pi below.

https://github.com/docker/sandbox-kit-spec/tree/main/examples

13

u/ECrispy Oct 29 '26

this is funny, because the original intention and talks by Mario all focused on yolo mode and how guardrails aren't needed.

16

u/pragmojo 29d ago

What I understood his intention to be is that sandboxing should be the OS/environment's job, not the agent harness

-4

u/ECrispy 29d ago

a harness is quite a bit more powerful than a normal process. the fact that there are so many extensions for permissions proves it should be built in

1

u/pragmojo 29d ago

I mean pi is built on the premise you can build exactly the permissions control you need.

2

u/ECrispy 29d ago

well Pi started as a nothing included, bare bones harness, its now grown into something much bigger, and mark my words, more and more stuff is going to be included.

the whole 'ask pi to build it' is also contradictory with having a million extensions in the official catalog. its the n+1 problem repeated for every single thing.

2

u/ArtofRemo 29d ago

indeed! as an example, why would we have a need for 100's of sub-agent extensions when a single official one could set the standard ?

3

u/jtackman 29d ago

because then you are responsible for it and its maintenance

1

u/ArtofRemo 25d ago

manage it together with the community ? it's about having a solid base to work from. Now everybody is doing their own thing which makes collaboration more difficult.

8

u/EC36339 Oct 29 '26

Pi's official documentation recommends running it in a sandbox

1

u/ECrispy 29d ago

I know. Like I said it's funny because the creator said one of the reasons was other harnesses had too much baggage and Pi was supposed to be Yolo, no restrictions, user beware, only for the experienced devs. Now it's just as complicated

1

u/roland303 29d ago

I think its just a legal issue, and cmon man before "pi" mario was going to call it "shit" coding agent... alots gotta change when you clean up and shave to go corporate, and i cant imagine any lawyer being happy with compamy saying yeah leave your shit unsanboxxed were hardcore! 

3

u/one-man-circlejerk Oct 29 '26

I just let it raw dog my machine

3

u/Opening_External_625 Oct 29 '26

sbx with a basic kit

2

u/ptgamr Oct 29 '26

https://ptgamr.substack.com/p/a-pi-setup-with-permission-sandbox?r=1njvx6&utm_campaign=post-expanded-share&utm_medium=post%20viewer

I do it with a combination of 3 extensions:

- `@gotgenes/pi-permission-system
- `@erichll/pi-auto-review`
- `@erichll/pi-sandbox`

pi-permission system define the list of locations it can access

pi-sandbox run every cmd in a sandbox, with ability to allow certain prefixes cmd to run outside of the sandbox

pi-auto-review for getting another agent to review the toolcall

2

u/xRebellion_ Oct 29 '26

I built a custom sandbox on top of https://github.com/earendil-works/gondolin . That and also a custom permission gate system as a second layer.

2

u/betiz0 Oct 29 '26

Podman

2

u/Bomb-OG-Kush Oct 29 '26

I just let it ride

2

u/funk443 Oct 29 '26

separate user

1

u/lazyfai Oct 29 '26

And no sudo right

2

u/davblaster Oct 29 '26

I wrote it up here: https://doctrine.engineering/articles/more-convenient-straitjackets/

My pi-for-other-orchestrators runner here is built around the same ideas: https://github.com/davidlee/quotient

1

u/davblaster Oct 29 '26

oh, and when I want to leave them unattended, microVMs + just enough network to sob quietly to the model provider:
https://github.com/davidlee/oubliette/

1

u/brotlos_gluecklich 29d ago

   " LiteLLM is a great way to keep credentials beyond reach of models" (from your blog post]

If only LiteLLM itself would be more trustworthy...

They have quite a track record of incidents (1), with compromised version containing info stealers in March (2) and again just a few days ago this October.

(1) https://app.opencve.io/cve/?vendor=litellm

(2) https://www.sonatype.com/blog/compromised-litellm-pypi-package-delivers-multi-stage-credential-stealer

(3) https://www.mend.io/blog/litellm-1-107-0-compromised/

1

u/davblaster 29d ago

yeah fair, I should probably add a footnote about that. I wouldn't use hosted, but it's been pretty decent as a base to hack on top of.

EDIT: shit, that pypi story is not happy. Happily mine's a nixpkgs install.

1

u/jtackman 29d ago

try bifrost

4

u/HectaMan Oct 28 '26

I work at Cosmonic, and we are currently rolling this out now - it will be in the next release of Cosmonic Desktop and supported on Kubernetes with Cosmonic Control. Desktop is free; it's like Docker but for fine-grained Wasm sandboxes.

Underneath the hood, we build CNCF wasmCloud, where we support the common policy enforcement points (file, network, config, secrets, etc).

The why here is that we give you the ability to:

  1. Run each agent, tool, and app inside an isolated sandbox - isolated in process, via resources, and isolated over time (resuse).
  2. All sandboxes are deny-by-default, for all policy enforcement points.
  3. Support least-privilege capability grants
  4. Extensive policy enforcement points - network, file, config, secrets, "system call"

What you would sandbox: defined agentic loops, apps, cron, triggers, etc
What's not a good fit: general wide-ranging coding agents

There are some amazing advantages to this architecture, chiefly density and security.

Excuse the marketecture, but that's what I am working on atm for a blogpost. Will be linking resources here shortly.

1

u/AmazinglyNatural6545 Oct 29 '26

But I can run any vm listed above and it's basically the same, so what's the point or benefit?

3

u/HectaMan Oct 29 '26

Well, the first benefit is that you can run each isolated sandbox confidently; even when there are exploits, like Remote Code Execution, there is nothing to execute in the box. You can give your agent a fixed set of capabilities to limit exactly what it is allowed to do.

Our primary users are people like banks and other security-conscious orgs; they want to adopt AI, but need to do so securely.

The second benefit is scale - these tiny sandboxes are often measured in Kilobytes; a scale test we did this week let us run over 175,000 of them in 2 GB of memory. Those were tiny, but the properties are scalable.

Third - these are low maintenance. When your application only includes your business logic, you do not need to waste the time / money patching, securing, or defending the OS.

Compare this to a container or a microVM - you have all of this rich capability, far more than what you need to do the job at hand; this extra stuff is called Ambient Authority. Then you run even more tools to "secure it". The math of software is such that, that is a very hard thing to do for a general program, so most pople just use generic rules instead of a perfectly crafted sandbox.

Read more at the links above.

2

u/ekool Oct 28 '26

I haven't used this but it's been on my list to check out: https://github.com/superradcompany/microsandbox

1

u/Murky-Abalone-9090 Oct 28 '26

Nvidia openshell + custom bash wrapper for manage all openshell flags and driverconfig and other providers and …

1

u/geek_404 Oct 29 '26

I am building a container based system for my team that let's them pick an agent and then it layers on Nono on top so we have container segmentation and nono layers it rules and runtime protection as well. I also pre-populate the skills and such that we default too. If you are interested DM me and I'll send you the repo. https://github.com/nolabs-ai/nono

1

u/pArbo Oct 29 '26

nix sandboxes

1

u/TrickyPlastic Oct 29 '26

pi-landstrip

1

u/lazyfai Oct 29 '26

Saw many users used VM, docker or whatever isolation but give the agent all keys 🤣

1

u/iportnov Oct 29 '26

pi install npm:pi-sandbox.

1

u/madddi2011 Oct 29 '26

I've built https://github.com/go-corral/corral

It's essentially bwrap on Linux / seatbelt on macOS and providers that create throwaway tokens for system access so your agent can work with them without having all your permissions and tokens.

1

u/schmurfy2 Oct 29 '26

I use https://github.com/bindsch/scode on osx which wraps the native sandbox tool on os x 1nd bubblewrap on linux.
It block access to my credentials and sensitive files.

I am investigating running it in microvm with tart

1

u/Glum-Drop-5724 29d ago

I am on windows. Run my agent in wsl+bubblewrap. Give it read access to everything, but write access to only Development folder. Its become a mess however with files scattered everywhere.

1

u/radim11 29d ago edited 29d ago

We ended up using custom Docker based containers as the default for coding agents too. The part that made it feel safer was not just putting the agent in a container, but cutting off its direct network access.

The container can only talk to a local proxy. The proxy has an allowlist for destinations and can inject a credential for an approved request, so the agent never gets the raw token in its environment. Repo gets mounted in, but not the home directory or random host credentials.

Docker has been the more reproducible option for us. Native sandboxing can be lighter, but it is easier to accidentally inherit too much from the host.

The extension issue sounds like it may just be the network allowlist. npm, GitHub, and any registry the extension fetches from all need to be reachable. What breaks when Pi tries to install or load one?

Context, we are building https://stashbase.dev

1

u/brotlos_gluecklich 29d ago

Does anyone know a good write for using Docker Sandbox (sbx) with pi? Like how I can sync my global pi settings, extensions, skills into it, together with my project repo, control network access, manage credentials and such?

1

u/nez_har 29d ago

https://github.com/VibePod/vibepod-cli supports Pi and you can run it via Docker or Podman, use custom providers, profiles and restrict network access 

1

u/AdorableBreadfruit51 29d ago

It does keep everything isolated in Docker, but it’s annoying because I had to feed it files, directories, config, etc. manually. I had a shared folder mounted in the container, but the container ran as root, so every time I copied something out, I had to manually overwrite the permissions. In the end I deleted the whole setup.

Now I have no guardrails, which isn’t ideal and is actually dangerous. It wrecked my phone when I gave it su privileges. I eventually fixed it, but it was a great learning moment and I'm more careful now with my prompts.

1

u/-rcgomeza- 29d ago

VM with non sudo user

1

u/jinnyjuice 29d ago

Any simple & free solutions for Windows? So hard to find stuff outside of Linux

1

u/juanluisback 29d ago

Shameless self-plug, I published a video recently on how to sandbox Pi using Canonical Workshop (LXD containers) https://youtu.be/u5Q149jlMQ8?si=gp_vhtviHwzQKbGH

1

u/e3e6 29d ago

I don't

1

u/lmpdev 29d ago

I made this https://github.com/perk11/pipod

It has been working reasonably well. I also create a global instruction file to explain to the agents what's going on and that they can install any packages they need (although it was working without it too).

1

u/True_Joke_5248 28d ago

How do you copy and paste between the host and container? And screenshots if on a Mac?

1

u/lmpdev 28d ago edited 28d ago

The terminal runs docker on the host, so you just interact with it as a normal application and it pastes to Docker and gets output from Docker.

Screenshots is one weak spot of this approach right now, you have to put them into the project directory and reference them via @file.png.

I also haven't tested it on Mac (but theoretically it should work).

1

u/LaserKittenz 29d ago

Docker/kubernetes seems like the best option imo

1

u/Flaky-Eggplant-3479 29d ago

I make a lot of little pi agents with the sdk and generally just deploy inside a fully featured firecracker vm and give the harness root access

1

u/UpbeatBass6066 29d ago

I think I am moving toward real VMs for each project. I've tried Bubblewrap but being careful about not giving too much permission in tools that I use is tedious. VM boundaries are much simpler and I just install tools in the VM. And I can put the VM on a server cleanly and develop using a terminal via ssh.

1

u/ColonelKlanka 28d ago

have a look at the free nono sandbox cli. it sandboxes the pi agent (or any other agent)

1

u/Maleficent-Ad876 28d ago

Checkout smolvm! Falls right into place

1

u/Express_Quail_1493 27d ago

Nope. Sandbox is the Ai cond0m. I like to live on the edge 😀. LOL but my qwen3.8-27b never does anything crazy though so maybe im hoping for adrenaline from disaster that will never come🥲. Anyway.. living on the edge baby Rawdog🤘

1

u/schwigglezenzer 27d ago

Hi, what do you mean by 'anything crazy', like accidentally deleting files? What is the actual likelihood of that happening?

My setup uses a debloated Win 11 running entirely in admin mode (I cannot run CMD non-elevated). I use Qwen36-q8_0 and plan to try Flash Next soon

Is there a real risk of the agent going rogue and deleting my files on C or on external HDDs? I can't reinstall Windows as it's configured perfectly with ton of software etc.. so I just need a solution to restrict the agent's access exclusively to the project folder. I'm trying to avoid a VM due to RAM constraints.

1

u/Express_Quail_1493 27d ago

the only LLM less than 100b that i trust to leave autonomous loop and turn my back and let it go freely i only trust qwen3.8-27b. because 35b-a3b MOE has too little amount of active parameters 3b active will defenitely cause it to loose track and do crazy stull like delete some important system stuff if its working close with them. but some tools guard against that quite well like https://github.com/xing-shuyin/pi-web-ui amazing little repo has good guards. but still a competent 27b with zero restructions is more productive for me since i don't stall waiting for approval. he never does anything stupid so far so im happy with it. been doing this for the last 4-5 months and my windows 11 is still intact. im excited for qwen4-27b will be even more competent and autonomous human-out-of-loop agentic.

2

u/schwigglezenzer 27d ago

Thanks, appreciate the response! I'll check out that repo.

So Qwen4-27B is much smarter, huh? Nice.

I'll probably just install Flash Next with Strata and call it a day... my only concern is that I need to run other RAM heavy apps at the same time.

1

u/Express_Quail_1493 26d ago

happy tweaking 😄 enjoy & good luck

1

u/New_Plate1652 27d ago

Docker's great for speed but those permission issues with extensions are super common. Honestly, the core problem isn't the container tool, it's getting true isolation without breaking your dev flow.

I've been testing kosa8 for my agent projects. Runs each agent in its own microVM so it's totally sealed. It's way better for the sensitive data I sometimes handle. The instant rollback is a lifesaver when things go wrong. Plus, it works right alongside my existing Docker setup.

What's the main thing driving your sandboxing need? Is it more about security for work data, or just keeping hobby projects tidy?

1

u/jodosha 26d ago

I’m building my own (no vibecoding) based on libkrun VMs, Seatbelt (MacOS), Landlock (Linux). Plus other security features (egress, permissions, etc…).

1

u/No_Caterpillar_5428 20d ago

Docker sandboxes make sense for cross-platform work. For macOS, I built Agent Guard as a lighter-weight option using the native Seatbelt sandbox.

With Pi, it limits writes by Pi and its child processes to the launched project and permitted runtime/cache/temp locations, without requiring a container. It also supports OpenCode, OMP, and Grok CLI.

It requires macOS 15+. It isn’t equivalent to a VM: network access remains unrestricted, and files inside writable locations can still be deleted.

Which extensions were giving you trouble?

https://github.com/ebrindley/AgentGuard

1

u/First_Inspection_478 Oct 28 '26

smol-machines/smolvm as a git worktree hook

1

u/mxcw Oct 28 '26

Wat? Please elaborate

1

u/First_Inspection_478 Oct 29 '26

I added a script that forks a smolvm off some “base snapshot” per worktree.

1

u/psychobarge Oct 28 '26

I built a custom sandbox solution with docker containers and a proxy for api keys i have a mac and a windows version https://github.com/psychobarge/pi-sandbox

1

u/deepit6431 Oct 29 '26

I like pi because it has no permissions and doesn't stop me from doing things. I don't.

1

u/mission_tiefsee 29d ago

This is my solution to this problem. I re-use bubblewrap with a shell wrapper. The thing looks a bit complicted and i need to reword the github readme, but if you are interested just point an agent there and let it read it. Its pure shell (+bubblewrap).

Supports ssh keys per folder, ro, rw mounts of other folder. I use it every day. https://github.com/zweifuchs/limen

0

u/dev_zero Oct 28 '26

I use microsandbox and really like it