Bottling an Agent
Back in June 2026 I was doing some exploratory work around sandboxes and confining coding agents. I develop on macOS and intended this to be a tool for myself. I wanted to do a quick writeup on what I did and what I had built.
I had a rough idea of various ways to approach building a sandbox. Containers, VMs, microVMs, etc. I knew that I needed isolation at two levels: filesystem and runtime. I figured both would be relatively easy with containers and VMs, but I anticipated there being a lot of friction between the container/VM and the developer’s own system. That’s where all the problems will be.
In my research I came across the (then-new) Apple Container tool .
On the surface this seemed like the perfect tool for what I was building. So I ran a few tests on container, validated that it actually works as intended, and set off to build a tool im calling agentBottle.
With container you can restrict filesystem access to specific folders, which in my tool correspond to project/agent pairs.
Calling it container is also a little misleading. It’s not containers in the same sense as Docker or LXC. In either of those solutions, containers share the kernel of the host OS. In Docker on macOS, docker spins up a linux VM and containers all share the guest’s kernel.
With apple containers, each individual “container” is really just a lightweight VM, so runs its own kernel and doesnt share it with other containers. not quite micro-VMs like firecraker or the like, but still lightweight.
on security
My position is that containers are not true isolation and we should not treat containers as true sandboxes. Equally, i would not trust whatever safeguards are built into a cli coding agent either.
VM / μVM is the better path imo. If you are a developer, stick to a VM if you care about isolation. For personal projects, I use an older micro PC to run my agent on. The idea is that I dont care what happens to that box, and I can give the agent unrestricted permissions, full access to system/screen, etc and let the it do its thing.
In a corporate environment I’d stick to VMs or hosted sandboxes. Of course, none of this really protects you if you give your agent access to internal systems via network and APIs. Managed identities for agents, ingress/egress control, observability- these are all enterprise considerations beyond the current scope of this tool so we’ll stop here.
the UX
there are 3 main concepts within agentBottle:
- Workspaces: these are the places where work happens and where agents live
- Catalog: a collection of definitions and scripts that install and configure an agent
- Terminals: as described, a list of supported terminal emulators you have available on your system that can be used to launch the agent in.
The intended workflow looks like this:
- Create a new workspace
- Select a coding CLI agent you want to work with
- Choose a directory you will use for your project, this becomes your project root inside of the workspace
- give your workspace a name, resource limits, and hit create
- See your workspaces, click on one to launch it
- The workspace opens and connects automatically via your preferred terminal.
- you interact with the agent via your terminal






limitations
An early limitation I ran into was in the guest/host boundary and exec. I wanted bidirectional clipboard and image paste. I knew I could get around the clipboard stuff, but if you dont trust an agent, does giving it polling access to your clipboard make sense? As for images, I know OSC 5522 is a thing, but every terminal/agent combo would need to support it and it wasnt widely supported when i first looked at this several months ago. I figured that if i wanted a really good experience I would probably have to write my own service that lives on the inside of the apple container/vm and communicates with my app and exchanges data. More complexity, but gives me more control.
conclusion
Overall, I’m pleased with this tool and how it turned out. It’s got limits and rough edges but I’m happy I was able to build something like this. I dont think I’ll get much more use out of it going forward, as tooling has moved towards ADEs and such (and I built my own too!), but maybe I’ll reuse some of the mechanisms in my other projects. The problem of confining agents is not going away and the market for agent sandboxing tools feels saturated right now.
You can find the project on github: MRKups/agentbottle