Run the control plane in the cloud¶
The control plane that Dragon Rider runs on your Mac can only be reached while the Mac is awake and online. Run it on a machine you rent instead, at a domain of your own, and it is always there. Windows, phones and hosts reach it at one address from anywhere. Its certificate comes from Let's Encrypt, so it is trusted like any website's, and codes carry no pin.
This guide runs one copy, with its store on the machine's own disk, behind Caddy. For several copies over a bucket, see Run the control plane as several copies.
Before you start¶
- Nothing to build or clone. Each release of Dragon Rider publishes the control plane as a
signed image,
ghcr.io/agentloops-dev/agents-control:<version>, for x86-64 and ARM64. It carries the Linux host that it hands to servers that join, and the files to run it with. See The image. - A Linux machine you rent, on x86-64 or ARM64, with Docker and Docker Compose. The smallest size a provider offers is plenty: 1 CPU and 1 GB of memory. The control plane runs no agents itself.
- A domain you control, such as
example.com, so that you can add DNS records for two names likeagents.example.comandviews.example.com. The second is where the web page draws MCP Apps views. - An email address for Let's Encrypt to write to about the certificate.
- A Google Cloud project with Cloud KMS turned on, and the
gcloudcommand signed in to it. Cloud KMS keeps the key that seals the control plane's own key, so that key is never on the machine's disk in clear.
Google Cloud¶
On Google Cloud, three scripts do most of the steps below for you: they make the machine,
its firewall, its address, the Cloud KMS key and the DNS records, then build and start the
control plane. They run from a clone of the Dragon Rider repository on your Mac. With no Mac, do
the Steps by hand instead: they need only a browser and the machine's own
terminal. Each script looks first for what it makes, so you can run it again safely.
Each takes --dry-run, which prints every command and runs none.
What you make first¶
- A Google Cloud project, with a billing account linked to it. Link it in the console
(Billing ▸ Link a billing account). A billing account that is not linked to the
project is not sufficient: without the link,
up.shcan't turn on Compute Engine or Cloud KMS. - In that project, a service account for the scripts, with these roles: Service Usage
Admin, Compute Admin, Cloud KMS Admin, Service Account Admin and Service
Account User. Make a JSON key for it, and put the key in
~/.agents/secrets/gcp-agents-control.json(chmod 600). The scripts read the project from this file. They use a gcloud configuration of their own, in~/.agents/gcloud/agents-control, and do not change yours. - The domain, such as
agentloops.dev, on Cloudflare's DNS, and a Cloudflare API token from the Edit zone DNS template, for that zone only. Put the token in the Keychain:
security add-generic-password -a "$USER" -s agents-cloudflare-token -w
- For notices on iPhone and iPad with no Mac host: the APNs
.p8key, as in Get what it runs. Its name gives the Key ID. - On your Mac:
gcloud(brew install --cask gcloud-cli). To deploy a commit that no release has (up.sh --build), also Go (brew install go) and the Node inWeb/.node-version: the binaries and the web page are built on your Mac, and the VM's own Docker builds the image from them. Your Mac needs no Docker.
Run the scripts¶
In the repository on your Mac:
- Look at what
up.shwill do:
deploy/gcp/up.sh --dry-run
- Make the machine:
deploy/gcp/up.sh --apns AuthKey_KEYID.p8
It turns on Compute Engine, Cloud KMS and IAM. The IAM API needs about a minute after
it is first turned on, so up.sh waits until IAM answers. Then it makes:
- the Cloud KMS key ring agents and key control;
- the service account agents-control-vm, which may only encrypt and decrypt with that
key. The machine runs as this account, so no key file for it is on the machine;
- the network agents-control, with ports 80 and 443 open to all, and port 22 open
only to your Mac's IPv4 address;
- a static IPv4 address;
- an e2-micro machine in us-west1-b, running Debian, with a 30 GB standard disk.
A startup script puts Docker on it;
- the snapshot schedule agents-control-daily on that disk: a snapshot every day at
10:00 UTC, each kept 7 days. See
Restore the disk from a snapshot.
It prints the machine's address, then stops: the names do not point at it yet.
3. Make the DNS records, with the address that up.sh printed:
deploy/cloudflare/dns.sh <the address>
It makes an A record for control.agentloops.dev and one for
views.agentloops.dev, DNS only (not proxied), and never prints the token. Use
--zone and --names for other names. To put Cloudflare's proxy and rate rules in
front instead (#2151), see "Cloudflare in front" in deploy/README.md: give
--proxied here, once that section's other steps are done.
4. Run up.sh again, with the same options:
deploy/gcp/up.sh --apns AuthKey_KEYID.p8
When both names point at the machine, it copies deploy/compose.public.yaml and the
secrets to /opt/agents on the machine, has the machine pull the release's image, and
starts the control plane and Caddy. It waits until
https://control.agentloops.dev/healthz answers. Let's Encrypt's address for notices is
your git email, or give --email. Use --domain and --views-domain for other names.
To keep the control plane key from your Mac, give --seal-key control-key at this
step, before the first start. See
Move the control plane from your Mac.
5. Get the first code with the command that up.sh prints, then go on at
Pair your first window.
up.sh runs the release in AGENTS_VERSION, such as 0.19.0. Without it,
scripts/version.sh says, which is a release's version only in a checkout of its tag. For
a commit that no release has, give --build: it builds the binaries and the web
page on your Mac from the checkout, stamps that version on them, and the machine builds the
image from them. That takes 15 to 27 minutes on an e2-micro, with each step in the output. It
stops after 45 minutes, or when the connection to the machine ends.
To upgrade, run up.sh again with the new version: the machine pulls the new image, and
keeps the store, the APNs key and the snapshot schedule. At the end, up.sh checks that the
control plane on the machine says that version, the one Settings ▸ Control plane shows.
Every release of Dragon Rider deploys control.agentloops.dev this way (#2100). After the tag, and after the GitHub release and both TestFlight builds pass, the release runs, in a checkout of the tag:
AGENTS_VERSION=<version> deploy/gcp/up.sh
Then it checks that https://control.agentloops.dev/healthz answers and that the version
served is the new one. If either check fails, the release report says so and a
priority:high bug is filed. The store is never rolled back.
To remove it all, run deploy/gcp/down.sh. It asks first. The store is on the
machine's disk, so after down.sh every window, phone and host must pair again. It
removes the snapshot schedule, but keeps the snapshots, as the last copy of the store, and
prints the command that deletes them. The
Cloud KMS key stays, unless you give --destroy-key. Remove the DNS records at Cloudflare
yourself.
What it costs¶
| Item | Cost |
|---|---|
| The static IPv4 address | about $3.65 a month |
| The e2-micro machine in us-west1 | free tier (one a month) |
| The 30 GB standard disk | free tier (30 GB a month); a balanced disk, the console's default, is billed |
| The Cloud KMS key | about $0.06 a month, and $0.03 for each 10,000 uses |
| The disk's snapshots | billed by the GB a month that they hold: each snapshot after the first holds only what changed |
| Traffic out | free tier (1 GB a month), then billed |
Steps¶
On another provider, or to do it by hand, follow these steps.
Get the machine ready¶
- Rent the machine, and note its public IPv4 address (and its IPv6 address, if it has one).
- Open ports 80 and 443 to the internet, in the provider's firewall and in the machine's own if it has one. Caddy needs both: 443 for connections and for proving the name to Let's Encrypt, and 80 for its other challenge and its redirect to HTTPS. Keep every other port closed. The control plane's own port, 8791, is only reached by Caddy inside Docker.
- Install Docker and the Compose plugin, following Docker's guide for the machine's distribution.
Point the name at it¶
- At your DNS provider, add an A record for the name, such as
agents.example.com, with the machine's IPv4 address. If the machine has IPv6, add an AAAA record too. If it has no IPv6, add no AAAA record: Let's Encrypt prefers IPv6, and a record that reaches nothing makes the certificate fail. - Add the same records for the views name, such as
views.example.com. The web page draws MCP Apps views from this name, because a view must have an origin of its own, apart from the page. A CNAME record to the first name is also correct. - Check both from your computer:
dig +short agents.example.com
dig +short views.example.com
Each prints the machine's address. Wait for that before you start Caddy: until the name resolves, Let's Encrypt can't check it, and too many failed tries make it wait an hour.
Make the key that seals the control plane's key¶
The control plane's key proves to every window, phone and host that it is your control plane. On the machine it is sealed in the store by a key in Cloud KMS, which never leaves Google Cloud. The machine gets only the right to use that key.
On your computer, or in Google Cloud Shell, with gcloud (put your Google Cloud project's id in place of my-project):
- Make a key ring and a key:
gcloud kms keyrings create agents --location global --project my-project
gcloud kms keys create control --keyring agents --location global \
--purpose encryption --project my-project
- Make a service account that may use only that key:
gcloud iam service-accounts create agents-control --project my-project
gcloud kms keys add-iam-policy-binding control --keyring agents --location global \
--member serviceAccount:agents-control@my-project.iam.gserviceaccount.com \
--role roles/cloudkms.cryptoKeyEncrypterDecrypter --project my-project
- If the machine is not a Google Compute Engine VM that runs as that service account, make a key file for the service account:
gcloud iam service-accounts keys create sa.json \
--iam-account agents-control@my-project.iam.gserviceaccount.com
On a Compute Engine VM that runs as the service account, make no key file: the VM gets its right to use the key from Google Cloud, and no secret of any kind is on its disk.
Get what it runs¶
On the machine, in a folder of its own such as ~/agents, take the files to run it with out
of the release's image (here 0.19.0):
docker create --name agents-files ghcr.io/agentloops-dev/agents-control:0.19.0
docker cp agents-files:/deploy ./deploy
docker rm agents-files
deploy/ has the compose files, the Caddyfiles and make-secrets.sh. The image itself
carries the rest: the Linux host, which the control plane hands to every Linux server that
joins, and the runtimes' toolsets, so that the server installs Claude by itself.
- Say which key seals the control plane's key, and give the service account's key file:
deploy/make-secrets.sh --public \
--kms projects/my-project/locations/global/keyRings/agents/cryptoKeys/control \
--service-account sa.json
This writes AGENTS_CONTROL_KMS in deploy/.env, and copies the key file to
deploy/secrets/gcp-service-account. On a Compute Engine VM that runs as the service
account, leave out --service-account. Then delete sa.json: anyone who has it and a
copy of the store can open the control plane's key. Never commit either.
For notices on your iPhone and iPad, give the APNs key from your Apple developer account (Certificates, Identifiers & Profiles ▸ Keys, with Apple Push Notification service on). Do it now or later, with or without the rest:
deploy/make-secrets.sh --public --apns AuthKey_KEYID.p8
This copies the key to deploy/secrets/apns-key, and writes AGENTS_APNS_KEY_ID (read
from the file's name) and AGENTS_APNS_TEAM_ID in deploy/.env. Give --apns-key-id
when the file has another name. Without it, the control plane sends no pushes, and its
log says so once when it starts. Never put the key in a code, the store or the repo.
make-secrets.sh is a zsh script: install zsh on the machine first
(sudo apt-get install zsh on Debian or Ubuntu). Copy sa.json and the .p8 key to
the machine for it, and delete them there afterwards.
To run a commit that no release has, build from source instead: copy the repository's
deploy/, Go/, Web/ and App/Resources/toolsets/ to the machine with the same layout,
and give --build to docker compose up below. The image is then built on the machine.
Start it¶
On the machine, in the folder you copied to:
- Say the two names, your email and the release, in
deploy/.env:
AGENTS_DOMAIN=agents.example.com
AGENTS_VIEWS_DOMAIN=views.example.com
ACME_EMAIL=you@example.com
AGENTS_VERSION=0.19.0
Caddy gets a certificate for each name. AGENTS_VERSION is the image's tag: a release
such as 0.19.0, 0.19 for the newest 0.19 release, or latest. Without it, latest.
- Get the image, and start the control plane and Caddy:
docker compose -f deploy/compose.public.yaml pull
docker compose -f deploy/compose.public.yaml up -d
To upgrade, take the new release's deploy/ folder out of its image as above (keep
deploy/.env and deploy/secrets/), set the new AGENTS_VERSION, and run both
commands again. The store and the certificate stay.
At its first start the control plane makes its key and seals it in the store. To keep a key from elsewhere, seal it before this step: see Move the control plane from your Mac.
- Within a minute Caddy has its certificate. Check from your computer:
curl https://agents.example.com/healthz
It prints ok. If it doesn't, look at what Caddy says:
docker compose -f deploy/compose.public.yaml logs caddy.
Pair your first window¶
The first code comes from the machine. After that, every code comes from a paired window.
- On the machine:
docker compose -f deploy/compose.public.yaml exec control /agents-control code --client
It prints a code, which works once, for five minutes. Its eighth field is -: it
carries no pin, because the certificate is publicly trusted.
2. In Dragon Rider on your Mac, open Settings ▸ Control plane, click Connect to
Another…, then Use a Code…. Paste the code, click Next, and then Connect.
The window is paired, and this Mac's host joins with it.
Pair your iPhone and iPad from that window, as in Connect a window or phone.
With no Mac, pair a browser first. Add --browser to the command, so the code is
for the web page:
docker compose -f deploy/compose.public.yaml exec control /agents-control code --client --browser
Open https://agents.example.com/ in the browser, paste the code under Connect this
browser to your agents, and click Connect. The code works once, for five minutes.
See Run Dragon Rider with no Mac for the rest.
Use Dragon Rider in a browser¶
The control plane serves the Dragon Rider page at its own address, https://agents.example.com/,
so a browser anywhere can use it. The first browser can pair by a code from the machine
(see Pair your first window). After that, a browser pairs by a
code from a window, phone or browser that is already paired:
- In Dragon Rider on your Mac, open Settings ▸ Control plane ▸ Clients and click Pair a Client…, then choose Browser. On an iPhone or iPad, tap Add a Browser… at the foot of the sidebar.
- In the browser, open
https://agents.example.com/, paste the code, and click Connect. The code works once, for five minutes.
The browser shows in Clients as Chrome on the web (or its own name). It can do all a
window can. To cut it off, click Forget… on its row. To serve no page, set
AGENTS_CONTROL_PUBLIC_WEB= (empty) in deploy/.env. Sign-in with an account comes later
(#995).
Enrol a Linux server¶
- In the window, open Settings ▸ Machines, then Add a Machine…, and Copy the command.
- On the server, as the user your agents should run as, run it. It looks like this:
curl -fsSL https://agents.example.com/v1/install.sh | sh -s -- 'agents-control:2:h:…'
There is no --pinnedpubkey in it: curl, and then the host, check the certificate
with the server's own trusted roots. The server needs them installed, which most
distributions do by default; on a minimal image, install ca-certificates first.
The command says devbox joined the control plane. The server has a heading of its own in every window.
See Add a machine for the rest: installing over ssh, folders on the server, and its Claude sign-in.
Enrol your Mac¶
Your Mac becomes a host of the control plane in the cloud when you connect it, as in Pair your first window. The window pairs and this Mac's host joins in one step. The Mac's folders appear under its own heading in every window.
If Dragon Rider already runs a control plane on this Mac with hosts and devices paired to it, Connect to Another… starts afresh: those devices pair again, and the control plane on this Mac stops. Use This Mac Only, in the same place, starts it again as it was. To move an existing control plane across and keep what is paired, see the next section.
Move the control plane from your Mac¶
If Dragon Rider already runs the control plane on your Mac, you can move it to the machine and keep every window, phone and host paired. The machine gets this Mac's control plane key, so everything that is paired trusts it. Agents keep working while it moves.
Get the machine ready first, as above, with its names and certificate. If the control plane on the machine has already started (it has a store and a key of its own), empty it first.
- On the machine, stop the control plane and remove its store:
docker compose -f deploy/compose.public.yaml down
docker volume rm agents-control_data
This removes everything that the machine's control plane keeps: its hosts, its
clients and its own key. The certificate is in another volume and stays.
2. In deploy/.env on the machine, add this line. It starts the control plane empty, to
wait for this Mac's records:
AGENTS_CONTROL_RECEIVE=1
- In Dragon Rider on your Mac, open Settings ▸ Control plane and click Move… beside Move to Another Machine. The sheet opens at step 1.
- Click Save Key…, and save the key as
control-key. Then seal the key in the machine's store, with the key piped in over ssh, so that it is never written on the machine:
ssh you@agents.example.com 'cd agents && docker compose -f deploy/compose.public.yaml pull control'
ssh you@agents.example.com 'cd agents && docker compose -f deploy/compose.public.yaml \
run --rm -T control key seal --key-fd 0' < control-key
It says the control key … is sealed in the store by gcpkms://…. On Google Cloud,
deploy/gcp/up.sh --seal-key control-key seals the key, and starts the control plane.
Then delete the saved control-key on your Mac. Anyone who has it can pose as your
control plane.
On Google Cloud, deploy/gcp/move.sh receive control-key does steps 1, 2, 4 and 5 in
one command. It saves the machine's old store to /opt/agents/saved/ on the machine
before it empties it, and it deletes control-key when the key is sealed. After
Move Now, deploy/gcp/move.sh done takes AGENTS_CONTROL_RECEIVE=1 out again.
5. Start the control plane on the machine, if it is not running:
docker compose -f deploy/compose.public.yaml up -d
- In the sheet, click Continue. Type the machine's address, such as
https://agents.example.com, and click Check. Each line must get a tick: It answers, Its certificate is publicly trusted, It holds this control plane's key and It's empty, and waiting for this one. - Click Tell Everyone. Every window, phone and host that is paired gets the new address. The sheet counts who knows. You can move when some have not heard yet: this Mac sends them on later.
- Click Move Now. The sheet shows each stage: records held still, records copied, the machine takes over, this Mac's host goes there, and this Mac forwards anyone who still comes to it.
When the move is done, Settings ▸ Control plane says Joined and the machine's address. Windows, phones and hosts connect to the machine in a few seconds, and nothing pairs again. This Mac's copy of the control plane keeps running only to send members on to the machine, for 30 days. It does this again after the Mac restarts.
After the move, take AGENTS_CONTROL_RECEIVE=1 out of deploy/.env. On a store that
it has already taken, the setting has no effect. But if the store is lost, a control plane
with this setting waits for a move and does not start a store of its own.
Bring it back to your Mac¶
- In Dragon Rider, open Settings ▸ Control plane and click Run It Here Again…. The sheet checks both ends: the machine answers and holds this control plane's key, and this Mac's copy is ready and empty.
- Only if the machine made a key of its own (it started with an empty store and no key sealed), the sheet says so. Then write that key to a file on your Mac, piped out over ssh, so that it is never written on the machine:
(umask 077; ssh you@agents.example.com 'cd agents && docker compose -f deploy/compose.public.yaml \
run --rm -T control key export --key-fd 1' > control-key)
Click Use Key… in the sheet, choose the file, and then delete the file. Dragon Rider keeps the Mac's earlier key aside in the keychain. Only a shell on the machine can export the key: no request to the control plane gives it out. After a move from your Mac, the machine holds this Mac's key, and you do not do this step. 3. Click Tell Everyone, and then Move Now.
Every window, phone and host comes back to the Mac, with nothing paired again. The Mac has no address on the internet, so the iPhone and iPad then reach it only on the Mac's own network.
Notifications¶
The control plane sends notifications to the iPhone and iPad itself, through Apple's push
service (APNs), with the APNs key (--apns). A need from any host, on a Mac or a Linux
server, gets to the locked phone. Without the key, the iPhone and iPad get no
notifications.
The web page gets notifications by Web Push (#1486). make-secrets.sh makes the VAPID key
once, in deploy/secrets/vapid-key, and up.sh makes it on the VM and never replaces it: a
new key ends every browser's subscription. Allow notifications in the page's Settings ▸
Notifications; when no iPhone gets a need, that browser shows it, also with the page closed.
On an iPhone or iPad, Safari gives Web Push only to the page added to the Home Screen.
AGENTS_WEBPUSH_SUBJECT in deploy/.env is the mailto: or https: address a push service
may write to about it; without it, the project's page.
What to know¶
- The certificate renews itself. Caddy renews it about a month before it runs out. Nothing needs doing: no client or host holds a pin, so a renewed certificate, even with a new key, is accepted like the old one, and live connections carry on. Behind a proxy such as Cloudflare's, TLS-ALPN can't reach this Caddy, so it renews over HTTP-01 instead, also with nothing to configure.
- A proxy in front is optional, and trusted only by its own address. Caddy reads the
real client address from Cloudflare's published ranges only (
deploy/Caddyfile.public); from anywhere else it's the direct peer, as without a proxy at all. See "Cloudflare in front" indeploy/README.mdto put Cloudflare's proxy and rate rules in front ofagentloops.dev(#2151); a self-hosted control plane needs none of it. - The page and the control plane are one version. The image builds the page from the same checkout, so an upgrade changes both. A browser that has the page open loads it again when it reconnects.
- MCP Apps views on the page come from the views name. At
views.example.comthe control plane serves only the two files that hold a view (/sandbox.htmland/sandbox.js), and only the page may frame them. Atagents.example.comit refuses them. If the views name has no DNS record or no certificate, the page loads, but each view stays empty. - Don't set
AGENTS_CONTROL_PINwith a publicly trusted certificate. Caddy makes a new key at each renewal, so a pin would stop every window, phone and host from connecting after the first renewal. - What's kept, and where. The store, with every host and client and the sealed
control plane key, is in the Docker volume
agents-control_data. The certificate and the ACME account are inagents-control_caddy. Both are on the machine's disk, which the daily snapshots copy. Never destroy the Cloud KMS key: without it, the sealed key doesn't open, and every window, phone and host must pair again. - If the machine or its disk is lost, remove the service account's key in Google Cloud (IAM ▸ Service accounts ▸ agents-control ▸ Keys). A copy of the disk then can't open the control plane's key.
- Upgrading. Set the new release in
AGENTS_VERSION, and run thepullandup -dlines again (see Start it). Hosts and clients reconnect within seconds. Linux servers update their host the next time they connect.
On a corporate network¶
On a network where machines reach the internet through a proxy, and where the network may re-sign TLS with the organisation's own certificate authority (CA), every part of Dragon Rider can still reach the control plane:
| What dials | Its proxy | The organisation's CA |
|---|---|---|
| The Dragon Rider window on a Mac | The Mac's: System Settings ▸ Network ▸ Proxies, a PAC file too | The Mac's keychain |
| Dragon Rider on iPhone and iPad | The device's | The device's trusted certificates |
| A browser | The browser's | The browser's |
| The Mac's host (agentsd) | HTTPS_PROXY, HTTP_PROXY and NO_PROXY when set; otherwise the Mac's web proxies and their exceptions. A PAC file is not read |
The Mac's keychain |
| A Linux server's host | HTTPS_PROXY, HTTP_PROXY and NO_PROXY |
The system's roots, and the PEM file in AGENTS_CA_FILE, or else /etc/agents/ca.pem |
The tunnel through a proxy is HTTP CONNECT, so TLS goes from end to end. A proxy that
re-signs TLS breaks a pinned control plane: its codes carry a pin, which only the
control plane's own certificate matches. Use a control plane with a publicly trusted
certificate, as in this guide, or exempt its name from the re-signing. Whichever CA signs
the certificate, each window, phone and host also checks the control plane's own key at
each connection, so a proxy can't stand in for the control plane.
On a Mac:
- If the network uses a PAC file and no fixed proxy, also set the Secure web proxy (HTTPS) in System Settings ▸ Network ▸ Details ▸ Proxies. The window follows the PAC file. The host follows the fixed proxy.
- To trust the organisation's CA, open its certificate in Keychain Access, add it to the System keychain, and set When using this certificate to Always Trust. Most organisations do this for you with a configuration profile.
On a Linux server:
- Export the proxy in the shell where you run the install command:
export HTTPS_PROXY=http://proxy.example.com:3128
export NO_PROXY=localhost,.internal.example.com
The install command's curl follows them. The host started in the background (with no
systemd user session) has them too.
2. Put the organisation's CA, as PEM, in /etc/agents/ca.pem (one or more certificates
in one file). To keep it elsewhere, set AGENTS_CA_FILE to its path. Add it to the
system's roots too (update-ca-certificates on Debian and Ubuntu), so that the install
command's curl trusts it.
3. After the install command, if it started the host as the systemd user service
agents-host, give the service the same variables (and AGENTS_CA_FILE, if you set
it), as systemd does not read your shell's:
mkdir -p ~/.config/systemd/user/agents-host.service.d
cat > ~/.config/systemd/user/agents-host.service.d/proxy.conf <<'EOF'
[Service]
Environment=HTTPS_PROXY=http://proxy.example.com:3128
Environment=NO_PROXY=localhost,.internal.example.com
EOF
systemctl --user daemon-reload
systemctl --user restart agents-host
Running the install command again keeps this file.
The control plane itself also dials: other copies of it, with several copies. If its
machine has HTTPS_PROXY or HTTP_PROXY set, put the copies' names in NO_PROXY.
Metrics and logs¶
To scrape the control plane with Prometheus and ship its logs, set these in deploy/.env,
then run docker compose -f deploy/compose.public.yaml up -d again:
AGENTS_CONTROL_METRICS=0.0.0.0:9791
AGENTS_CONTROL_METRICS_TOKEN=<a long random string, such as from openssl rand -hex 32>
AGENTS_CONTROL_LOG_FORMAT=json
AGENTS_CONTROL_LOG_LEVEL=info
Metrics. The control plane serves /metrics, in the Prometheus text format, on a port
of its own, 9791. It is off unless AGENTS_CONTROL_METRICS is set. Caddy does not serve
it, and the compose file does not publish it, so only a container on the same Docker
network reaches it, at http://control:9791/metrics. On an address other than loopback, a
token is necessary: the control plane does not start without one. Prometheus sends it as a
bearer token:
scrape_configs:
- job_name: agents-control
authorization:
credentials_file: /etc/prometheus/agents-control-token
static_configs:
- targets: ["control:9791"]
The metrics are:
| Metric | What it counts |
|---|---|
agents_control_requests_total{method,result} |
Requests from clients. result is ok or error for the control plane's own methods, routed for a call sent on to a machine, refused or offline for one that was not |
agents_control_request_seconds{method} |
A histogram of the time that the control plane took for its own methods |
agents_control_events_sent_total{method} |
Notifications sent to clients, one for each client |
agents_control_store_operations_total{op}, agents_control_store_errors_total{op}, agents_control_store_seconds{op} |
Store reads, writes, deletes and lists, the ones that failed, and their times |
agents_control_hosts_connected, agents_control_hosts_known |
Machines connected to this copy, and machines in the store |
agents_control_clients_connected, agents_control_client_sessions |
Windows, phones and browsers connected, and their sessions |
agents_control_leases_held, agents_control_copies |
With several copies: machine leases that this copy holds, and the copies it knows |
agents_control_phase{phase} |
1 for this copy's phase: serving, receiving, frozen or forwarding |
agents_control_up_seconds, agents_control_build_info{version} |
How long it has run, and its version |
agents_control_capacity_level |
0 for ok, 1 for near, and 2 for full |
agents_control_capacity_reason{reason} |
1 for the signal that set the current level: load, pressure_io, pressure_memory or hysteresis |
agents_control_load_per_core, agents_control_load_per_core5 |
One and five minute load averages, each divided by the number of CPU cores |
agents_control_pressure_io_full_avg60, agents_control_pressure_memory_full_avg60 |
Linux PSI full avg60, in percent. They are 0 when PSI is not available |
agents_control_memory_available_bytes, agents_control_swap_used_percent |
Available physical memory in bytes, and percent of swap in use |
agents_control_heap_inuse_bytes, agents_control_goroutines, agents_control_open_files |
Go heap objects in use, goroutine count, and open file descriptor count. Open files are 0 when /proc is not available |
agents_control_store_files, agents_control_store_bytes |
Regular file count and total bytes in a folder store, counted every 6 hours with the store-size measurement (#7690). They are 0 for other store types, and they stay at the last count until the next one. After a restart they stay 0 until that measurement |
The control plane samples local load, memory, swap and process data every 15 seconds. It
does not send network traffic for these measurements. Load above 2 per core or I/O PSI
full avg60 above 10 or memory PSI above 5 sets near. Load above 3, I/O PSI above 25,
or memory PSI above 15 sets full. These PSI lines are percentages. The level rises at
once and falls after two looks under its line. Available memory, swap, heap, goroutines,
open files and folder store size are reported, but they do not set the level. The level
does not delay or refuse work.
Alert when the copy has stayed at full for five minutes:
groups:
- name: agents-control
rules:
- alert: AgentsControlAtCapacity
expr: agents_control_capacity_level >= 2
for: 5m
labels:
severity: warning
annotations:
summary: Dragon Rider control plane is at capacity
A method name gets a label of its own for the first 300 names only. After that, the count
goes to other, so a client can't make the metrics grow without end.
Profiles. The same port, with the same token, serves the Go runtime's heap and goroutine
profiles (#6583): /debug/pprof/heap and /debug/pprof/goroutine. The port clients use serves
neither. From the VM, read what the heap holds:
docker compose -f deploy/compose.public.yaml exec control wget -qO- \
--header "Authorization: Bearer $TOKEN" 'http://127.0.0.1:9791/debug/pprof/heap?debug=1&gc=1' | head -40
?debug=2 on goroutine gives each stack in full; with no debug, the file is for
go tool pprof. deploy/README.md, "Memory", says why the compose file sets GOMEMLIMIT.
Logs. With AGENTS_CONTROL_LOG_FORMAT=json, each line of docker compose logs control
is one JSON object, from Go's log/slog, with time, level and msg. A line also has
copy, method, client_id, person_id, host_id and request_id when they apply.
AGENTS_CONTROL_LOG_LEVEL is debug, info, warn or error. At debug, each request
from a client gets a line request, with its method, result and time. A line never holds
a request's parameters, a prompt, a code, a bearer token, or a token=, secret= or
password= value: these are cut out before the line is written.
A redeploy recreates the container, and docker compose logs control starts again then.
The lines from before it are in the data volume: the control plane writes a copy of each
line to /data/control.log (AGENTS_CONTROL_LOG), rolled at 4 MB to
/data/control.previous.log and kept 7 days at most. Read them with
docker compose -f deploy/compose.public.yaml exec control tail -n 200 /data/control.log.
Set AGENTS_CONTROL_LOG= (empty) in deploy/.env to write no copy.
agents-control serve takes the same settings as flags: --metrics, --log-format and
--log-level.
Restore the disk from a snapshot¶
up.sh keeps a snapshot of the machine's disk for each of the last 7 days. The disk holds
the store, the sealed control plane key and Caddy's certificate, so a restore brings the
whole control plane back. Every window, phone and host stays paired. What changed after the
snapshot is lost: at most a day.
Run these on your Mac, in the scripts' own gcloud configuration:
export CLOUDSDK_CONFIG=~/.agents/gcloud/agents-control
zone=us-west1-b
- Find the snapshot to restore. The newest is last:
gcloud compute snapshots list --filter "sourceDisk~/agents-control" \
--sort-by creationTimestamp --format "table(name,creationTimestamp,diskSizeGb)"
- Make a new disk from it, beside the old one:
gcloud compute disks create agents-control-restored --zone $zone \
--source-snapshot <snapshot> --type pd-standard
- Stop the machine, and put the new disk in the place of the old one:
old=$(gcloud compute instances describe agents-control --zone $zone \
--format 'value(disks[0].source.basename())')
gcloud compute instances stop agents-control --zone $zone
gcloud compute instances detach-disk agents-control --zone $zone --disk "$old"
gcloud compute instances attach-disk agents-control --zone $zone \
--disk agents-control-restored --boot
gcloud compute instances start agents-control --zone $zone
- Run
deploy/gcp/up.shagain, with the options you gave before. It puts the snapshot schedule on the new disk, and checks thathttps://control.agentloops.dev/healthzanswers. - When the control plane works, delete the old disk. Until then it is kept, and two disks are more than the free tier's 30 GB:
gcloud compute disks delete "$old" --zone $zone
If the zone itself is down, make the disk from the snapshot in another zone of
us-west1 (--zone us-west1-a). The snapshots are kept in the region, not in the zone.
Then make a machine there that starts from that disk, with the flags of up.sh's
instances create, but --disk name=agents-control-restored,boot=yes in place of the
--image-family, --image-project and --boot-disk-* flags. Set zone in
deploy/gcp/common.sh to the new zone before you run up.sh again.
The image¶
Each release pushes ghcr.io/agentloops-dev/agents-control from the release workflow (#2140), for
linux/amd64 and linux/arm64, with three tags: 0.19.0, 0.19 and latest. All in it is
of the same version:
| Path | What it is |
|---|---|
/agents-control, /workspace-commands, /agents-hosted |
The control plane, the command machine provider, and the hosted service |
/web |
The web page |
/servers |
The Linux host and the MCP servers beside it, for x86-64 and ARM64 servers |
/toolsets |
The runtimes' toolsets, which a server that joins installs |
/deploy |
The compose files, the Caddyfiles and make-secrets.sh |
It is signed with cosign, keyless: the signature names the release workflow that pushed it. Check it before you run it:
cosign verify ghcr.io/agentloops-dev/agents-control:0.19.0 \
--certificate-identity-regexp '^https://github\.com/agentloops-dev/agent-loops/\.github/workflows/release\.yml@' \
--certificate-oidc-issuer https://token.actions.githubusercontent.com
The image also carries an SBOM (SPDX) and its build's provenance (SLSA), as BuildKit attestations. To read them:
docker buildx imagetools inspect ghcr.io/agentloops-dev/agents-control:0.19.0 --format '{{ json .SBOM }}'
docker buildx imagetools inspect ghcr.io/agentloops-dev/agents-control:0.19.0 --format '{{ json .Provenance }}'
The image is public, and pulling it needs no account. If the repository becomes private (#1064), the package stays public: its visibility is set on the package, apart from the repository's.
To add the CLIs that your workspace commands call, make an image of your own FROM this
one, and apk add them.
If it doesn't work¶
-
docker compose pullsaysmanifest unknown. No release has thatAGENTS_VERSION. Give a release's version, such as0.19.0, orlatest. -
The control plane stops at start with
could not find default credentials. It has no right to use the Cloud KMS key:deploy/secrets/gcp-service-accountis empty and the machine isn't a Compute Engine VM with the service account. Runmake-secrets.shagain with--service-account. - It stops with
PermissionDenied. The service account may not use the key. Give it the roleroles/cloudkms.cryptoKeyEncrypterDecrypteron the key, as above. -
It stops with
the key given is not the one sealed in the store. The store already has a control plane key, andkey sealwas given another one. Give the store's own, or start with an empty store. -
curlsays the certificate can't be verified, or Caddy's log sayschallenge failed. The name doesn't point at the machine yet, or port 80 or 443 is closed. Checkdig +shortand the firewall, then restart Caddy:docker compose -f deploy/compose.public.yaml restart caddy. - Caddy's log says
rateLimited. Let's Encrypt allows only a few failed tries an hour. Fix the cause, then wait for the time it gives. - The install command says
This machine has no CA certificates. Installca-certificateson the server, and run the command again with a fresh code. - A host's log says
CERTIFICATE_VERIFY_FAILED. The server's trusted roots are missing or out of date. Updateca-certificatesthere.
Related¶
- Run Dragon Rider with no Mac: this control plane, the web page and a codespace.
- Run the control plane as several copies.
- The control plane.
Without a container: agentsd install --control (#6610)¶
A Linux machine can run the control plane as a systemd user unit beside agentsd, as the Mac app runs two launchd jobs. It needs no root and no container. Unpack the release's agentsd-linux-<arch> tarball, then run agentsd from it:
./agentsd-linux-x86_64 install --control --no-agents --domain agents.example.com --acme-email you@example.com
--no-agentsruns only the control plane, as the VM does. Without it, the host also joins this control plane by itself, with no--join. Use both roles only on one person's machine: an agent there runs as the same Unix user and can read the control key and the store. When more than one person uses the control plane, it refuses a new host on its own machine, and the install says to run the agents on another machine (#7305). A bot is not a person. A control plane whose machine also runs agents refuses a second person (invite, sign-in or SCIM) until an admin removes that machine or moves the control plane. A team that had both roles before this rule keeps them, and its log has a warning at each start.--no-agentsis refused on a machine that already runs a host, and--joinon a machine that already runs a control plane.- To make this machine one that a team's control plane can move to, add
--joinwith a host code from the current control plane:install --control --no-agents --join <code> --domain …(#7314). The machine joins it with the control role alone. It shows to admins as a control-only machine, and the current control plane can read its memory and disk (control/eligible). It takes no sessions, folders, providers or workflows: the control plane opens no client's channel to it and refuses each request for one, and its host refuses them too. The install does not install runtimes or projects and runs no smoke session. Run the install again with agents later, and it is refused. - With
--domain, the control plane makes its own publicly trusted certificate (Let's Encrypt, TLS-ALPN-01) in the process, so there is no Caddy unit. Port 443 must reach the unit. A user cannot bind 443: forward it, or allow it once withsysctl net.ipv4.ip_unprivileged_port_start=443. The installer never asks for root. - Without
--domain, the certificate is the control plane's own, and its pin is in every code, as on the Mac. - Without
--domain, the address in each code is not the machine's hostname, because another machine cannot resolve a droplet's hostname (#7467). The install gives--addresswhen you give it: a name or IP address that other machines reach this one at, such as a tunnel's name (--address plane.tail1234.ts.net). With no--address, the install takes the machine's own IP address: a public IPv4 address on an interface, then a public IPv6 one, then the source address of its default route. A cloud VM behind NAT (GCP, AWS) has only a private address on its interfaces: when this machine joined a control plane before, the install then takes the public address that control plane saw its uplink come from (#7493). A VM that never joined a control plane gets its public address from the cloud's metadata service (GCP, AWS and DigitalOcean), which the install asks for at most 1.5 seconds (#7638). The install says which address it took. When that address is private, the install says so: only machines on the same network reach it. To reach it from elsewhere, install again with--addressand the public address or a tunnel's name. An install again with no--addresskeeps the address it took before, so the codes that you already gave stay good. A second machine then joins with a host code from this control plane (agentsd install --join <code>). - The web page is in the tarball (
web/). The install puts it in~/.agents-server/web. With--domain, the control plane serves it athttps://<domain>. Without--domain, it serves it athttp://localhost:8792on that machine only, as on the Mac. - The unit is
~/.config/systemd/user/agents-control.service. Its folder is~/.agents-control. Run the install again to change a flag. - To update, unpack the newer release's tarball and run the same install from it. The install replaces
agents-controland the web page together, and restarts the unit. - With both roles, the control plane goes first (#6613). Its unit has a higher
CPUWeightand IO priority, andMemoryLow. The drop-in~/.config/systemd/user/agents-host.service.d/10-control-first.confputs the host and its agents lower. A setting that the user manager cannot apply has no effect.MemoryLowhas an effect only when the slices above the unit also have it (root sets that). The machine's capacity level is the higher of the two roles' levels, and it keeps one core's load free. A host that already runs takes the drop-in at its next start.
The container above stays for a machine that has a container and Cloudflare in front: its Caddy also serves the second (views) name.