Building a localhost testing workbench

The infrastructure behind my agent security research: any live site presented to an isolated coding agent as genuine localhost origins, with a plan-driven testing harness and dashboard on top.

Internally developed research infrastructure, running on my own hardware. Nothing here is a client engagement, and no third-party system was tested without authorisation — the workbench exists so agents can be tested against real software offline. Written by Joshua Thweny.

The problem

Testing whether a coding agent behaves safely is hard to do honestly. Point an agent at a live site and you are testing against someone else's production system without permission; point it at a mock and you have removed everything interesting — real JavaScript bundles, real sign-in flows, real WebSocket traffic, all the places agents actually go wrong.

I wanted a third option: give the agent a real website, live and unmodified, but running as if it were the agent's own localhost — inside a VM the agent owns, on hardware I own, with no path to the public internet unless I open it.

What it is

The workbench has three layers, all private infrastructure on a macOS arm64 host:

  • A one-command VM. localrun clones a prepared Ubuntu rootfs copy-on-write and boots it under vfkit on Apple's Virtualization framework — no virtual network card, the host talks to the guest only over a vsock trunk. Every run gets a fresh disk; nothing persists between targets.
  • A live-site bridge. A host-side gateway runs the real upstream website's traffic through a rewriting layer (Rust parsers for HTML, CSS, JS, JSON, source maps) and serves it inside the guest at app.localhost and derived *.localhost origins, so pages, assets, sign-ins and streams resolve live to the genuine upstream — but from the agent's seat it is all local. TLS is handled by a host-held root CA; the guest sees valid certificates for every .localhost name.
  • An agent testing harness ("Prompter"). A plan-driven loop with six escalation levels: a planner model turns the operator's scope into one evidence-bearing objective per level, a worker agent executes real browser and shell tasks inside the VM, and a judge model separates process health from outcome. A level advances only when its objective's evidence bar is met; a refusal rewinds and reframes the task rather than counting it as done.

A host-only dashboard (Starlette, loopback) ties it together: launch and switch VMs, start campaigns, watch the worker's live message and tool stream, inspect findings, and steer the campaign scope mid-run.

Why it is built this way

  • Isolation by default. The guest has no NIC; egress is an explicit host-side decision. An agent that misbehaves is contained to an ephemeral disk, not a production system.
  • Realism without permission risk. The agent exercises genuine multi-megabyte bundles, OAuth handshakes and streaming responses, but the target is a private clone-on-write VM — authorised testing of my own infrastructure, the default posture of every review I publish.
  • Honest evaluation. The harness refuses to reward process health: only judged evidence advances a level, refusals are retried with framing rather than discarded, and blocked environments record durable blockers instead of failing silently. This is the same honesty I look for when reviewing client agent setups.
  • Observable agents. Because the gateway sees every request, the dashboard can show exactly what an agent fetched, sent and wrote — the raw material for judging tool-permission and injection-surface decisions.

What it feeds

The workbench is where the patterns in the field notes come from: agent tool schemas, spend caps, prompt-injection surfaces and human-in-the-loop gates, all exercised against realistic targets rather than contrived ones. It also backs the defensive AI agent reviews offered under Services.

It is not public open source yet; parts (the Rust rewriter, the campaign harness) may be released once the research notes they support are published. Ongoing independent research that reaches third-party software follows the coordinated disclosure policy.