Skip to main content
Run coding agents (pi, Claude Code) on Vers VMs and drive them programmatically from a coordinator. This is the foundation for agent swarms, parallel task execution, and remote agent workflows.

Architecture

A remote agent runs inside a Vers VM with a FIFO-based RPC channel. The coordinator (your local machine, a CI runner, or another agent) sends JSON messages over SSH and reads responses back.
Two tmux sessions run inside the VM:
  • pi-keeper: Runs sleep infinity > /tmp/pi-rpc/in to hold the FIFO write-end open (prevents pi from getting EOF)
  • pi-rpc: Runs pi --mode rpc < /tmp/pi-rpc/in >> /tmp/pi-rpc/out 2>> /tmp/pi-rpc/err

Prerequisites

  • Vers CLI installed and authenticated
  • API keys configured via vers env set (e.g., ANTHROPIC_API_KEY)
  • A golden image with pi pre-installed, or willingness to install it on a fresh VM

Step 1: Boot an Agent VM

From a Golden Image (Fast)

If you have a golden image with pi and the RPC scaffold pre-configured:
The agent is immediately ready for tasks.

From a Fresh VM (Manual Setup)

Start a fresh VM and install the agent manually:
Inside the VM:
Then set up the RPC scaffold:
Exit the VM (exit).

Step 2: Send a Task

From your coordinator, send a JSON message to the agent:
The -i flag is required when piping stdin into vers exec. Without it, stdin is not forwarded to the remote command. vers execute is an alias for vers exec and works identically.

Step 3: Read Output

One-shot (last N lines)

Streaming (live)

Check for errors

Message Protocol

Standard Task

Queue a task. If the agent is idle, it starts immediately. If busy, it queues.

Steer (Interrupt + Redirect)

Interrupt current work and redirect the agent:

Follow-up

Queue a task to run after the current one completes:

Other Commands

Response Format

The agent writes JSON lines to /tmp/pi-rpc/out. A completed task produces a line with:
Watch for "type": "response" to know when work is done.

Polling Pattern for Long Tasks

For tasks that take minutes, poll for new output:

Multiple Agents (Swarm Pattern)

Spawn several agents and fan out work:

Snapshotting Agent State

Save an agent’s working state as a commit for later reuse:
This is useful for:
  • Checkpointing before risky operations
  • Creating reusable “warmed up” agent states
  • Sharing agent environments across team members

Building Golden Images for Agents

Manually setting up each agent VM is slow. For repeatable agent workflows, build a golden image once and boot from it instantly. See Custom Golden Images for the full process. The key steps:
  1. Start a fresh VM, install your agent and tools
  2. Set up the tmux/FIFO scaffold and systemd auto-start
  3. Clean secrets and regenerate SSH keys
  4. Commit as a tagged snapshot

Troubleshooting

No output from agent

Check that tmux sessions are running:
You should see both pi-keeper and pi-rpc. If missing, re-create the scaffold (Step 1 manual setup).

Agent exits immediately

The pi-keeper session isn’t running. Without it, the FIFO gets EOF and pi exits. Restart:

Task sent but nothing happens

Check if pi is actually running:
Send a state check:

SSH / connection issues

Verify the VM is running:
If paused, resume it:

See Also