Skip to content
vlad.io
Go back

Where my coding agents run when my laptop is off

I wanted to be able to shut down my Mac in the middle of a Claude or Codex session and let the agent keep working. I also wanted some say in what an unattended agent could get its hands on. A refurbished Dell OptiPlex and a single Proxmox container turned out to cover both.

Why this particular Dell?

I paid $370 for a refurbished Dell OptiPlex 7000 SFF with a Core i7-12700, 16 GB of RAM and a 512 GB SSD. I wanted to run several coding agents in parallel on the same machine I’d be using for Frigate and Home Assistant, and the i7-12700 has 12 physical cores and 20 hardware threads.

Frigate was another reason I picked this particular processor. Its integrated GPU could handle video decoding for my security cameras, and the CPU could clock down when the machine was mostly idle. That mattered to me since I planned to leave it on around the clock. I haven’t put a meter on it yet, so take this as an estimate: desktops of this generation tend to sit somewhere between 20 and 35 watts under a light load like mine, and at 30 watts that works out to roughly 260 kWh over a year.

The Dell also had four RAM slots. I already had spare RAM lying around, so I added 48 GB to the 16 GB it came with and ended up with 64 GB.

My development container gets 4 of the 20 threads and 16 of the 64 GB. That leaves 16 threads and 48 GB for the cameras and Home Assistant, which gives me a lot of room to expand and to run resource-intensive tasks like bringing up databases and compiling.

What can an unattended agent get to?

Before leaving a coding agent running on its own, I thought about what it needed for the job. It needed the project files, but it had no business reaching the Proxmox host, my email, or the secrets I had on my Mac for a completely different project.

I set up an unprivileged LXC container in Proxmox and ran my coding agents inside it. Unprivileged means that the container’s user ids are shifted on the host, so root inside the container is user 100000 outside of it and has no special rights over the host’s files or processes. These are the lines of the container’s config that matter here:

cores: 4
memory: 16384
unprivileged: 1

The other part was deciding what went into the container. Keeping my personal files and the credentials for unrelated projects outside the agent’s environment mattered just as much as the unprivileged setting. The agent could still make a mess of whatever I had put in that container. At least I knew where the mess would stop.

A container that joins a tailnet under the default policy can also open connections to every other device on it, which is more than a coding agent needs. The ideal arrangement is to give the container a tag and write grants so that my own devices can reach the tagged container over SSH while no grant names the tag as a source. Tailscale denies whatever isn’t granted, so the container can answer my Mac but can’t start a conversation with anything else.

{
  "tagOwners": { "tag:agents": ["autogroup:admin"] },
  "grants": [
    { "src": ["autogroup:member"], "dst": ["tag:agents"], "ip": ["22"] }
  ]
}

The default policy that lets every device talk to every other one has to go for this to work, since a narrower grant doesn’t cancel a broader one, and the rest of the devices on the tailnet then need grants of their own.

Checking in with herdr

In June I kept my agent sessions alive with tmux. For this setup I switched to herdr, which does the same job with coding agents in mind. It runs as a server inside the container and owns the terminals that Claude and Codex run in, so the sessions carry on whether or not anything is attached to them. That is the whole reason I can turn the Mac off.

herdr also keeps track of what each agent is doing. I run several sessions side by side in the one container, and its sidebar shows which of them are working, which have finished and which are blocked waiting for me.

I put the container on Tailscale, so from my Mac I could connect directly to it, open herdr and see what needed my attention. Sometimes that meant reviewing what an agent had done, and other times helping it past a sticking point or giving it something else to work on.

If I have to run an errand halfway through a coding session, I can shut down my Mac and go, and Claude or Codex keeps working on the Dell. The next time I open the Mac, I connect to the container over Tailscale and check on it in herdr. I do the same thing when I’m traveling.

With this setup I’m no longer attached to my location or even to my MacBook, since I can answer an agent’s questions or trigger new tasks from my phone, using a mobile terminal client connected over Tailscale.

My Mac and my phone connect over Tailscale to a herdr server in the development LXC on a Dell running Proxmox. herdr hosts the Claude and Codex sessions, and Frigate and Home Assistant run on the same machine.

Security for long-running agentic tasks

An agent that runs for hours without me watching has plenty of time to do something I didn’t intend, so the container is only the first layer. These are the safeguards I have in place today:

  • Narrowly scoped API tokens: wherever a service allows it, the agent gets a token that can only do what the task needs. My GitHub tokens, for example, have write access to a single repository, even if they can read a few other private ones.
  • Limited CLI authentication: tools like the Google Cloud CLI are signed in with an account that has enough access for the project and nothing more, and never with my admin credentials.
  • Tailscale ACLs and network configuration: these limit what the container can reach on my internal network.

And these are the ones I would still like to add:

  • An authentication proxy: a layer that the agents have no access to, which holds the real credentials and routes their API requests to the outside world. I would configure which access each agent gets, and the agents themselves would never see a secret.
  • An outbound allowlist: the container would only be able to reach the hosts an agent needs, such as the model APIs, the package registries and GitHub, which makes it much harder for anything running inside to send data somewhere else.
  • Short-lived credentials: tokens that expire after hours instead of months, so that a leaked one stops working soon after.
  • A snapshot before every long task: Proxmox can snapshot a container, which would let me roll the whole environment back if an agent leaves it in a state I can’t untangle.
  • A spending limit per agent: a budget on each agent’s model key, so that a session stuck in a loop overnight stops when it hits the limit.


Previous Post
Adding flexibility and observability to an AI application with LiteLLM