Operations runbook
This runbook is organized by task, so you can read only the section you need. It covers provisioning hosts, deploying Cloud Agent, protecting retained workspaces, and diagnosing job and network failures.
The control plane owns the job API, the database, accounts and admission, the MCP, GitHub and model relays, and the admin settings. Every turn runs on a model connection: either one its owner added with their own provider key, or one the deployment provides through the model relay.
Start with the task you need:
Task |
Go to |
|---|---|
Prepare a host and its credentials |
|
Start or inspect the host service |
|
Enable isolation for untrusted repositories |
|
Change application behavior, integrations, or appearance |
|
Open PostgreSQL administration |
|
Browse and filter database rows |
|
Change concurrency, sandbox settings, or placement |
|
Add a host on another machine |
|
Upgrade an existing deployment |
|
Deploy or roll back a release |
|
Apply a maintenance migration |
|
Protect workspaces and monitor disk use |
Sandbox archives, retained Docker storage, storage measurement |
Diagnose connectivity |
|
Configure or troubleshoot tools and repository access |
|
Answer a waiting agent question |
|
Investigate a task |
|
Measure startup, terminal and file latency |
|
Choose the tests for a runtime or MCP change |
|
Let owners reach their own servers |
|
Let owners run tasks on their own inference endpoint |
|
Provide shared models through the control-plane model relay |
|
Operate environments and team environments |
ENVIRONMENT.md documents configuration, and the
compute-resource runbook covers administrator-managed
SSH and CloudLab hosts. For pre-drain checks, migration regression, failed peers,
and queue alerts, use deployment reliability.
Replace every <...> placeholder before running a command.
Admin Settings
Admin → Settings holds the application and integration configuration, web
appearance, operational intervals, upload and skill limits, task titles, sandbox
and workspace limits, and sandbox archives, stored in the Agent database. It is
operator access: grant agent.admin only to people you trust to operate the
deployment, because it edits the host signing key, the account settings
(sign-up, approval, mail transport, administrator addresses) and the GitHub API
URL that GitHub credentials are sent to. Saved credentials stay write-only.
Editing settings
A group is read-only until you choose Edit. Change the fields, select Review changes, check the current and proposed values, then choose Apply changes; Cancel discards the group’s drafts, and unsaved edits survive switching categories. A credential field shows only whether a value is set: Replace secret (or Set secret) enters a new one, and an empty replacement keeps the saved value. Each field’s More actions menu offers Restore default… or Clear secret…. The Administrator setup required prompt links to required or partly configured fields.
The API is GET /admin/agent/settings and PUT /admin/agent/settings with a
partial body such as {"settings": {"max_attempts": 3}}. Add
"expected_revision" with the revision you read to have the write refused with
409 if someone saved in the meantime; the editor always sends it. Writes appear
in the Audit log.
Listeners pick up saved changes every five seconds, and each setting’s description says when a change takes effect. The web server reads the public appearance on every request, within 400 ms; when that fails, it uses the last appearance it read, or neutral defaults before its first successful read.
Settings during an upgrade
Apply migrations first (upgrade notes), then start the main
control-plane listener with its full environment. It imports the registered
environment settings once, and settings a new release adds only when they are
absent, never overwriting a saved value; the MCP-only listener waits for that
import. After that, .env values no longer matter, and resetting a field never
brings one back.
The import refuses an AGENT_CONTROL_TOKEN_SECRET or
AGENT_SOURCE_CONTROL_ENCRYPTION_KEY shorter than 32 bytes, an
AGENT_GITHUB_APP_INSTALL_URL that is not an https://github.com URL, and an
AGENT_GITLAB_OAUTH_REDIRECT_URI that is not HTTPS (HTTP on localhost is
allowed). The listener stops with an error naming the variable before anything is
written, so rolling back is safe. Replacing the control key means re-enrolling
hosts, and a new encryption key orphans saved user connections.
When a release narrows what a setting accepts, a saved value it refuses does not
stop the listeners. Each logs saved setting not applied as stored: … once per
settings revision, naming the key but never the value, and uses the built-in
default. A signing key, encryption key or service token below a new minimum
length stays in use until you replace it. Save a valid value or confirm
Restore default to clear the warning. Stored credentials that cannot be
decrypted, or are not encrypted, still stop the listener.
A new installation
A new installation needs no .env. Start the web application before you enroll
hosts or run the deployment readiness gate. From the deployment checkout:
AGENT_DEPLOYMENT_SHA=$(git rev-parse HEAD) docker compose -p cloudagent \
-f deploy/control-plane/docker-compose.yml --profile edge \
up -d --build control-plane mcp-relay web edge
The browser reaches the web app and the API on one origin, with the API at
/api. The edge profile is the nginx that splits that origin, on
127.0.0.1:3003 (AGENT_EDGE_BIND, AGENT_EDGE_PORT); point the TLS proxy or
tunnel in front of the hostname at it. Leave the profile out only when that proxy
already routes /api/* to the control plane with the prefix stripped, and
everything else to the web app.
On the bundled database, the keys service generates the database password,
AGENT_DATABASE_URL, AGENT_LOCAL_SESSION_SECRET and
AGENT_SETTINGS_ENCRYPTION_KEY into the agent-keys volume before anything else
starts (how the keys are kept);
an artifact deployment’s first prepare does the same
(release artifacts). For another database, set
those three yourself in the environment or a .env beside it, because the
keys service cannot prove such a database is new. It stores what it is given,
so you can delete the lines after one start. Back the keys up apart from the
database (Disaster recovery): the settings root key
decrypts every saved secret.
On its first start, the control plane generates its host signing key, credential
encryption keys and sandbox manager credential, and logs a one-time setup code
(agent_local_setup_pending). Then:
Open
/setup/administrator, enter the code and create the first administrator.Confirm the site address the page offers; account emails link to it.
On Admin → Servers, add the first server with Add server, which writes the host’s configuration (Compute resources).
Run the usual deployment command.
Recovery access and the settings root key
/setup is the recovery door for when no administrator can sign in. It works
only when the deployment sets ADMIN_TOKEN, goes through the ordinary
administrator API and audit trail, and keeps the token only in page memory.
AGENT_SETTINGS_ENCRYPTION_KEY is the settings root key on both listeners; back
it up apart from the database. AGENT_SESSION_SECRET is no longer read as a
root, and a start that still names it without the root key is refused: set
AGENT_SETTINGS_ENCRYPTION_KEY to its same value and remove it. Changing the
root key needs the stored settings re-encrypted and a coordinated listener rollout;
replacing the environment value alone makes existing ciphertext unreadable. The
API refuses to replace or reset an existing credential encryption key without a
separate re-encryption procedure.
Database access, the settings encryption root, recovery authentication, host provisioning, networking and listeners, host isolation, build routing, mounted files and trusted compute deployment profiles stay deployment configuration (environment inventory).
The edge and request logs
The edge profile’s nginx (deploy/control-plane/edge.nginx.conf) keeps its
connections to the control plane and the web app open between requests. It
closes an idle one after 4 seconds, before uvicorn and the web app’s Node
server would at 5. It gzips JSON answers of 1 KiB or more, except pgAdmin’s
pages, and buffers API answers in memory. The event streams
(/api/v1/agent/changes, /api/v1/agent/jobs/<job>/stream and
/api/v1/agent/jobs/<job>/terminals/<terminal>/stream) and the workspace
archive pass through unbuffered and uncompressed, because buffering and
compression can hold a stream’s events back. A proxy that takes the edge’s place
must treat those paths the same way. Every event stream also sends
X-Accel-Buffering: no, which nginx obeys on any path.
There are two request logs:
Each listener’s uvicorn access log, in its container’s log, for example
docker compose logs control-plane. It has every request: those the hosts send over their tunnels and those the web app’s server sends, which never pass the edge, as well as the browsers’. WithAGENT_LOG_FORMAT=jsonits lines are JSON too.The edge’s access log, in
docker compose logs edge. It has only the requests browsers send through the edge, in nginx’smainformat: the client’sX-Forwarded-Foras the front reported it, the status nginx answered, the bytes sent and the user agent.
Docker keeps each service’s log in json-file files of at most 100 MB, five per
service, and deletes the oldest. docker compose logs shows only what is still
kept, so ship the logs elsewhere to keep them longer. A service’s own logging
takes precedence over the Docker daemon’s defaults (log-driver and log-opts
in /etc/docker/daemon.json). To keep another driver or other sizes, set them
for each service in the Compose override
(AGENT_CONTROL_PLANE_COMPOSE_OVERRIDE_FILE): other sizes merge with these
options, and a different driver replaces them.
Sandbox archive storage
Archive to S3 and delete writes to the bucket and region of the
Sandbox archives policy (Sandbox archives), so it is
available only while that policy is enabled. While it is disabled, an
administrator can only discard a sandbox, and a deleted chat’s sandbox is retired
without an archive. Each request writes one object,
s3://<bucket>/cloud-agent/sandbox/deletion/<sandbox>/<request>/archive.tar.
The control plane signs and verifies the upload with the policy’s saved access
key or, without one, its standard AWS SDK credential chain, preferably an IAM
workload role. That identity needs s3:PutObject and s3:GetObject on
arn:aws:s3:::<bucket>/cloud-agent/sandbox/deletion/* (the lifecycle grant on
cloud-agent/sandbox/* already includes both), plus kms:GenerateDataKey and
kms:Decrypt on the key if the bucket applies SSE-KMS by default. It does not
need s3:DeleteObject. A policy’s expected bucket owner is asserted on the
HeadObject.
For environment or shared-profile credentials, create a private Compose override for the main service; the base Compose forwards no AWS variables. For example:
services:
control-plane:
environment:
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID:?Set the archive access key}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY:?Set the archive secret key}
AWS_SESSION_TOKEN: ${AWS_SESSION_TOKEN:-}
Keep the override outside the checkout and set its absolute path as
AGENT_CONTROL_PLANE_COMPOSE_OVERRIDE_FILE in the deployment root’s .env; the
deployer applies it after the release’s own overlays, in source and artifact
modes. For shared profiles, mount the files read-only and set
AWS_SHARED_CREDENTIALS_FILE, AWS_CONFIG_FILE and AWS_PROFILE. Neither path
gives AWS credentials to sandboxes, the web app or the MCP relay.
The host gets a 15-minute presigned PUT with a fixed byte length, a full-object
SHA-256 and If-None-Match: *. An archive over 5 GiB is refused and the
container kept, and a retry after a successful upload can get HTTP 412. Before
deleting, the control plane reads HeadObject with ChecksumMode=ENABLED and
requires the exact SHA-256 and length that S3 verified; ETags and supplied
metadata do not count.
Use a private bucket with public access blocked, encryption, retention and recovery access. Other principals must keep the objects immutable too: a bucket policy can require conditional writes, and versioning or Object Lock protect further. Do not expire an archive that a deletion or recovery may still need. The receipt records the original S3 URI, SHA-256, length and version, so changing the bucket does not redirect verification of an existing request.
Database browser
Admin → Database browses the Agent database in the dashboard: select a table,
add filters (combined with AND; Contains matches a literal, case-insensitive
substring), choose a sort column and page size, then select Run query. It
shows only reviewed metadata columns, never stored credentials, raw user content
or opaque configuration documents. Queries are read-only, parameterized, bounded
and time-limited, each checks current agent.admin, and outcomes appear under
Audit log → Database without filter values or returned data. The API is
GET /admin/agent/database/tables and POST /admin/agent/database/query. For
writes and arbitrary SQL, use pgAdmin.
pgAdmin
Admin → Database → Open pgAdmin opens pgAdmin through the same-origin API
proxy, so the public edge needs no new route. Every request needs current
agent.admin. pgAdmin keeps its own login and CSRF checks, and Agent cookies and
bearer credentials are never sent to it.
To enable it, add this to the control-plane deployment’s .env, keeping any
existing profiles (for example COMPOSE_PROFILES=edge,pgadmin), and run the
normal deployment:
COMPOSE_PROFILES=pgadmin
AGENT_PGADMIN_BOOTSTRAP_URL=http://pgadmin:5050
AGENT_PGADMIN_BOOTSTRAP_DIR=/var/lib/cloud-agent/pgadmin-bootstrap
On an existing stack, this starts the service and applies the new control-plane environment (for an artifact deployment, use the release-generated Compose file):
docker compose --env-file .env -f <selected-compose-file> up -d pgadmin control-plane
Then open Admin → Database, choose an administrator email and a password of
at least 12 characters, and wait for Open pgAdmin. Only a current Agent
administrator can complete setup, and no account or default password is shipped.
Setup saves the connection under Admin → Settings → Operations (Database
tools) if none is saved. The public URL defaults to the web base URL plus
/api/admin/agent/pgadmin/; for another prefix, set
AGENT_PGADMIN_BOOTSTRAP_PUBLIC_URL before setup. Keep the
agent-pgadmin-bootstrap and agent-pgadmin volumes across deployments.
Sign in with the email and password you chose. The server definition points to
postgres:5432, with the database and user named by AGENT_POSTGRES_DB and
AGENT_POSTGRES_USER (both cloudagent by default); enter the database password
when you connect. pgAdmin imports that definition only once, so after changing
either variable, edit the connection in pgAdmin.
Private pgAdmin URL can only select a pgAdmin the deployment names: the
bundled http://pgadmin:5050, or the scheme, host and port of
AGENT_PGADMIN_URL or AGENT_PGADMIN_BOOTSTRAP_URL in the control plane’s
environment. Any other saved URL gets 503 without being contacted, because the
proxy forwards every method, path and body and could otherwise reach a cloud
metadata endpoint or another private service. To run pgAdmin elsewhere, set
AGENT_PGADMIN_URL, restart the control plane, select the same address, and keep
the variable set.
Security. pgAdmin runs on the Agent’s origin, where the administrator’s
session authorizes every admin route. The proxy therefore adds a second
Content-Security-Policy that keeps pgAdmin’s fetches, forms, frames and
workers under its own path, plus frame-ancestors 'self', nosniff,
X-Frame-Options: SAMEORIGIN and Cross-Origin-Opener-Policy: same-origin.
This narrows what an injected script could do, but it is not an origin boundary:
pgAdmin shares the origin’s browser storage, and only a separate origin would
remove the shared session, which this release does not provide. Keep the pinned
image and its default security headers, enable the profile only where it is
used, and grant agent.admin only to operators. pgAdmin connects as the database
owner, and the Agent audit log records no SQL (only
agent.database.pgadmin.setup and agent.database.pgadmin.open), so treat
pgAdmin access as full database access.
Troubleshooting. For the HTTP-only local stack, set
AGENT_PGADMIN_COOKIE_SECURE=False. If the dashboard reports pgAdmin
unavailable, check docker compose logs pgadmin. Before setup, the container is
healthy and logs Waiting for first-time setup in Admin -> Database.; after
setup, unreadable bootstrap storage or an unavailable PostgreSQL stops it. A
setup that cannot write the bootstrap volume is recorded as failed: fix the
volume and set up again. To turn access off, reset Private pgAdmin URL;
removing the profile keeps the volume.
What a job does
POST /v1/agent/jobs owner queues work
→ enrolled host claims exact shared-live capability attestation
→ runner creates/starts one retained Docker group and its writable layer
→ native Agent CLI one live process/session per member chat
→ normalized events streamed to the owner over SSE
→ model calls the owner's provider, on their own key
→ push and pull request git/gh as the owner, through the GitHub relay
→ turn settles the workspace stays in the retained sandbox
The platform never pushes or opens a pull request itself. When the owner asks, the agent does, as the owner, through the GitHub relay, and the pull requests it opens are recorded for the conversation (Resume, Fork, and pull requests). Watch PR and merge asks the agent to merge once required checks and reviews pass; the repository’s GitHub rules decide what may merge without a person.
Credential boundaries:
No repository credential enters the sandbox. The owner’s GitHub token stays in the control plane for the GitHub relay. The runner’s clone credential is read-only, scoped to one repository and never written to
.git/config(it travels in git’s environment), and the runner refuses to start the agent if it finds the token anywhere under.git/.git and
ghact as the owner without the owner’s token. A member’sGH_TOKENis its residency’s placeholder, which only the GitHub relay accepts.Model and MCP credentials are narrow. The CLI runs on the owner’s provider key, handed over only in that owner’s claim and residency, or, on a provided model, holds only a placeholder that the model relay accepts. Its residency’s MCP credential reaches only the MCP relay, and there only the servers the conversation’s bindings authorize, while the residency serves a running turn. Neither can write the event log or end the job; only the runner’s token can.
There is no per-job spend cap and no local quota. The provider keeps the key’s quota and bill.
Temporary workspaces
A job created with "repo": null starts a conversation without a repository.
Any user with agent.use may create one, and its claim carries no clone or
GH_TOKEN credential. The host makes /workspace a new Git repository on main
with one empty commit, the same on every host
(77bbec2039abcd5c7663078db4f90f3c860a751a), which becomes the job’s base. A
request that also names base_ref, base_sha or environment_id is refused.
The GitHub relay sends the agent’s requests without credentials and records no
pull request. Everything else (archive, delete, Fork, Side Chat, goals, MCP,
retention, checkpoints, S3 archiving) works as for a repository chat, but no
project memory is built. temporary=true on GET /v1/agent/jobs,
/conversations and /sessions lists only these conversations and cannot be
combined with repo. While a configured GitHub App cannot be loaded, creating
one answers 503, like any job.
GET /v1/agent/jobs/{job_id}/workspace/archive downloads any retained chat’s
/workspace as a gzipped tar. The host compresses it to disk first, so a
workspace over workspace_download_max_mib (default 1024 MiB, before
compression) is refused with 413 instead of arriving truncated.
Conversation titles
A new conversation is titled with its prompt’s first meaningful line, cut to Maximum task title length (36 characters by default; under Advanced on Admin → Settings → Content). The owner can rename it; follow-ups keep the name, and forks inherit it. No model is asked for a title.
Conversation status and run history
The UI shows Queued, Running, Idle or Failed. A running turn wins
over queued ones; otherwise the latest turn decides, and completed and
user-stopped turns leave the conversation idle. The owner API reports this as
conversation_state, separate from the selected job’s state. A turn’s
execution history appears only when it had several attempts, and viewing history
never restarts or moves a task.
Native agent questions
Claude Code AskUserQuestion, Codex user-input requests, and OpenCode/Kilo
questions open a dialog while the turn waits; submitting continues the same
native tool call. Answer later closes it, Review question reopens it,
and Skip declines. Claude Code ExitPlanMode uses the same dialog:
Approve plan lets Claude leave plan mode, and Skip asks it to keep
planning. Pending questions are read from the resident agent, so a reload finds
them again. An answer names the job, attempt and request, both the API and the
host fence it, and answers are never queued as follow-ups.
Deploy the runner, Sandbox Manager and rebuilt sandbox image together. The
http-agent-live-bridge helper pin is 5
(native conversation recall), and anything older fails the
turn-time attestation. Before starting a replacement OpenCode/Kilo process, the host
installs its trusted bridge into the retained container, keeping the workspace
and native sessions.
Who may run a job against which repository
A repository needs at least one entitlement, the user’s GitHub connection or the deployment allowlist; job creation fails closed without one.
User connection. The user authorizes the GitHub App through the frontend
callback. The control plane exchanges the code for a user token, records the
account in agent_github_accounts, and stores the installations GitHub reports
in agent_repo_grants; reconnecting removes grants the user can no longer reach.
The composer, job creation, claims and workspace reads check repositories
as the user through /user/installations/{id}/repositories, and only
repositories the user can push to qualify. The answer is cached per user for
GitHub repository cache duration (60 seconds by default; under Advanced on
Admin → Settings → Source control). Do not replace this
check with an installation-token listing: GitHub can report an organization’s
installation to a collaborator who can see only one of its repositories, and the
installation token would expose the rest.
The user token stays in the control plane, encrypted with
AGENT_SOURCE_CONTROL_ENCRYPTION_KEY. GitHub App user tokens last eight hours,
with a six-month, single-use refresh token; refresh starts five minutes before
expiry under a row lease. A connection without a usable token grants nothing, and
the composer asks the user to Connect GitHub again. Connecting and installing
the App are separate steps: if the App is not installed on the user’s own
account, the connect flow offers GitHub’s installation page (the user can choose
Not now), and Configure repositories and
Configure repository access open the same page.
Deployment allowlist. AGENT_REPO_ALLOWLIST (comma-separated owner/name or
owner/*) is for single-tenant use. It is not per user: every admitted user may
have the platform clone every listed repository with the deployment’s App, so
list only repositories all of them may work on. It grants no push; pushes and
pull requests always use the owner’s own connection. When the App’s OAuth
credentials and AGENT_GITHUB_APP_INSTALL_URL are configured, the composer still
requires a connection before any repository can be chosen; until then a task
runs in a temporary workspace.
Disconnecting. Disconnect GitHub under Integrations deletes the account, token and grants and asks GitHub to withdraw the authorization. Uninstalling the App revokes the platform’s installation access.
Sandbox inventory, resource usage, and controls
The admin Sandboxes tab lists every group recorded as running, including
containers retained between turns; the state filter adds stopped, starting,
stopping or failed groups, and Fork members share one row. It refreshes every 30
seconds from GET /admin/agent/sandboxes (default state=running; state=all
for every state). Search covers titles, repositories, owners, hosts, agent
versions and container identifiers, and combines with the host and activity
filters; unchecking Auto-refresh pauses polling. A sandbox’s details show its
member sessions, host, runtime, container identity and lifecycle, but no native
session identifiers, credentials, prompts or raw container diagnostics.
Stopping an idle sandbox
Stop idle sandbox stops the shared container for every member of the group and keeps its workspace and native sessions for a later turn. The API checks the reviewed container, generation and last activity, and refuses a busy group, a group with open terminals, and one whose terminal observations are stale; the host repeats the idle check before stopping. When the terminal report is zero, missing or older than 90 seconds, the details (and a stop request) ask the owning sandbox manager for the group’s terminal count directly. An unavailable sandbox manager or unknown activity keeps stopping disabled, and the page shows the recovery step. The request is audited and shown as pending until a host observation confirms the stop, so an offline host cannot complete it, and new turns wait meanwhile. Stopping neither deletes the container nor frees its disk.
Deleting a sandbox
Archive to S3 and delete removes a stopped or dead, idle container after its
whole retained filesystem (manifest.json and container-rootfs.tar, with the
workspace and native session files) has been uploaded to the
Sandbox archives bucket and verified
(Sandbox archive storage). New turns, Fork and
workspace operations wait while the archive is prepared. An archive over 5 GiB
is refused, and a failed upload keeps the container. The host removes the
container only after the object’s SHA-256 and length match and the receipt is
committed; if the host reports the container missing or changed first, the
request fails for operator review. Once an archive is verified, an uncertain
deletion acknowledgement keeps admission blocked and retries the same request,
and the sandbox manager keeps its deletion receipts on its persistent volume
across restarts.
Delete without archive removes the same container without uploading
anything, and needs no bucket. The host still refuses a running, busy or changed
container, and native resume is marked lost only after the host confirms
removal. While the host is offline or removed from the pool, the details say so,
and what ends the wait: the host reconnecting, or being enrolled again. The
exception is a host whose server its provider confirmed terminated: after 10
minutes of silence, the container is taken as gone with the machine and the
deletion finishes without it (host_reclaimed in the trajectory and audit),
even after automatic retries have stopped. Let a pending or verified archive
deletion finish or fail before you choose this action.
A cold sandbox lives only in its
checkpoint, so
Archive to S3 and delete refuses it. Delete without archive deletes it at
once, with no host call, once the host it names is gone (removed, forgotten, or
silent for 30 minutes). One transaction marks it lost and deleted, marks its
chats’ native context lost, fails their queued turns and supersedes its
checkpoint receipts (checkpoint_only). The checkpoint objects stay in S3 under
the bucket’s lifecycle rules; the control plane deletes no objects. Until the
host is gone, the next message to one of its chats restores it, and
Remove stale entry can hide it.
Sandboxes of deleted chats are removed automatically. When an owner
permanently deletes the last chat in a sandbox on an online host, a sweep that
runs every minute (actor user-deletion-sweeper, source system) stops it and
queues its deletion, archived first while the Sandbox archives policy is
enabled. A sandbox that
another chat still uses is never touched.
Verify stopped and force delete recovers a sandbox still recorded as
running, but only when the owning sandbox manager confirms that the container is
stopped or dead, and idle. On failure, the error names the cause (missing host
registration, an absent or refused advertised URL, a missing or rejected sandbox
manager credential, a connection failure, a timeout, or unavailable status), and
the control plane logs agent_sandbox_delete_verification_failed. For a
connection failure, check the
reverse sandbox manager route.
Deletion keeps chat history, memberships, execution records and audit receipts, but deleted native sessions cannot resume. Each row shows a deletion as pending, failed or deleted, and a finished one leaves the default inventory (Include removed sandboxes lists it).
How requests run. One worker handles deletion requests one at a time, in order. Only transient failures retry, with backoff from one minute to one hour, for up to eight claims or 24 hours. A stopped request stays fenced. After you fix the cause, Resume deletion starts a new retry window for the same request, keeping its archive or discard choice and any verified receipt. The details show each request’s attempts (host, last confirmed stage, outcome, failure code); this history is best-effort and never holds up a deletion.
Removing a stale entry
Remove stale entry is available when the owning host has not reported for more than 90 seconds. It hides the entry from the default inventory without contacting the sandbox manager, so a retired host does not leave an entry that can never be cleared. The server refuses it while turns, workspace operations or a deletion are active. It keeps every record and deletes nothing: no container or file is removed, no archive is made and no disk is freed, so restore the sandbox manager connection to finish archival and deletion. Undo it with Include removed and Restore to inventory; a matching host observation or new work also brings the entry back. Remove from inventory is the same reversible visibility control for stopped sandboxes.
Batch operations
Select rows, or Select all visible sandboxes (only what the current filters show), choose an action, then Review selected sandboxes. The review reads each sandbox’s current details and lists blockers. One confirmation then applies the action to the eligible entries, with the same checks as the individual controls, up to four at a time. A stop or deletion result means the request was accepted (a cold sandbox’s deletion is done at once). Skipped and failed entries say why and stay selected, and expired reviews and changed containers are refused.
Resource measurements
CPU is occupied cores between Docker samples, memory excludes inactive file cache, and network and block I/O show cumulative counters and rates, all for the whole shared container. The details also show process and terminal counts, session capacity, active operations and sandbox age (counted from group creation, not container uptime). The sandbox manager samples Docker in the background and sends the observations with the heartbeat, each keeping its original age. Readings older than 90 seconds are marked stale and left out of the fleet totals, which show their coverage; a current heartbeat does not mean current measurements. Only the latest observation is stored, so there is no resource history.
The owner’s Usage page
Settings → Usage (/settings/usage) shows each owner their own containers,
what the running ones use now, and what their work used over the last 7 or 30
UTC days. It reads three owner-scoped routes, none of which names a host,
container ID, image or generation:
Route |
What it reads |
|---|---|
|
Containers behind chats the owner has not deleted, active first, with limits and the latest sample of a running one. Fresh samples (90 seconds) are summed into current CPU and memory. |
|
For |
|
The admin Usage aggregation over the same range, filtered to the owner’s runs: reported tokens and turns by bucket and by model (see Usage). |
Running time counts the starting, running and stopping states. Each
accepted sample adds the time since the
previous one (at most 120 seconds), and its CPU and memory over that time, to the
container’s rows for the UTC days it covers, split at midnight. The page shows
how much of the running time the measurements cover, and that its days are UTC.
It shows no disk usage and no cost.
Usage
The owner’s Usage page, the admin Usage page (/admin/agent/usage), a run’s
usage footer (/v1/agent/jobs/{id}/usage) and the admin run detail all show the
tokens each turn’s agent reported about its own model calls
(source: "runtime_reported"; the per-job read’s runtime.source is
"runtime"). They are not a provider bill, and these pages hold no pricing,
quota or billing. Several accounts using keys of one provider account share that
account’s allowance. The model relay keeps its own record of provided-model use
(Provided models).
Each attempt’s events are reduced into an agent_attempt_thread_stats rollup
(reducer version 3), stored with the state of its reduction, so a later read
reduces only the events after it: the usage a run’s footer is pushed after each
model call does not read the turn again. A repeated report counts once, a
retry’s attempt counts as its own report, and a Fork’s copied history is not
counted again. A turn that reported nothing shows as pending, then unavailable,
never as zero.
Agent |
What it reports |
Input total |
|---|---|---|
Claude Code |
Anthropic counters per response: uncached input, cache reads, cache writes, output |
The three input counters added |
pi |
The same counters per assistant message |
The three input counters added |
Codex 0.145.0 |
|
|
OpenCode, Kilo |
No verified counter shape; any counter they emit is shown as reported |
Unknown |
Only Codex reports reasoning tokens, which are part of the output and shown beside it. No agent reports a cost or a request count, so those are always null.
What is not counted. Codex reports each model call with its thread’s running total. A call counts toward a turn only when the notification names that running turn, or comes from a subagent spawned during it. Calls from a subagent after its turn ended, or spawned in an earlier turn or process, notifications replayed on resume, and malformed reports count nowhere, so a provider can bill more than the totals show. The pages say so where the numbers appear.
Operation measurements
Admin → Measurements times sandbox startups, terminal opens, and file
listings and reads while an administrator has turned collection on, and shows
the timings and samples below its switch. It needs no configuration; the
profiling variables
can override who controls it. The page uses
GET /admin/agent/profiling-control, POST /admin/agent/profiling-runs and
POST /admin/agent/profiling-runs/<run>/stop, and the audit log records every
Turn on and Turn off under measurements.
Turn on asks what to measure (Sandbox startup, Terminal opening, File access) and where (one online or draining host, or All hosts), then collects until Turn off, whether or not the page stays open.
Samples come only from real use. Sandbox startup times each claimed turn from its claim to the prompt reaching the agent; the other two time opening a terminal and listing or opening files in a workspace. The switch starts no work of its own. One terminal interaction can store several samples.
Turn off stops selecting new operations. Measurements already under way finish, and stored samples stay.
The status line is the stored configuration, not what every process has applied. The control plane applies a change at once; each runner picks it up at its next sync and passes it to its sandbox manager, so a host can take about 30 seconds to start collecting and about 5 seconds to stop. A runner that cannot reach the control plane keeps its last configuration until it can.
No switch. Measurement set by deployment configuration means the control plane is in environment mode (
AGENT_OPERATION_PROFILING_MODE=environment): a static run descriptor decides, and the deployment may still be collecting. Measurement unavailable means profiling is disabled on the control plane (AGENT_OPERATION_PROFILING_MODE=disabled, or an invalid value).
Reading a task’s recorded events
The admin console shows tool-call measurements and reported token usage, but has
no route to a task’s raw runtime events; owners read their own through the
session routes. Do not read agent_job_events.payload directly. A psql
query returns prompt text, tool arguments and tool output with no audit record,
no size bound and no column allowlist. If an investigation needs raw events,
build an audited route.
The audit trail. Admin → Audit log (GET /admin/agent/audit-log) shows who
did what, to whom, with what result, newest first, paged by before (the oldest
id of the previous page). Each action is declared once in
cloud_agent/domain/audit.py, with a category (accounts, settings,
servers, sandboxes, measurements, sensitive_access, access_control),
its target (target_type, target_id) and the user it affected
(target_user_id).
Who acted (
actor_type, derived fromactor_id):admin,break_glass(ADMIN_TOKEN, first-run setup, the bootstrap command),service,system,useroranonymous. The page showsadminandbreak_glassunless asked for everything (actors=all); break-glass access is always shown, in red.Names are kept as they were when the row was written, with a short id beside them. Erasing an account deletes no audit row.
Outcome is
applied,refused,failed,replayed, orrequestedfor work that runs later. A requested sandbox deletion or compute operation carries its final result; the worker’s steps are in the sandbox’s trajectory.Filters.
user=<account id>shows everything about an account, andtarget_type=withtarget_id=everything about one host, sandbox or server operation.Recording never blocks an action. A row that cannot be written is logged as
agent_admin_audit_write_failed, counted inagent_admin_audit_write_failures, and reported at the top of the page for seven days.
Reads and connection checks are not recorded.
Teams
Owners and admins manage their teams from Settings → Teams. Platform administrators see every team, read-only, under Admin → Users → Teams:
The list (
GET /admin/agent/teams) shows teams newest first, with the owner, active members, admins and pending join requests.stateisactive(default),deletedorall;qmatches part of a team name, a team id, or the user id of anyone who has been a member. It pages withbefore(the response’snext_before).A team’s page (
GET /admin/agent/teams/{team_id}) lists the active members, the 50 most recent departures (departed_member_countcounts them all), the 50 oldest open join requests (pending_request_count) and the invitation link counts.GET /admin/agent/teams/{team_id}/audit-eventspages the team’s audit history withbefore.
Show in People opens a team’s members in Admin → Users → People. Names and emails are read on each request and never stored. These pages change nothing, so they leave no audit record. You cannot yet move ownership of a team whose owner lost access.
MCP servers
MCP calls pass through the control plane. The sandbox holds only a scoped relay credential; upstream credentials stay outside it:
sandbox ──[residency mcp credential]──▶ MCP-only relay ──[owner credential]──▶ MCP server
A member’s CLI serves several turns, so it holds its residency’s credential
(amr.…). On every call, the relay resolves it to that chat’s current attempt
and checks that the attempt is leased, its job running and not stopped, and its
host enrolled. Between turns, or once the residency rotates, expires or is
released, it authorizes nothing. A follow-up whose MCP servers did not change
keeps the live process; adding or removing a connection restarts it, because a
CLI reads its servers once, at start. A request keeps the attempt and residency
it was authenticated with, and the relay checks both again after waiting for
OAuth, an approval or an upstream session. Memory writes, Web Search admission
and approval claims also check the residency inside their transactions.
Listeners and connections
The MCP listener is a separate FastAPI app on port 8001 that serves only the MCP
tool surface. Sandboxes reach /v1/agent/mcp on it over the MCP tunnel on their
group bridge.
Keep the tool relay off the public main API. The public edge forwards
/api/* to port 8000, where no tool route is mounted, so a leaked MCP credential
cannot be replayed there. Connection management, OAuth callbacks and approvals
also use the /v1/agent/mcp prefix and must stay on 8000, so do not block the
whole prefix at the edge. Point the sandbox MCP tunnel at 8001.
Users add connections through /v1/agent/mcp: a remote URL, an imported
mcpServers snippet, or a stdio launch specification. agent_mcp_connections
stores the configuration and the credential, encrypted with
AGENT_SOURCE_CONTROL_ENCRYPTION_KEY under an MCP-specific domain, and
discovery stores a capability snapshot. Templates only prefill the form. MCP
OAuth uses AGENT_MCP_PUBLIC_BASE_URL for the API callback and
AGENT_WEB_BASE_URL for the browser’s return to /settings/plugins, for example
https://agents.example.org/api and https://agents.example.org.
Of the optional protocol capabilities, the platform answers only roots. When a
server offers elicitation, sampling, resource subscriptions, tasks or MCP Apps,
the connection’s diagnostics mark them unsupported.
End-to-end coverage
tests/external/test_agent_mcp_end_to_end.py runs a real listener, a migrated
Postgres, the image’s pi 0.73.1 CLI (or the release named by
AGENT_PI_TEST_VERSION) and the shipped bridge, against stub model and MCP
servers. It checks that the model sees session__github__get_issue, that the
upstream receives server/discover, initialize and tools/call with the
connection’s credential instead of the sandbox token and with the tool name
get_issue, and that a handshake follows when the era probe returns -32601.
It needs Postgres, npm and network access, skips without them, and belongs to
the external tier. Run it after changing the merged endpoint, host or bridge.
Where a connection runs
An address runs as a remote service behind this relay, and a command as a
sandbox program (sandbox MCP servers); the API refuses
any other location.
Deployment and rollback
Apply migrations through head before replacing the API, then deploy the runner and sandbox artifacts from the same release; MCP is on for every runtime.
Before launching members, the runner upgrades retained containers’ adapter files
and the patched Kilo 7.4.17 (built from the revision and patch recorded beside
build-kilo.sh; another version needs a reviewed build), and installs Codex’s
system allowlist, with no host bind mount or extra capability. A rollback must
keep a schema-compatible service and the migrated data; fix forward when a
downgrade would discard them. MCP credentials share
AGENT_SOURCE_CONTROL_ENCRYPTION_KEY with source control, separated by domain.
Runtime boundaries
Claude Code retries transient inference failures (HTTP 429 and 5xx) within the
native request. The resident launch sets CLAUDE_CODE_MAX_RETRIES=15 and
CLAUDE_CODE_RETRY_WATCHDOG=0, and the pinned CLI backs off from 500 ms to 32
seconds plus up to 25% jitter, honoring an integer Retry-After of up to 60
seconds. Retries keep completed tool calls and the native session; when they run
out, the turn fails with its context kept, and the runner never resends the
prompt. HTTP 400 and 403 are not retried, and 401 keeps the CLI’s own credential
refresh. The runner’s execution timeout still bounds the turn, owner
cancellation still interrupts a backoff, and the chat shows each retry.
An adapter declares MCP support only after both behaviors are checked against the pinned binary: it points the CLI at the platform relay, and it stops every other MCP configuration source from adding servers. A job that names connections on a runtime without MCP support is refused at creation.
Runtime |
Pin |
How the relay reaches it |
Why the repository cannot add servers |
|---|---|---|---|
|
2.1.220 |
|
|
|
1.18.9 |
the reviewed |
the wrapper exports |
|
7.4.17 |
the reviewed wrapper configures the authenticated merged relay for run and serve; the live bridge verifies connection before reporting ready |
the pinned build patches the legacy MCP loader to honor |
|
0.145.0 |
exec and app-server share the merged relay URL and token environment reference; app-server verifies MCP startup |
trusted guest-root bootstrap atomically installs the deployment’s exact relay URL as the sole server identity in |
|
0.73.1 |
the reviewed |
|
Use the runtime’s credential-reference syntax. Claude Code expands
${AGENT_MCP_TOKEN}, and the OpenCode family substitutes
{env:AGENT_MCP_TOKEN}; the wrong syntax sends a literal placeholder as the
bearer token and gets 401. The adapters in
apps/backend/cloud_agent_host/runtimes/ choose the address, and the CLI
adapters in deploy/sandbox/ write the reference. The token travels in the
environment, never in argv or a configuration file.
What --strict-mcp-config is holding shut
Always pass --strict-mcp-config with --mcp-config, even for an empty platform
configuration: it makes that configuration Claude Code’s only source of MCP
servers. Without it, a committed .mcp.json loads with no prompt under the job’s
configuration (headless -p, bypassPermissions, a checkout as the working
directory).
Sandbox browser
The sandbox image ships headless Chromium and cloud-agent-browser, a root-owned
launcher that runs one browser per sandbox. cloud-agent-browser start returns a
CDP WebSocket URL for Playwright (connectOverCDP, Playwright MCP
--cdp-endpoint), Puppeteer (browserWSEndpoint) or Chrome DevTools MCP
(--wsEndpoint).
Shared by the sandbox. A chat and its Forks share one browser, tabs and sign-ins included. It runs as
agent-browser(uid 10002), so a member’s turn-end reap never stops it. The host runscloud-agent-browser service startbefore each member launch, and a failure never blocks the chat.Isolation. Chromium speaks CDP only over a pipe to the launcher, which serves it on loopback behind a random token in
/run/agent-browser(written only byagent-browser, readable only by the sandbox group). Clients cannot reach each other’s CDP sessions.Chromium’s own sandbox is off. Docker’s default seccomp profile refuses the user namespaces it needs, under runc and Kata alike, so Chromium runs with
--no-sandbox, and the container and the Kata VM are the boundary.cloud-agent-browser statusreportschromium_sandbox.Downloads are staged by the service and copied into the member’s private download directory. One that cannot be handed over shows as canceled, and the service log says why.
Lifecycle. Chromium starts with the first client and stops after 15 minutes without one (
CLOUD_AGENT_BROWSER_IDLE_S). The profile (/home/agent-browser/profile) stays in the retained container, andcloud-agent-browser stopcloses Chromium for every member.Resources. About 174 MiB and 140 threads idle, and 321 MiB and 213 threads with four pages open, counted against the group’s memory limit and its 512-process limit, which counts threads. At most four renderer processes run.
Screenshots go to
/workspace/.cloud-agent-artifacts(CLOUD_AGENT_ARTIFACTS_DIR), which is listed in.git/info/exclude. A turn shows the images written there (GET /v1/agent/jobs/{job_id}/artifacts/images, up to 200), andGET /v1/agent/jobs/{job_id}/files/imageopens PNG, JPEG, GIF and WebP files of up to 10 MiB.
To check a host, run cloud-agent-browser status and cloud-agent-browser self-test
in a sandbox; the image build runs the self-test too. /run/agent-browser/daemon.log
has the service’s log. A container created from an image without the browser has
none until it is recreated.
Sandbox MCP servers
An MCP connection can run in each chat’s sandbox (location sandbox), where it
reaches the task’s localhost, files and the sandbox browser; the Playwright and
Chrome DevTools presets drive that browser.
What may run. One exactly pinned package started by
npxoruvx, with no mount or working directory. An import pins a bare name, or a tag such aslatest, to the release the public registry names at that moment (cloud_agent/mcp/package_pins.py); a range or an unknown package is refused.Credentials. Keys pasted with it are sealed at rest and named
secret://NAME, and${NAME}is filled from the chat’s environment. The host hands both only to the slot’s runner, in/run/agent-mcp-slots/<slot>/secrets.json, which only that runner’s user can read. A sealed key shorter than 8 characters is refused, because the runner masks only longer keys. An edit keeps the stored keys only while the command and arguments stay the same apart from the package release; any other change must send the keys again.How it runs. Before launching a member’s CLI, the host writes the slot’s admission as root, starts the image’s MCP gateway,
cloud-agent-mcp, asagent-mcp(uid 10003) onhttp://127.0.0.1:47801/mcp, then starts the slot’s runner asagent-mcp-<slot>(uid 12001 + slot). The CLI reaches the servers as the MCP serversandbox, with its relay token. A server affects only its own slot, and a failure leaves the chat without those tools but still runs the turn.No approval step. The relay’s per-tool policies do not apply: a sandbox server can do what the agent’s shell can. Changes take effect at the next turn.
Where to look.
/run/agent-mcp/gateway.logrecords the methods each slot called (readable asagent-mcp);/run/agent-mcp-slots/<slot>/runner.logand/run/agent-mcp-slots/<slot>/<alias>.logare readable asagent-mcp-<slot>; admissions are in/run/agent-mcp-admissions. When a CLI lists a slot’s tools, the gateway reports them to the relay (cloud_agent/sandbox_tools), and the connection’s card shows them.
Sandbox incidents
The host records what goes wrong in each retained sandbox as incidents in the sandbox’s event list, and the sandbox list shows the newest one within a day under the sandbox’s name.
Kinds.
out_of_memory(the OOM killer killed a process),container_exited(adienobody asked for),memory_highandpids_high(a reading at 90% of the limit),browser_crashed, andmcp_server_failed(a sandbox MCP program could not start or exited on its own; it names the chat and the server). A stop or deletion the platform made is not an incident.Repeats. Repeats of a kind within a minute become one
.repeatedrow with a count. A sandbox records at most 60 rows an hour, and onedroppedrow counts the rest.What people see. A running chat shows a line for
out_of_memory,container_exitedand its ownmcp_server_failed, and the agent’s next prompt lists what happened since it was last told.Contents. Kinds, times, exit codes, limits and MCP aliases only: no stderr, URL, command line or environment.
Where to look. The browser service journals to
/run/agent-browser/events.jsonl, and each slot’s runner to/run/agent-mcp-slots/<slot>/events.jsonl. The sandbox manager reads them every minute and holds the rows until a heartbeat answer saysincidents: "accepted".
Before a job can run for real
Provision each host, check its network, enroll it and set up the credentials before enabling job claims.
0. The sandbox network needs its host rules, a resolver and its relay
Every sandbox group runs on its own routable bridge, the same for setup, the
agent and each Fork sibling. This deployment’s host nftables tables decide what
it reaches: public IPv4 on TCP 80/443, the resolver in AGENT_EGRESS_DNS_SERVER,
the group’s relays (MCP, plus the model and GitHub relays where configured) and
the SSH servers its owner enabled, and nothing else. There is no mode to choose
and no setting that opens it further. The sandbox network
has the full rule set and what each refusal means.
Before it can run a job, a host needs:
AGENT_EGRESS_CHAT_NETWORK_POOLandAGENT_EGRESS_DNS_SERVER. Neither has a default: the pool must be this deployment’s own, and the resolver is the only DNS a sandbox can use.The MCP relay on the relay network,
AGENT_RELAY_NETWORK(the host compose derives<COMPOSE_PROJECT>-agent-relays), declaredinternal: true. No sandbox group joins it: lifecycle code finds the MCP tunnel there by alias and attaches it to each group’s bridge, and refuses the group network before the Agent CLI starts if the alias has no running container, or more than one. Let Compose create this network; one created by hand is refused because its labels do not match.A kernel with nftables, bridge family included.
Docker 28 or newer, client and daemon. The relay joins each group bridge with gateway priority -1, so that a group bridge never becomes its default route (
freeinference-chat-net-*sorts before<COMPOSE_PROJECT>_internal). At the default priority, the relay’s SSH session would meet the sandbox rules and die for every group sharing it.
Checks run at four points:
sandbox_host.sh preparevalidates the network settings with the candidate runner image’s parser before draining any runner.sandbox_host.sh checkrequires HTTP 200 from MCP/healthz, sent from containers on the relay network, before publishing the ready marker. Name resolution alone does not prove that the tunnel’s upstream is up.Each runner’s preflight installs and reads back the host tables before it claims anything.
Each group cold start checks inside the guest, as the sandbox user, for a default route, the configured resolver and the relay’s TCP port. A failure stops the sandbox, keeps its workspace and fails the turn.
For a runner on another machine, the MCP relay is an SSH tunnel to the MCP-only listener; see Running runners on another machine.
Lifecycle code creates the freeinference-chat-net-* group networks through the
Docker API: one /29 from the pool each, named from the group and generation,
with host interfaces named from this deployment’s prefix. A group’s bridge is
deleted on an idle or lost stop, while the container’s writable layer stays, and
is recreated on wake. Sandbox Manager reconciliation removes labelled bridges
left by an interrupted create after a five-minute grace period. A bridge that an
environment test or prebuild still uses is removed by that run; one that
reconciliation cannot remove, such as one with an unknown container attached, is
logged as chat_network_prune_failed and retried on the next pass.
1. Only enrolled sandbox hosts run jobs
Jobs run only on enrolled hosts. Deploy at least one host through
deploy/host/deploy.sh and enroll it; its runner then polls
/v1/agent/worker/claim, and claims nothing until its replica attests the
retained protocol, image and runtime pins, sandbox manager configuration,
execution profile and host capacity.
Admin → Servers → Add server writes the host’s .env
(Compute resources), and you write none of it by hand.
Besides the enrollment credential, it holds COMPOSE_PROJECT,
AGENT_SANDBOX_IMAGE, AGENT_EGRESS_CHAT_NETWORK_POOL and
AGENT_EGRESS_DNS_SERVER (each interpolated with :? in
docker-compose.sandbox.yml, so an unset one stops the render),
AGENT_SANDBOX_MANAGER_TOKEN, the two tunnel destinations with their own keys
and known-hosts files, and the three sandbox manager reverse-forward settings.
2. Credentials
Host credential. Mint a short-lived enrollment token for a named host:
# Admin API; the response shows the single-use token once.
POST /admin/agent/runner-hosts/enroll-token
Put it in AGENT_ENROLL_TOKEN for the first start. Registration replaces it with
a long-lived credential bound to that host, stored under AGENT_HOST_STATE_ROOT,
which every heartbeat and claim then uses. A host name in a request is never
identity by itself.
Sandbox manager credential. One AGENT_SANDBOX_MANAGER_TOKEN per
environment, with the same value on the control plane and every host’s Sandbox
Manager. A new installation generates it, and server setup writes it into the
hosts it sets up. It authorizes file, terminal, Git and session-lifecycle calls,
is not a claim credential, and never enters a chat container.
Creating the GitHub App from the dashboard. On github.com, an
administrator can skip registering the App by hand: Admin → Settings →
Source control → Create the GitHub App opens a setup page that posts a
manifest to GitHub (GitHub’s
App-manifest flow).
The control plane builds the manifest from Web app URL: the connect
callback below, the permissions under App permissions, and no webhook. The
administrator picks the App’s name, an organization they manage or their own
account, and whether any account may install it (users who install it on
their own accounts need that). GitHub sends the browser back to
/admin/settings/github-app with a one-time code, and the control plane
exchanges it at POST /app-manifests/{code}/conversions and saves the App ID,
client ID and secret, private key and installation URL in one settings
write, with the App’s bot as Agent commit co-author when GitHub names it.
The state is single-use and bound to the administrator, and the audit trail
records agent.source_control.github_app_created without a secret. Replacing
a configured App needs confirmation, because every user connects and installs
the new one again. GitHub answers the secrets only once: if the save fails
after the exchange, the error names the App to delete on GitHub. The page is
the only one whose policy lets a form post to https://github.com, and it is
reached by a full page load. Everything below still applies to an App
registered by hand.
GitHub credential. Install a GitHub App and give the control plane its
private key. The platform signs a nine-minute App JWT (github_app.py; GitHub
refuses more than ten) and exchanges it for an hour-long installation token for
the runner’s clone credential, branch lookups and repository reads, so nothing
is minted or rotated by hand. The key reaches the container through a read-only
bind mount at a fixed path, and two different variables are involved:
# The *host* file that holds the PEM. This is the mount source.
AGENT_GITHUB_APP_PRIVATE_KEY_FILE=/etc/cloud-agent/github-app.pem
# compose: $AGENT_GITHUB_APP_PRIVATE_KEY_FILE ──▶ /etc/cloud-agent/github-app.pem:ro
AGENT_GITHUB_APP_PRIVATE_KEY_PATH, the path inside the container, defaults
to that mount, so the Compose deployment sets only
AGENT_GITHUB_APP_PRIVATE_KEY_FILE. Put the file on the host, owned by the
service user, with chmod 600. Alternatively, save an inline PEM in Admin
Settings: it is encrypted and takes precedence over the mounted file. A legacy
AGENT_GITHUB_APP_PRIVATE_KEY value is imported once.
The saved GitHub App ID decides whether GitHub is configured. It is imported
once from AGENT_GITHUB_APP_ID. The key path always has a default, and
/dev/null is mounted there when there is no App. With the App ID set, a key
that cannot be loaded (missing, empty, unreadable or invalid) does not stop the
control plane (issue #47):
Integrations and the composer say GitHub is temporarily unavailable. Creating a job (temporary workspaces included), a runner’s claim or a branch lookup answers
503 source_control_unavailablewithRetry-After: 30, and queued jobs and goal wakeups wait without spending retries.The log has one
ERRORevent,source_control_load_failed, with areason(key_file_unreadable,key_missing,key_invalid,unexpected) and, for a file, its path and the OS error. It repeats only when the reason changes. Queued jobs that cannot start also fire thequeue_not_startingalert.The key is read again every 30 seconds, so fixing the file in place recovers within a minute (
source_control_load_recovered). Changing the host path of the bind mount needs the container recreated.
App permissions. Checkout, pushes and pull requests need contents: write and
pull_requests: write; an owner’s user token holds only what both the App and
the owner may do. Without workflows, GitHub refuses a push that changes a file
under .github/workflows/. For Create repository in the pickers, also grant
Repository creation: write; GitHub also accepts the broader
Administration: Read and write (see GitHub’s
repository creation permissions).
Owners of existing installations may have to approve the new permission, and
without it repository creation reports that the App cannot create repositories.
Creation calls POST /user/repos with the user’s own token, in their personal
account, private, with a README. It adds no local grant, so on an installation
limited to selected repositories, the owner grants access through
Configure repository access. To revoke everything, uninstall the App.
Connect flow. For users to authorize their own repositories, the App also needs its OAuth half:
AGENT_GITHUB_APP_CLIENT_ID=Iv1.xxxxxxxx
AGENT_GITHUB_APP_CLIENT_SECRET=...
AGENT_GITHUB_APP_INSTALL_URL=https://github.com/apps/<app-slug>/installations/new
# App setting "Callback URL": <agent web origin>/connected?provider=github
# for example https://agents.example.org/connected?provider=github
Set the App’s Callback URL to the agent web’s own origin, where the callback
page and session cookie live. The authorize link sends no redirect_uri, so
GitHub uses the App’s first Callback URL. Move it whenever the web origin moves:
a stale callback breaks the connect flow without any error from GitHub. Leave
the App’s Setup URL empty: GitHub sends a browser there after an installation
with installation_id and setup_action, and no page of the web app reads
either, so an App created from the dashboard has none. If one is set, point it
at <agent web origin>/settings/integrations, which shows the user’s GitHub
connection and repositories. The
Connect link is built from AGENT_GITHUB_APP_CLIENT_ID and GitHub’s OAuth
endpoint, and AGENT_GITHUB_APP_INSTALL_URL (/apps/<slug>/installations/new)
is offered after connecting and behind Configure repositories. Keep the two
separate: GitHub sends an installed App’s install link to its settings page
without calling the callback, and an install URL pointing at the OAuth endpoint
loops a user with no installation through authorization.
The runner’s clone token is a separate installation token, requested as
contents: read on the one repository being worked on, so checkout does not
inherit the App’s broader permissions.
The GitHub relay
No GitHub token reaches a sandbox. Each member’s residency carries a placeholder
(agh.) that git and gh present to GitHub, and commits name the owner as
author (GIT_AUTHOR_*, from the owner’s noreply address) with
AGENT_GITHUB_COAUTHOR as co-author. Every group bridge resolves github.com
and api.github.com to the host’s github-tunnel, so every process in the
sandbox reaches the relay. Before the first process starts, a root exec writes
the deployment’s relay CA, and a bundle of the image’s roots plus the CA, to
/etc/freeinference/, root-owned and read-only. The tunnel forwards TLS unopened
to the control plane’s GitHub relay, a listener of its own that holds the
certificate.
The relay accepts the placeholder only while its residency serves a running, leased, unstopped turn on an enrolled host. It then sends the request with the owner’s GitHub App user token when the request concerns the conversation’s repository and is on the relay’s allowlist, and with no credential otherwise. It refuses repository administration, secrets, GraphQL, branch deletion and tags. A pull request it sees created is recorded for the conversation. The control plane renews the owner’s token, so a long turn does not outlive it.
To turn it on:
Run
deploy/control-plane/github-relay-certs.sh <dir>. Keepca.keyoffline; giverelay.pemandrelay.keyto the control plane (AGENT_GITHUB_RELAY_TLS_DIR) andca.pemto every host (AGENT_SANDBOX_GITHUB_RELAY_CA_FILE).Give
relay.keyto the relay’s user. Thegithub-relaycontainer runs as uid 10001 and reads the directory through a read-only bind mount, which keeps host ownership, so a key the operator owns at0600fails withPermissionError. Run the script as root, which sets the key to10001:10001and0400, or runsudo chown 10001:10001 <dir>/relay.keyas the script prints. Moveca.keyout of<dir>before you mount it.Enable the
github-relayCompose profile on the control plane and on each host, and give each host’sgithub-tunnelits own SSH key, limited bypermitopento the relay’s port (AGENT_GITHUB_TUNNEL_*).Set Agent commit co-author under Admin → Settings → Source control (initially
AGENT_GITHUB_COAUTHOR) to the App bot’s noreply address.
Nothing on the platform scans what goes through the relay; branch protection, GitHub’s push protection and the repository’s CI still apply (AGENTS.md §7).
Without an App, the runner clones anonymously, which works for public repositories only. Without the App and the relay, agents cannot push or open pull requests: jobs still run, and their changes stay in the retained workspace, readable in the Git pane or as a download. There is no static-token fallback, and a host without the relay gives the sandbox no placeholder. The workspace is a shallow checkout of the pinned commit and its parent, with the base branch as a local branch at that commit, so a review can diff without fetching.
Running self-hosted
Administrators can also attach an SSH server or provision a CloudLab experiment from Admin → Servers, and select the ready host as the location for new sandboxes (compute-resource runbook). Retained sandboxes stay on their original host, and neither Remove nor Forget destroys the machine.
Run the host agent as a standing service, so queued jobs are claimed after
crashes and reboots. Add server writes the host’s .env and runs the
commands below for you; installing a host from a hand-written .env is not
supported, and this section is for operating a host that exists. Its .env holds
the enrollment token and the shared sandbox manager token. The example below
includes the shared-kernel setting for trusted internal repositories; untrusted
repositories need the default kata backend and
Kata provisioning.
AGENT_ENROLL_TOKEN="<single-use token for this host>"
AGENT_SANDBOX_MANAGER_TOKEN="<same environment value as the control plane>"
AGENT_SANDBOX_BACKEND=container # explicit trusted-repository downgrade
AGENT_SANDBOX_BACKEND=container is an explicit downgrade: sandbox groups
share the host kernel. Compose uses restart: unless-stopped, so enable the
host’s Docker daemon at boot. The host lifecycle commands are:
deploy/host/sandbox_host.sh up # build images, tunnel + runners
deploy/host/sandbox_host.sh preflight # validate this host against an existing image
deploy/host/sandbox_host.sh check # probe all relay/control paths
deploy/host/sandbox_host.sh status # containers + recent log tail
deploy/host/sandbox_host.sh down # stop them
# `up` in its two halves, for a deployer that has to put something between
# them. Nothing in `prepare` replaces a container that is serving.
deploy/host/sandbox_host.sh prepare # pull or build, Kata smoke test, candidate check
deploy/host/sandbox_host.sh activate # drain, replace, prove
Use the standalone host stack even on the control plane’s machine, with tunnel
destinations pointing to its local listeners. preflight checks Docker, the
retained-session configuration, host isolation and the configured image, and
up repeats those checks for the image it deploys.
Host configuration reference
sandbox_host.sh validates the required environment before starting and prints
the runner’s preflight verdict: control plane reachable, retained image and
runtime usable, Docker data root correct, relay network present and route-less,
host network rules installed and read back. The equivalent by hand:
# The image carries exactly the source-reviewed pins, which change together
# with SHARED_SANDBOX_RUNTIME_PINS. Other agent versions are installed from
# Admin -> Settings -> Agent versions, without a rebuild.
docker build -f deploy/sandbox/Dockerfile.agent-sandbox \
-t freeinference-cloud-agent-job:latest .
AGENT_SANDBOX_IMAGE=freeinference-cloud-agent-job:latest \
AGENT_HOST_SLOTS=4 \
docker compose -f deploy/host/docker-compose.sandbox.yml \
up -d
AGENT_SANDBOX_IMAGE has no default: the runner and the Sandbox Manager both
interpolate it with :?. Tag it per environment (…-job:staging, …-job:prod)
so a rebuild on one side cannot replace the other’s image. All hosts share one
queue (claim_job uses FOR UPDATE SKIP LOCKED), with no leader and no
sharding.
Variable |
Default |
Notes |
|---|---|---|
|
|
Deploy refuses |
|
required |
Image built from |
|
|
Docker network for the download step of an agent update from Admin Settings. Only npm runs there, with package scripts off; the scripts and the check run with no network |
|
public npm |
Registry for agent updates until the host’s first heartbeat answer; after that, Agent package registry in Admin → Settings → Agent versions. pi updates come from |
|
required |
This deployment’s RFC1918 IPv4 pool, one |
|
required |
The one IPv4 resolver sandboxes may use, on TCP and UDP 53, and the only exception to the protected ranges. Not loopback, and not inside the pool; see Choosing the resolver |
|
none |
Extra IPv4 blocks to refuse on top of the built-in ranges, such as an institution’s services on public addresses. It can only add protection. Set the same value on the control plane, whose SSH server and model connection checks refuse these blocks too |
|
derived |
Where lifecycle finds the MCP relay: |
|
host name |
The enrolled execution environment that the admin placement switch picks between; |
|
|
Display-only name of the physical server, used to group the admin inventory. Set it explicitly when invoking Compose directly |
|
|
Turns at once until an admin sets a number on the Servers page; 2 to 128 |
|
|
Expected daemon |
|
|
Probe behind the Servers page’s Storage column; |
|
|
Bootstrap value for Storage reserve for new sandboxes, replaced by the admin setting after the first settings heartbeat. Below it, a new sandbox allocation is declined without spending the turn; existing sandboxes may resume. It is an admission guard, not a disk quota |
|
|
Only for a custom sandbox image; must match its user |
|
derived |
Host only: the MCP-only relay URL as this host’s sandboxes see it, derived from the MCP tunnel alias. Never point it at the full control API |
|
none |
MCP-only listener destination and its own restricted SSH key and known-hosts; see |
Start either OAuth flow only from the signed-in /settings/integrations page. The
OAuth state is bound to that user and provider, expires after ten minutes and
works once; GitLab also uses PKCE. GitLab tokens are encrypted at rest, rotated
on refresh, never returned to the browser, and revoked best-effort on
disconnect. GitLab support covers identity and discovery only: the control plane
verifies the GitLab user and lists their projects, but GitLab projects do not
appear in the task composer, and it neither reads their source nor opens merge
requests.
Provisioning Kata on a runner host
Kata gives each sandbox group a lightweight VM with its own kernel. Use it for
untrusted repositories, whose build and test scripts run arbitrary code; plain
containers share the host kernel and are for trusted internal repositories only.
Kata needs an x86_64 Linux host with KVM, bare metal or with nested
virtualization. Install the runtime on the host (the runner image has only a
Docker client, and the host daemon must resolve io.containerd.kata.v2), once,
as root:
sudo deploy/host/setup_kata_runtime.sh
The script is idempotent. It checks for /dev/kvm and CPU virtualization before
downloading, verifies the release against a pinned SHA-256, and links the shim
into /usr/local/bin. After the pinned version changes in the script, --check
fails on every host still carrying the old one.
Guest tracing and member isolation
The setup selects the release’s vmlinuz-debug.container kernel, which carries
the eBPF/BTF support the process observer needs, and sets
runtime.disable_guest_seccomp=false, without which Kata ignores the OCI seccomp
filter; --check verifies both. Runner preflight then starts a disposable
sandbox shaped like a real guest and runs the observer and tool-marker
self-tests, so a missing BPF syscall, BTF image, tracepoint or exec permission
fails the deployment before the runner claims work. See Kata’s
debug-kernel build contract.
Only the fixed observer and lifecycle helpers run as guest root. Agent CLIs and
repository code run under per-member UIDs with all capabilities dropped and
no-new-privileges, and cannot touch the root-only journal. The bounding set
keeps BPF, PERFMON, SETUID, SETGID, CHOWN, DAC_OVERRIDE, KILL and
SYS_PTRACE for those helpers, and ordinary exec enters through
setpriv --no-new-privs, because Kata 3.32 does not inherit PID 1’s setting.
Preflight requires non-root execution, zero effective and permitted
capabilities, NoNewPrivs=1 and Seccomp=2. Privileged helpers verify the
inspected container’s Kata runtime first, so an old runc container can never
become a guest-root target.
Per-tool attribution is diagnostic only, never a security or billing authority.
Member turns report aggregate CPU, memory, I/O and network as unavailable
(coverage=0, sampler_version=shared-member-v1), because Docker statistics
cover the whole shared container; per-call numbers come from the eBPF process
census, which charges a process to the one tool call whose window contains its
start, and marks ambiguous calls partial.
Faster VM boot settings (opt-in)
Two installer settings may shorten the VM boot that every new or resumed group waits for. Both stay off until they are qualified (#1054). To try them on one host:
sudo KATA_STATIC_SANDBOX_RESOURCES=true KATA_DEFAULT_MEMORY_MIB=1024 \
deploy/host/setup_kata_runtime.sh
KATA_STATIC_SANDBOX_RESOURCES=truesetsruntime.static_sandbox_resource_mgmt: each VM boots with its container’s--cpusand--memoryalready added, instead of hot-plugging them. The VM cannot grow later, which the platform never needs, and a VM larger than the host’s memory plus 1 GiB fails to start.KATA_DEFAULT_MEMORY_MIBsetshypervisor.qemu.default_memory(Kata’s default is 2048 MiB), added to every VM on top of its container’s limit for the guest kernel, its page tables and the Kata agent. The installer refuses less than 256 MiB.
They go into one drop-in, config.d/cloud-agent-vm-boot.toml, which --check
reads back; it refuses any other file there and any change to this one. An
install without the settings deletes the drop-in. The control plane’s automated
deploy of a managed host installs prerequisites by default, so it reverts the
settings unless they are passed again. VM templating stays off, because it shares
kernel memory and RNG/KASLR state across tenants, and so does the uncompressed
debug kernel, which would boot every guest at the same kernel addresses.
Guest networking
Docker’s embedded DNS resolver (127.0.0.11) is outside the guest, so after each
Kata activation a guest-root helper writes the relays’ bridge addresses into
/etc/hosts and AGENT_EGRESS_DNS_SERVER into /etc/resolv.conf; under runc
the container gets --dns instead. Kata 3.32 does not apply live network
changes to a running guest, so a running sandbox that is not on exactly its group
bridge is refused until stopped.
Existing runc groups and activation checks
A backend change does not change an existing container’s runtime, and the
privileged helpers refuse old runc containers. When switching a host from runc,
keep its retained runc groups on a compatible sandbox manager or migrate them
separately; do not delete their workspaces. Installing the shim does not prove
that a sandbox reaches its relays, so check from the host checkout, with its
.env, before switching:
AGENT_SANDBOX_BACKEND=kata deploy/host/sandbox_host.sh preflight
AGENT_SANDBOX_BACKEND=kata deploy/host/sandbox_host.sh check
preflight verifies the image and guest kernel. check starts relay probes under
Kata on the relay network, requires HTTP 200 from MCP /healthz, and checks the
live runner’s sandbox preflight (which installs and reads back the host tables),
the sandbox manager and the control-plane paths. A bare alpine getent probe or
the compose ..._internal network proves nothing here. Then drop
AGENT_SANDBOX_BACKEND=container from the .env and redeploy: up requires the
shim and a real container from the sandbox image reporting a kernel other
than the host’s. Nothing falls back to a shared kernel; that takes
AGENT_SANDBOX_BACKEND=container, and every deploy warns about it.
Scheduling and runtime attestation
AGENT_DEFAULT_EXECUTION_PROFILE is untrusted-kata-v1 in
deploy/control-plane/docker-compose.yml, so a deployment whose hosts have not
been through Kata provisioning claims no secure work at all. Set it explicitly
in the .env once a Kata host passes preflight, so the value is visible. A
secure job is claimable only when, in one claim transaction, the caller presents
the host’s current enrollment credential, the runner replica reports
io.containerd.kata.v2, and preflight saw the configured image boot a guest
kernel different from the host’s. The claim, not the host’s heartbeat row,
supplies the attempt’s runtime, image digest, CLI version and kernel stamp.
trusted-v1 selects the shared-kernel boundary for trusted internal
repositories. Follow-ups and forks inherit the thread’s execution profile, and a
retained chat’s image digest is fixed in its container labels.
How many runners
Each chat runs in a group that shares one retained container and workspace; Fork adds a member with its own native session and CLI process, and members run turns concurrently.
Execution slots
Set a host’s concurrency on the admin Servers page (Execution slots), or with
PUT /admin/agent/runner-hosts/<host>/slots and {"slots": N}; null returns
it to the host’s AGENT_HOST_SLOTS default (3). The range is 2 (a fork’s sibling
runs beside its parent) to 128. The limit is how many turns the host runs at
once; the rest wait in the queue. A sandbox gets 2 vCPU and 4 GiB by default, so
budget roughly that per slot. The host reads a new limit from its next heartbeat
answer, so nothing restarts.
Saving is not applying, and the page shows the difference. Claims admit against
the lower of the saved number and the host’s reported slots_total, so lowering
takes effect at once (running turns finish as finishing), while raising waits
for the host to confirm (applying N). An offline host shows N not applied.
The page has no reset; only the API’s null returns the host to its
environment value.
Member process cleanup
Each member has its own UID. Before handing over a turn, the host records that
UID’s processes with the root-owned member-process-reaper; cleanup passes the
baseline to a fresh helper over stdin, rechecks each process’s identity before
signalling, escalates TERM to KILL, and fails closed if anything survives. The
baseline never lives in a member-writable file, so repository code cannot edit it
to keep a process alive.
Fork compatibility and turn ordering
The claiming process must advertise shared-sandbox-v1. Forking from an earlier
point also needs the host’s current image to be the group’s own, or else the
group’s recorded claude-session-fork helper
(agent_sandboxes.fork_helper_version) to be the reviewed one and the host’s
image to still ship the CLI version the container runs. A group with an older or
unknown helper needs the exact image.
Sending a message into a running turn follows the same CLI-version rule.
The Docker socket (or a reviewed mTLS Engine endpoint) is the host’s only
interface to chat state; nothing is mapped from the host. Every turn that has
not started is queued, and a runner claims one only after every earlier turn in
the chat is terminal.
Removing a server
Open the server’s details on the admin Servers page and choose Remove server. Confirming deletes its allocation, nodes, hosts, host settings, capacity history, registration tokens, admission holds and compute activity; shared connections, deployment profiles, conversations, runs and deleted-sandbox audit records stay. First:
Release its cloud resources (an attached server without release support can be removed once its hosts are disabled).
Delete its retained sandboxes and wait for cleanup to finish.
Clear the default placement pin, running attempts and deployment drains.
Removal also refuses with The external operation is unresolved while the server’s Activity tab shows:
an operation still running, or waiting to confirm a provider call: wait for it, or stop it;
an operation whose outcome is
unknown, such as an acquisition whose create request timed out: retry it or, for an acquisition, adopt the experiment it created;on a server that never recorded its provider resource, an operation suggesting the provider has one: release the server, after checking the provider for a resource the request created.
Once the provider confirms the machine is gone, stopped operations no longer
hold the server. The API is DELETE /admin/agent/servers/<allocation_id> with
{"expected_revision": N} (refresh after a revision conflict), or
DELETE /admin/agent/runner-hosts/<host> for a host without an allocation. Stop
an unmanaged host agent first; removal does not touch its machine or files.
Sandbox settings
The Sandbox tab of Admin → Settings holds the sandbox and workspace limits
for every server: turn time limit, repository size limit, container CPU, memory
and disk, idle timeout, sessions per sandbox, workspace command and file limits,
and terminal limits (the less common ones under Advanced). The Sandbox table
in a server’s details on the Servers page overrides them for that server. The API
is PUT /admin/agent/host-settings and
PUT /admin/agent/runner-hosts/<host>/settings with
{"settings": {"<key>": N}}; null clears a key. A server’s value wins over the
global one, and otherwise the built-in default applies. ENVIRONMENT.md
§Sandbox settings from the admin pages lists the precedence and initial
variables; once imported, .env edits have no effect.
Settings travel in the heartbeat answer, so the page shows applying until the host’s report matches. Nothing running is cut short: a turn keeps its time limit, an existing sandbox keeps its size and capacity, and a shortened terminal lifetime closes terminals already past it at the next sweep.
Container size applies to each new group (default 2 vCPU, 4 GiB, disk 0, meaning
no quota) and stays with it through follow-ups, restarts, snapshots and Fork. A
positive disk limit bounds the writable layer with --storage-opt size=, which
needs overlay2 on XFS mounted with project quotas (pquota or prjquota);
elsewhere Docker refuses to create the container.
Set a disk limit on servers that run untrusted work. A Kata sandbox’s
writable layer, workspace and installed files included, shares one disk with
every other sandbox on the server, so without a limit one tenant can fill it for
all. Set Container disk above 0 once the Docker data root is on XFS with
project quotas. It is not enforced, but the control plane and runner log
agent_untrusted_sandbox_without_disk_quota when an unlimited server gets an
untrusted group, and the Servers page shows No container disk quota.
Sandbox archives
The Sandbox archives card under Admin → Settings → Sandbox stores the
deployment-wide archive policy. When enabled, it captures an initial and a final
lifecycle archive of each sandbox under s3://<bucket>/cloud-agent/sandbox, and
Archive to S3 and delete uses the same bucket
(Sandbox archive storage). The prefix is fixed; the
bucket defaults to freeinference.
The card saves, as one revision, the bucket, enabled state, AWS region, the
credentials, and (under Advanced) the maximum compressed archive size, multipart
threshold and part size. Uploads send eight parts at a time, so one upload holds
up to 64 MiB in memory at the default 8 MiB part size. Authenticate with an AWS
access key or with the workload-identity pair: a customer-managed KMS key ARN and
the expected 12-digit bucket owner. With an access key the pair is optional, and
uploads use SSE-S3 unless a KMS key is set. The secret is write-only, encrypted
at rest, sent to the sandbox manager on the authenticated heartbeat channel and
kept only in its memory; it never enters a container or the audit row. Updates
carry the revision last read, so two administrators cannot overwrite each other.
The API is admin-only GET and PUT /admin/agent/sandbox-archive-settings.
Do not put the policy or an access key in .env. To inspect the policy and its
rollout in Postgres:
SELECT sandbox_archive_settings,
sandbox_archive_revision,
sandbox_archive_updated_at
FROM agent_runner_policy
WHERE id IS TRUE;
SELECT host,
sandbox_archive_settings_applied_revision
FROM agent_runner_hosts
ORDER BY host;
The bucket must have versioning enabled. Grant the hosts’ AWS workload identity, or the access key:
s3:GetBucketVersioningonarn:aws:s3:::<bucket>;s3:ListBucketon the bucket, limited to thecloud-agent/sandbox/*prefix, so an exact-keyHeadObjectcan tell a missing object from a refusal;s3:GetObject,s3:GetObjectVersion,s3:PutObjectands3:AbortMultipartUploadonarn:aws:s3:::<bucket>/cloud-agent/sandbox/*;for SSE-KMS,
kms:GenerateDataKeyandkms:Decrypton the configured key;optionally, for snapshot cleanup,
s3:DeleteObjectands3:DeleteObjectVersiononarn:aws:s3:::<bucket>/cloud-agent/sandbox/env/*(see Environment installation snapshots).
Configure lifecycle retention and access logging on the bucket, with an
AbortIncompleteMultipartUpload rule for hosts that vanish mid-upload. The card
shows the saved revision beside the revision each sandbox manager has confirmed, and while
archives are enabled, a host or runner replica that has not applied the current
revision claims nothing.
What is archived. The initial object captures /workspace once, after source
and setup and before the first prompt, and is immutable. Each clean stop managed
by the sandbox manager flushes native Agent state and stores a final object with
/workspace, /agent-state and the optional
/home/agent/.freeinference-platform state, replacing the previous final key
(bucket versioning keeps older versions). Turns while the sandbox stays live
create nothing. Final capture runs inside the stop hook, within the size limit
and deadline, and an exhausted upload is a failed clean stop. Nothing lists,
downloads or replays these archives: they are for export and forensics, while
moving a sandbox uses restorable checkpoints.
Policy changes apply forward only: a sandbox that ran while archives were off has no initial object, and disabling them can leave an initial object without a final one. For paired archives, enable the policy and wait until the card shows the revision applied on every server before admitting new work.
The first prompt waits for the initial capture, not for S3. The bundle is written
under AGENT_SANDBOX_ARCHIVE_STATE_DIR/initial-uploads/<sha256(namespace)>/ and
uploaded in the background (sandbox_initial_archive_uploaded,
deferred: true), with retries after 5 seconds, 30 seconds and 2 minutes, then
every 10 minutes (sandbox_initial_archive_deferred_retry). Until it is
uploaded, that directory holds the only copy of the pre-prompt workspace, so keep
it on persistent disk and let it drain before removing a host. When it is full
(8 GiB) or unwritable, the capture uploads before the prompt instead
(sandbox_initial_archive_handoff_unavailable).
A stop the Sandbox Manager did not perform cleanly (a host crash or reboot, a
Sandbox Manager that exited, a docker stop behind its back) has no final
archive. It records a skipped final marker (sandbox_final_archive_skipped)
and the chat continues through the ordinary native-resume checks.
Changing the bucket. New archives go to the new bucket and restores read from it, but checkpoints and snapshots are read back by object version, so those in the previous bucket cannot be restored. Change it only when no retained group still needs a checkpoint from the previous bucket:
Keep the previous bucket writable by every host’s identity and the saved access key (old and new), with its KMS key usable, until every host has reported the new revision and no final archive is pending. A stop fenced before its host applied the new revision still finishes in the previous bucket, and its group refuses every start and deletion until it does.
Wait for pending finals, which the database does not show. The sandbox manager logs
sandbox_final_archive_failed(with sandbox id and generation) each time one fails; one in progress finishes within 12 minutes of starting, plus up to 12 for its checkpoint, and the finals of groups that stop together run one after another. Wait until every host reports the new revision, then until no host has logged that event for an hour.Treat restore points captured before then as being in the previous bucket (
agent_sandbox_checkpointsdoes not record the bucket). Until its next clean stop, such a group cannot move to another host. To list them, with the end of the wait as the cutoff:SELECT g.id, g.host, g.state, c.captured_at FROM agent_sandboxes g JOIN agent_sandbox_checkpoints c ON c.id = g.restore_checkpoint_id WHERE c.captured_at < '<cutoff>'::timestamptz AND g.deletion_state NOT IN ('pending', 'archived', 'deleted') ORDER BY g.host, c.captured_at;
A snapshot in the previous bucket stays on offer, but only a host that already
holds its image can use it; elsewhere the load fails as unavailable and the
group installs in full.
Restorable checkpoints
While archives are enabled, every clean archived stop also stores a checkpoint:
the container’s changes over its sandbox image, as an OCI image archive at
cloud-agent/sandbox/v2/<sha256(sandbox id)>/g<generation>/<checkpoint id>.oci.tar.
The key names the sandbox, not the host, so another server can restore it (see
Restoring a removed host’s sandboxes).
Checkpoints are on by default; clear Save restorable checkpoints on the card
to turn them off. They use the archive bucket, credentials, size limit and
permissions, and each object is written once.
A checkpoint never fails a stop: it runs after the final archive, within the same deadline, and a failure logs
sandbox_checkpoint_failed.The Sandbox Manager reads the new layers from containerd’s content store, mounted read-only at
AGENT_CONTAINERD_CONTENT_DIRfromAGENT_HOST_CONTAINERD_CONTENT_DIR(default/var/lib/containerd/io.containerd.content.v1.content), checking every digest. When that mount is missing or belongs to another daemon, it logssandbox_checkpoint_content_unavailableand falls back todocker image save, which is far slower.The latest receipt per sandbox is kept under
AGENT_SANDBOX_ARCHIVE_STATE_DIR/checkpointsand repeated on every heartbeat; the control plane records it inagent_sandbox_checkpointsasreported, thenverifiedonce a restore has started it. The admin sandbox page shows the latest.A receipt covers its group only while the group’s start fence (
start_seq) is still the one its stop ended. Every path that can start the container advances the fence first, and a stale request is refused with 409 and retried.The checkpoint holds the writable layer (workspace, native session state and anything installed outside
/workspace), not the credential tmpfs mounts.
Restoring a removed host’s sandboxes
When a host leaves the pool (Remove on the Servers page, or the autoscaler
releasing its node), its credential is revoked, and each stopped group whose
latest checkpoint still covers it becomes cold in the same transaction. A
checkpoint covers a group when it matches the group’s container, generation and
start fence, records every member’s last settled turn, and has a base image
another host can pull by digest. Other groups stay bound to the removed host and
continue only if it is enrolled again; the admin sandbox page shows which is
which. A provider confirming that a node terminated, or a host
moving out before its lease ends,
also turns covered groups cold.
A workspace request (Files, Terminal, Git or an environment retry) to a group
still bound to a removed host answers workspace_unavailable (409), and Fork is
refused; a covered group answers workspace_restoring (409) until a turn
restores it. A cold group does not block Forget on its old host, and once
that host is gone, Delete without archive deletes it at once.
The next turn of any chat in a cold group can be claimed by any host that
advertises shared-sandbox-v1 with archives enabled, except the one still
holding the group’s container (container names carry no generation). The claim
moves the group and advances its generation (restoring), and the new host’s
Sandbox Manager:
pulls the base image by digest if needed;
downloads the checkpoint version the receipt names and checks its size and SHA-256;
checks the archive (one image, every blob verified, every layer the base image’s or in the archive) and rewrites
index.jsonandmanifest.jsonitself;loads it, creates the container with the group’s limits and network, and resumes each native session.
Restores need only the archive permissions hosts already have. Downloads are
unnamed files in AGENT_SANDBOX_ARCHIVE_STATE_DIR/checkpoint-spool. The loaded
image,
freeinference-checkpoint/<sandbox hash>:<checkpoint id>, is removed with its
container.
A restore that fails before the group starts removes what it created (logging
sandbox_create_cleanup_failed or sandbox_checkpoint_image_remove_failed if it
cannot; docker rm --volumes or docker image rm clears the rest). The group
returns to cold and the turn to the queue without spending an attempt, and is
not claimed again for 30 seconds, 5 minutes and 30 minutes after its first three
failures; the fourth marks it lost and fails its queued turns.
A turn that was running when its host disappeared is not covered and ends as
LOST. A group created from a locally built image cannot move, so autoscaled hosts
should pull the published image (AGENT_SANDBOX_IMAGE_PULL=true, see
ENVIRONMENT.md). A host enrolled again after its groups moved cannot use them;
remove its old containers with the admin Discard action.
Environment installation snapshots
A new task whose environment has an install script can start from a saved installation: a container after installation, without the repository’s files, stored like a checkpoint.
Requirements. Archives and Save restorable checkpoints must be on, and prebuilds go only to hosts that advertise
environment-snapshot-v1.Storage.
cloud-agent/sandbox/env/v1/<sha256(owner)>/<snapshot id>.oci.tar, under the checkpoint rules. The building host keeps the image asfreeinference-environment/<owner hash>:<snapshot id>, and other hosts load it on first use after the same checks as a restore.Building. Only
prebuildruns build snapshots, in disposable containers, never from a chat or a test. A prebuild runs only the install script, so a variable or Secret available only at run time never reaches a snapshot. One is queued when a new task had none, its lockfiles changed, the owner asked (Prebuild again, which first deletes the current snapshots), or an environment test passed, and only one per installation is queued or running at a time. Prebuilds use environment-run slots. After a failed build, tasks queue none for that installation for 6 hours, and a prebuild no host started within a day is failed.Use. A new group uses a snapshot only on a host whose sandbox image is the snapshot’s base, when the setup fingerprint (an HMAC of the install script and setup-time variables, keyed by
AGENT_SOURCE_CONTROL_ENCRYPTION_KEY) and the checkout’s lockfiles match. Otherwise it installs in full; a snapshot never fails a turn. After a new sandbox image, each installation’s next task therefore installs in full and queues a build on that image.Lockfiles. The tracked dependency manifests in any directory (
package-lock.json,pnpm-lock.yaml,yarn.lock,bun.lock,bun.lockb,uv.lock,poetry.lock,Pipfile.lock,requirements*.txt,Cargo.lock,go.sum,Gemfile.lock,composer.lock), compared by Git object id. A checkout with more than 200 of them never uses a snapshot.Failed loads. A snapshot whose object does not match its record (size, SHA-256 or archive checks) is deleted. Any other failure to fetch or load one logs
environment_snapshot_unavailableand leaves it on offer.Retention. A newer snapshot, or a change to the install script or a setup-time variable or Secret, supersedes older ones, which are deleted after 24 hours. A snapshot is not offered after 25 days, and is deleted after 7 days unused, when its environment is archived or deleted, or beyond 20 GiB of ready snapshots per owner. Each snapshot’s row in
agent_environment_snapshotskeeps the reason it failed or was retired indetail.Deletion. Hosts poll
/v1/agent/worker/environment-snapshots/deletionsevery 10 minutes and ask/v1/agent/worker/environment-snapshots/retiredwhich localfreeinference-environment/*images to drop. Without the optional delete permissions, the host logsenvironment_snapshot_delete_failedand retries; as a backstop, give thecloud-agent/sandbox/env/prefix a lifecycle rule that expires current versions after 30 days and noncurrent ones after 1 day.Preparation marker. Installation writes
/var/lib/freeinference-broker/environment-setup-v1.json, which the sandbox user cannot write. A container the host has no preparation receipt for, from a snapshot or restored from a checkpoint, skips the install script when the marker’s fingerprint matches. Only one from a snapshot then runs the optional update script (for steps that follow the source, such as code generation or migrations), before the start script, with setup-time variables and a 15-minute limit. A failed update stops the turn like a failed installation and can be retried.Team environments. A team environment’s snapshot serves every active member and counts toward the quota of the member who queued it; only the team’s owner and admins can delete or rebuild it.
Launch failures and queue order
If a turn process cannot start, or exits before taking delivery, the host
returns the turn with POST /v1/agent/worker/jobs/<job>/release, spending no
attempt; once the CLI has admitted the turn, release is refused, so a prompt
never runs twice. Consecutive launch failures pause claims with backoff and show
on the Servers page. Run one runner container per host: scaling it would enroll
the host twice. The queue is global FIFO with no per-user fairness or quota.
The idle clock and safety watchdogs
AGENT_CHAT_IDLE_TIMEOUT_S (default 1800 seconds) is a group’s only
inactivity timeout. Once every member’s activity has settled and no operation is
active, the container is stopped and its bridge removed (never docker rm); the
next acquire recreates the bridge and starts the same container. At startup,
sandbox manager reconciliation stops running orphans before readmitting work; a
group it cannot reconcile is logged as shared_sandbox_reconcile_group_failed
without affecting the others. Closing a terminal by hand counts as activity, and
a running container found with no attempt or deadline gets one fresh 30-minute
window.
Lost attempt leases
Before a prompt reaches the CLI, the worker records its job_id as the
sandbox’s admission receipt. If that attempt’s lease then expires, the system
stops the activation, marks the context LOST and fails the job without retrying,
so no prompt or tool runs twice. Messages queued behind it fail too, and a new
follow-up gets sandbox_context_lost. The reaper waits at most 5 seconds per
member for the host’s sandbox manager, so an unresponsive host does not hold up
other hosts.
Safety watchdogs
These guards add no idle states and do not stop a healthy group:
Setting |
Default |
What it bounds |
|---|---|---|
|
3600 s |
One hung agent turn, which is cancelled and fenced |
|
30 min |
A terminal whose client and process have gone quiet; in a retained chat, the earlier of this and the chat clock applies |
|
8 h |
Any one terminal, however busy |
|
1800 s |
A member’s ownership of its live process; losing it restarts the member and ends an unfinished activation as LOST |
No timeout removes chat data: a retained sandbox goes only by an administrator’s deletion or when its owner deletes every chat using it, so monitor Docker storage separately. See sandbox settings.
Resume, Fork, and pull requests
All five agents are claimable only after image, runtime and helper attestation.
A follow-up sends only the new prompt to the resident process, and recovery
resumes the pinned native session in a new process. Fork is immediate inside the
same container, from any settled turn with a persisted native ordinal, and Edit &
rewind forks from the nearest earlier such boundary with the replacement text in
the composer. The UI shows context as NEW, LIVE, RESTORED or LOST.
A settled turn leaves its changes in the retained workspace; every follow-up
starts from the conversation’s own base, so the Git view shows all its changes.
Pull requests the agent opens through the GitHub relay are
recorded in agent_thread_pull_requests: a job’s published_pr_url is the first
its turn opened, and workspace_pr_url the conversation’s newest. A Fork does
not inherit them, and a pull request opened on GitHub directly is not
recorded.
Admission checks free space only through the
storage reserve.
Rolling deployment order
Downstream deployment automation runs the host and control-plane scripts; this repository publishes neutral artifacts (see the release contract). Until the first release, hosts and the control plane are deployed together, and neither supports the other’s previous release (AGENTS.md §4). The two tracks can run in parallel behind an exact-SHA readiness fence.
Host and control-plane readiness
On a host, activation:
prepares the new sandbox and runner artifacts and proves Kata, before invalidating the ready marker;
stops the old runner gracefully, with no time limit: it stops claiming and waits for every admitted turn to finish, while the sandbox manager and tunnels stay up;
replaces the sandbox manager and runner, runs the isolation, tunnel, runtime and Docker-root checks, records
.deployed-sha, and only then publishes theshared-sandbox-deployment:<sha>capability.
Meanwhile the control-plane deployment prepares its artifacts and runs
migrations. Before compose up replaces a running API, it waits for a heartbeat
newer than the start of its readiness check and reverse-probes every sandbox
manager eligible for new-chat placement, and every online host that still owns a
retained group. SHARED_READY_TIMEOUT (default 900 seconds) bounds that wait.
The claim route enforces the same capability: a pending runner registers and
heartbeats but does not poll, so a runner with a pending or failed marker takes
no work, even during a cold-start bootstrap.
A host the control plane installed (a managed server, or an attached SSH server) is not waited for, because only the new control plane rolls it forward (Compute resources). If it owns a retained group, it must send a fresh compatible heartbeat and answer its sandbox manager, and it starts no new chats until it reports the target commit.
The deploy user writes .shared-live-ready in the deployment checkout; runners
mount only that file, read-only, at /run/cloud-agent/shared-live-ready. The
host script keeps its inode when changing pending:<sha> to <sha>, so mounts
see the change, and a partial write cannot advertise a target SHA.
Rollback compatibility
The deployment orchestrator runs separately from the target checkout (in GitHub
Actions, from the workflow commit). Before changing Docker state, it refuses a
target without the current deploy/DEPLOY_PROTOCOL or with an incompatible
value; the current protocol is shared-live-exact-sha-v4. For downstream
Actions triggered by workflow_run, the workflow comes from that repository’s
default branch: update the orchestrator there before relying on a new fence,
and do not dispatch an older workflow during the rollout.
Database changes are expand-first. Never downgrade columns under a running new API: roll code back to a schema-compatible commit first, and treat any later contract migration as a separate reviewed operation.
The orchestrator must reject a control-plane recipe without
AGENT_DEPLOY_DRAIN_FENCE_V2. Every host has a drain_fence_epoch that rotates
on each change to its status, credential, fence or compute node. Acquiring or
transferring a fence
must present it with the expected owner token, and a database trigger enforces
the rotation and refuses to delete a host with an active fence. A host that went
offline and comes back keeps its inactive receipt, and delayed requests stay
fenced.
Inspect fence state before a rollback or recovery:
SELECT host, status, slots_used, drain_fence_token,
drain_fence_status_before, drain_fence_active, drain_fence_epoch
FROM agent_runner_hosts
WHERE drain_fence_token IS NOT NULL;
If an active fence is abandoned, use the control plane’s token-conditional
release (or the audited force override). If that is
impossible, stop the control plane and every deployment workflow, and clear one
host’s fence in a transaction that checks its token, epoch and slots_used = 0:
BEGIN;
SELECT host, status, slots_used, drain_fence_token, drain_fence_active,
drain_fence_epoch
FROM agent_runner_hosts
WHERE host = '<exact-host>'
FOR UPDATE;
UPDATE agent_runner_hosts
SET status = 'online',
drain_fence_token = NULL,
drain_fence_status_before = NULL,
drain_fence_active = FALSE
WHERE host = '<exact-host>'
AND status = 'draining'
AND slots_used = 0
AND drain_fence_token = '<expected-token>'::uuid
AND drain_fence_epoch = '<expected-epoch>'::uuid
AND drain_fence_active
RETURNING host, drain_fence_epoch;
COMMIT;
Require exactly one returned row. The returned epoch is the newly rotated value;
do not assign it yourself. To clear only an inactive receipt, use the same host,
token and epoch predicates with NOT drain_fence_active, and change the status
only when the recovery requires it. Never bulk-clear fence fields. If the owner,
token or epoch is uncertain, leave the host draining and restore the control
plane.
Cold starts and failed deployments
On failure, the existing control plane keeps running and the deploy stops for
repair. On a true cold start, with neither the API nor the MCP relay running,
the host cannot complete its readiness probes, so after migration the control
script starts only the missing services. A failed gate stops only the services
that invocation started, and web does not start until the exact-SHA fence
succeeds. A later API or web probe failure leaves the new stack running for
diagnosis but does not write .deployed-sha.
Applying migrations that are not backwards-compatible
deploy.sh migrates before replacing the API, so each migration must stay
compatible with the running version until the replacement, and most do. When
the upgrade notes say a migration needs stopped writers,
apply it as follows.
The runner holds no database connection (its heartbeats are HTTP calls to the
control plane), so stopping the control plane, the MCP relay and the web tier
leaves the database with no writer. The psql commands below run in the bundled
Postgres container against its POSTGRES_DB, the database AGENT_POSTGRES_DB
names, which must be the one AGENT_DATABASE_URL uses
(database settings).
Drain the hosts, keep the generated
cloudagent-undrain-*.sql, and wait for both counts to reach zero; neither can settle once the writers stop:docker exec -i cloudagent-postgres-1 sh -c 'exec psql -U "$POSTGRES_USER" -d "$POSTGRES_DB" -At' <<'SQL' SELECT count(*) FROM agent_attempts WHERE status = 'running'; SELECT count(*) FROM agent_session_forks WHERE state IN ('preparing', 'materialized'); SQL
A fork still
preparingormaterializedis one its coordinator has not finished, and the reaper that settles it runs inside the API. A stalepreparingoperation fails after the stall window (15 minutes by default).Stop the writers:
docker stop cloudagent-control-plane-1 cloudagent-mcp-relay-1 cloudagent-web-1
From the deploy root, with the target commit checked out, build and run the target’s
migrateimage while nothing writes:export AGENT_DEPLOYMENT_SHA="$(git rev-parse HEAD)" # `keys` builds the control-plane image that `migrate` runs. docker compose -p cloudagent --env-file .env -f deploy/control-plane/docker-compose.yml build keys docker compose -p cloudagent --env-file .env -f deploy/control-plane/docker-compose.yml \ run --rm --no-deps migrate
Undrain the hosts recorded in step 1, then deploy the target commit as usual. Its migration is now a no-op, and readiness can see a host that may claim:
docker exec -i cloudagent-postgres-1 sh -c 'exec psql -U "$POSTGRES_USER" -d "$POSTGRES_DB" -v ON_ERROR_STOP=1' \ < cloudagent-undrain-$(date +%F).sql deploy/control-plane/deploy.sh "${AGENT_DEPLOYMENT_SHA}"
Retained Docker storage on a host
Retained chat state lives in each container’s Docker writable layer, and with
the containerd image store the images live beside it under containerd. For
durable same-host operation, put both stores on a mounted data disk and leave the
daemon paths at their defaults: docker info must report
DockerRootDir=/var/lib/docker, and AGENT_RETAINED_DOCKER_DATA_ROOT stays
/var/lib/docker. A custom data-root, graph or containerd root is refused
before the host starts.
Automatic SSH bootstrap sets this up from the server’s
sandbox storage path. On a manual
host, with <disk> an existing writable mount (for example
/scratch/hybridInference-cloud-agent/sandbox):
Bind the two stores:
<disk>/docker bind -> /var/lib/docker <disk>/containerd bind -> /var/lib/containerd
Persist the binds in
/etc/fstab:<disk>/docker /var/lib/docker none bind,nofail,x-systemd.requires-mounts-for=<disk> 0 0 <disk>/containerd /var/lib/containerd none bind,nofail,x-systemd.requires-mounts-for=<disk> 0 0
Give each daemon a drop-in,
/etc/systemd/system/docker.service.d/cloud-agent-storage.confand/etc/systemd/system/containerd.service.d/cloud-agent-storage.conf(naming/var/lib/containerdinstead), and runsystemctl daemon-reload, so that a missing disk keeps the daemon stopped instead of opening an empty store:[Unit] RequiresMountsFor=<disk> /var/lib/docker
To move a store that already has data, copy it while the daemons run, stop Docker
and containerd, and copy again with --delete until the copy exits 0. Move the
old directories aside, create empty mount points, bind-mount and start the
daemons; do not point daemon.json at the new path. Containers with
restart=no must be started by hand. Delete the old copies only after a reboot
comes back on the binds.
The sandbox manager refuses an AGENT_RETAINED_DOCKER_DATA_ROOT that differs
from the daemon’s DockerRootDir, but cannot check the mount itself without a
host-root mount, so the RequiresMountsFor= drop-ins are the mount check.
Do not bind
<disk>,/var/lib/docker,/var/lib/containerd,/workspaceor/agent-stateinto the sandbox manager or a sandbox.Do not run
docker system prune, container TTL cleanup,docker rmor image garbage collection againstorg.freeinference.chat-sandbox=trueobjects; operate on them through Docker (docker inspect,docker exec,docker cp) and the sandbox manager, not by walking overlay directories.Back up or move the stores only with both daemons stopped, preserving ownership, hard links, extended attributes and sparse files.
With the binds in place, docker stop and docker start survive restarts of
every service and of the host. Another host can continue a group only from its
restorable checkpoint. A missed
heartbeat or an unreachable sandbox manager does not prove the state is gone:
keep the chat pinned, recover or re-enroll the same named host, and reconcile its
container. Only an inspection on the owning daemon may mark the context LOST;
never create a blank replacement elsewhere.
How full is the sandbox storage?
The Servers table’s Storage column shows how much of the filesystem holding
the sandbox writable layers is in use, in df terms. It covers the filesystem,
not one chat; a stopped container still holds its repository, dependencies,
changes and native session there. The same reading feeds
Storage reserve for new sandboxes (default 1024 MiB): below it, the runner
declines a turn that would create a sandbox and returns it to the queue. Free
Docker storage or lower the reserve to allow new allocations
(sandbox settings).
What the reading measures
A runner shares the sandboxes’ Docker daemon and storage driver, so
os.statvfs("/") inside it describes the writable layers’ filesystem. used is
total - free, available is what an unprivileged writer may still use, and the
percentage is over used + available, so free blocks reserved for root are in
neither.
Attesting the storage topology
A project quota (overlay2.size, or --storage-opt size= on XFS) would make
statfs report the quota instead of the disk. sandbox_host.sh therefore
compares the runner’s numbers with df of the mount root of the upper
directory’s filesystem, and writes its verdict to .storage-probe/verdict.json
beside .shared-live-ready. The mount root’s size must equal the runner’s
total_bytes exactly; a size mismatch with df <upperdir>, or overlay2.size
in daemon.json or on the dockerd command line, gives unsupported. When a
non-root deployment user cannot traverse Docker’s snapshot directories, a
locked-down temporary helper (no network, capabilities or Docker socket) reads
the two directories through read-only binds; it needs Docker 25 or newer on the
host, and older Docker reports unverified.
Each runner rereads the verdict on every sample and publishes a number only for
its own upper directory with a matching size; otherwise the column shows
unverified or unsupported. A rebuilt container gets a new upper directory, so
an old verdict stops applying by itself.
Refreshing or disabling the metric
Compose binds .storage-probe/ read-only at /run/cloud-agent/storage-probe;
keep the directory. Deleting verdict.json reports unverified until
sandbox_host.sh check recreates it.
Storage verification never blocks a deployment: failures are warnings.
# Re-run the checks without redeploying — this also refreshes the verdict.
deploy/host/sandbox_host.sh check
# Turn the metric off entirely (the rollback). The `.env` is the deploy
# checkout root's, beside `.deployed-sha`, which is where every reader looks.
echo 'AGENT_HOST_STORAGE_PROBE=off' >> .env
deploy/host/sandbox_host.sh up
The up is required, because a container’s environment is fixed when it is
created. The variable takes only overlay_root or off.
Measurement limits
The reading is block space: available does not promise that a container can
write (inodes, quotas and read-only remounts still fail), it includes every other
writer on the filesystem, and it does not predict how many more sandboxes fit.
Rootless, remote-Docker, btrfs, ZFS and devicemapper hosts report unsupported,
and Docker Desktop shows unverified.
Which machine runs the jobs
Admin → Servers lists every enrolled execution environment with authenticated heartbeats, grouped by the physical server it reported. Its New chats selector picks where a chat with no sandbox is created; the default, Automatic, lets whichever host polls first take it. Once a group exists, only its owning host can claim its turns. Runners pull work, so placement is enforced when a runner claims a job:
The switch is neither preemptive nor a drain. The new host starts claiming chats that have no sandbox yet. Jobs running on the old host finish, holding their leases, and existing chats stay pinned to the host that holds their writable layer. A group moves only from a covering checkpoint, after its host is removed, terminates or moves out (restoring a removed host’s sandboxes).
An unenrolled runner cannot claim. The control plane derives the host from its persisted credential, so a name in a request cannot impersonate a pinned machine.
AGENT_ENROLL_TOKENis bound to the chosen host name and redeemed once; replicas then share the persisted credential.There is no storage failover. If the selected host stops, new chats wait rather than starting elsewhere, and existing chats wait for their own host. The admin page warns when the selected host has not polled recently, but the signals that count are its heartbeat and its sandbox manager probe.
A second machine needs more than this switch: it needs the two tunnels described next and everything in §0 above. Preflight refuses on that machine at startup, rather than failing jobs at their first model or MCP call.
Running runners on another machine
A sandbox’s group bridge reaches the public internet only on TCP 80/443, and the host rules refuse private addresses except the group’s fixed MCP relay: an SSH tunnel that lifecycle code finds on the relay network and attaches to each group’s bridge. A separate control-plane tunnel is visible only to the runner:
runner host service host(s)
┌──────────────────────────────────────┐
│ [sandbox, its own group bridge] │
│ ├→ mcp-tunnel ─────────────────────┼──ssh──→ MCP-only :8001
│ └→ host rules and NAT ─────────────┼────────→ public IPv4, TCP 80/443 only
│ │ (the owner's model provider)
│ │
│ [runner, internal network] │
│ └→ control-plane-tunnel ───────────┼──ssh──→ control API :8000
└──────────────────────────────────────┘
Each tunnel is a relay, not a proxy (no CONNECT, no caller-chosen destination), so nothing a sandbox sends can widen either route. The control-plane tunnel never joins a group bridge, and its address on the runner’s network is a private one that the host rules refuse from every group. The tunnels use SSH so that each service keeps listening on loopback; binding them to a shared network would put scoped MCP tokens and host credentials there in cleartext.
deploy/host/sandbox_host.sh up # relays, sandbox manager and the runner
deploy/host/sandbox_host.sh check # probe relays and runner/Sandbox Manager paths
deploy/host/sandbox_host.sh status
deploy/host/sandbox_host.sh down
deploy/host/docker-compose.sandbox.yml holds the runner, the sandbox manager,
the two tunnels and two networks: the stack’s own network and the route-less
relay network. A host environment that still sets the removed inference tunnel
(AGENT_GATEWAY_URL, AGENT_GATEWAY_HOSTNAME, AGENT_TUNNEL_*) is refused.
Variable |
Notes |
|---|---|
|
The MCP-only relay’s destination and SSH material; remote default |
|
The runner-only control API relay; remote default |
|
Private key, mounted read-only. Each relay has its own key and its own account on the far machine, restricted as described below |
|
Required host-key file for each relay. Host checking cannot be turned off: an unverified hop would hand scoped tokens to whatever answers there |
|
The name a sandbox resolves on its group bridge, |
|
The runner-only control relay’s name, |
Generate the known-hosts entry, and compare its key fingerprint with a trusted record for the service host:
ssh-keyscan -p 22 "<control-plane-host>" > /etc/agent-tunnel/known_hosts
The way back: the control plane reaching this host’s sandbox manager
File listings, terminal traffic and git status go from the control plane to
the sandbox manager beside the Docker daemon that holds the workspace, at the
address the host reported at enrollment. The integrated local stack shares a
network (http://sandbox-manager:8092); the standalone host stack does not, even
on the same machine as the control plane. An unreachable sandbox manager answers
503, including on terminals/suspend during normal execution, so verify the
route before admitting jobs.
The control plane’s machine usually cannot reach this host, so the route rides the connection this host already opens: a reverse forward on the control-plane tunnel.
runner host control plane host
┌──────────────────────────┐ ┌──────────────────────────┐
│ sandbox-manager │◀─── -R ──────│ 172.24.0.1:18092 │
│ :8092 │ │ (docker bridge gateway) │
│ │ │ ▲ │
│ control-plane-tunnel ────┼──── ssh ────▶│ │ control-plane │
└──────────────────────────┘ └────────┴─────────────────┘
Set all three of these; an advertise URL with no tunnel behind it gives the same 503:
Variable |
Value |
|---|---|
|
The control plane host’s Docker bridge gateway. Not |
|
A free port on that host |
|
|
The control-plane machine’s sshd must apply GatewayPorts clientspecified to the
control account, as its block in
deploy/host/sshd-tunnels.conf.example
does, with that account’s PermitListen and the key’s permitlisten naming this
exact address and port. Never set it to yes: sshd then binds every remote
forward to the wildcard address, whatever the client asked for, and still
reports success, so each host’s sandbox manager is published on all of that
machine’s interfaces behind one shared token. With the default, no, sshd binds
the forward to loopback, where the control plane’s containers cannot reach it. A
listener that sshd refuses outright (a port in use, or one PermitListen does
not allow) makes ssh exit under ExitOnForwardFailure and the container restart;
the two wrong settings do not. On that machine, confirm with ss -ltn that the
port listens on the bridge address and nowhere else.
The bind address alone does not keep the LAN out, because Linux accepts a packet
for any local address on any interface. Also limit the reverse ports in that
machine’s firewall to its Docker bridge interface. Find the interface with
ip -o -4 addr show to <bind>, then add a rule for each reverse port (or the
range you assign), for example:
iptables -I INPUT -p tcp --dport 18092 ! -i br-0123456789ab -j DROP
Persist the rule the way that machine persists its firewall. Then check from inside the control-plane container:
docker exec "<control-plane-container>" \
python -c "import urllib.request; print(urllib.request.urlopen('http://<bind>:<port>/health', timeout=5).status)"
HTTP 401 proves the route works: the sandbox manager refuses the
unauthenticated request, and urllib reports that as an HTTPError. A DNS error
or a timeout means the route failed.
Notes on this topology
The runner is not the control-plane image. It builds from
Dockerfile.agent-runner, which adds a Docker client andgit. A runner built from the control-plane image fails preflight on every host.There is no host worktree mapping. For the first turn, the runner fetches the requested commit into a temporary directory, removes all repository credentials, normalizes ownership in a tar stream, imports it into
/workspacein the retained container, and deletes the temporary clone. Everything after that stays in the container’s writable layer.The Docker socket is the host’s authority. The runner and the sandbox manager can create, start, stop, inspect and exec in chat containers, so keep those services away from users; their Unix UID matters less. The security boundary is the retained sandbox (Kata for untrusted multi-tenant work, plain Docker only for trusted repositories), not a host bind mount or a per-turn container.
The sandbox network
Each sandbox group (setup, the agent and every Fork sibling) gets one routable
Docker bridge, a /29 from AGENT_EGRESS_CHAT_NETWORK_POOL, and there is no
other network to select
(AGENTS.md §7). The
bridge’s host interface is named with this deployment’s prefix: ca and five
hex digits derived from AGENT_SANDBOX_NAMESPACE, then eight derived from the
group. Docker routes and masquerades the bridge, and this deployment’s host
nftables tables decide what it reaches.
A chat’s optional setup_script runs inside the retained container before the
first Agent CLI turn, on the same network the agent gets afterwards. Its files
persist in the container’s writable layer; there is no host-side setup cache.
Package managers reach public registries directly over HTTPS, with no proxy to
configure. Anything that needs another port, such as Git over SSH, is refused,
except an owner’s own checked SSH servers in the chats that
enabled them. The sandbox runs unprivileged, so apt install does not work; use
pip --user, a virtualenv or npm ci.
New chats can select up to eight runtime plugins (+ → Plugins, or the create
request’s plugins field); follow-ups keep them and Fork copies them. Claude
Code and Codex take entries such as
{"plugin": "review@example", "marketplace": "example/plugins"}, from a GitHub
repository or a credential-free public HTTPS source (a Git repository for
Codex). pi, OpenCode and Kilo take npm entries such as
{"plugin": "@example/plugin@1.2.3"}. Ranges, tags, local paths, install
commands and credentials in source URLs are refused. Plugins install during
member initialization, before the CLI accepts a prompt, under the member’s own
identity and network. An error or timeout fails startup with a short
diagnostic, and a successful install is kept across restarts.
What it allows and refuses
Allowed:
public IPv4 on TCP 80 and 443: curl, Python HTTP clients, pip, npm, Git over HTTPS;
the resolver in
AGENT_EGRESS_DNS_SERVER, on TCP and UDP 53. It is checked before the protected ranges, so a resolver on a private address or on this host works, on port 53 only;the group’s own MCP relay, by exact bridge, address and port;
the model relay, the same way, on a host configured with one (Provided models);
the GitHub relay’s tunnel, the same way, on a host configured with it:
github.comandapi.github.comresolve to it on every bridge, on port 443 (The GitHub relay);the exact public IPv4 address and port of each SSH server the group’s owner registered, checked and enabled for one of its chats (the
ssh_targetsset). It is checked after the protected ranges, so a protected address stays refused (SSH servers).
Refused:
every address of this host, the bridge’s own gateway included, except the resolver when it runs here;
every IPv4 address that is not ordinary public unicast:
0.0.0.0/8,10.0.0.0/8,100.64.0.0/10,127.0.0.0/8,169.254.0.0/16(cloud metadata among them),172.16.0.0/12,192.0.0.0/24,192.0.2.0/24,192.88.99.0/24,192.168.0.0/16,198.18.0.0/15,198.51.100.0/24,203.0.113.0/24,224.0.0.0/4and240.0.0.0/4, plus Azure’s WireServer168.63.129.16and whateverAGENT_EGRESS_PROTECTED_CIDRSadds, on any port;other groups, of this deployment or another;
every other port and protocol: UDP 443 (QUIC), ping, all IPv6;
connections started from outside. A reply is accepted only for a connection the group opened, and one from a protected address is dropped even then.
The rules judge the address a packet is sent to, so a name that resolves (or is rebound) to a private address is refused like the address itself. Most refusals are answered at once with a TCP reset or an ICMP “administratively prohibited”, so a blocked request fails immediately instead of timing out; IPv6 is dropped silently.
What it does not promise. TCP 80/443 is a port rule: nothing inspects the traffic, so DNS over HTTPS or a tunnel on those ports is not prevented. Nothing stops a sandbox from sending the repository, its own short-lived tokens or its owner’s provider key to a public host, and the platform’s own public addresses may be reachable.
MCP prerequisite and accepted owner-key exposure
The main API does not mount the tool-call router, so the MCP tunnel must point at port 8001 (see MCP servers).
The member’s CLI holds its owner’s provider key for the turn it runs (see owner model connections), and code or instructions a task meets may cause that key to leave the sandbox. This is accepted: calls made with it spend the owner’s own quota and grant no other user’s identity, MCP tools or platform-management rights. The owner revokes the key at the provider; deleting the connection here does not revoke it upstream. Accepting this waives none of the other gates: Kata and network acceptance, member isolation and the restrictions on long-lived credentials still apply.
The host tables
The rules are two nftables tables of this deployment’s: an inet table for
routed traffic (to the internet, the host, another bridge) and a bridge table
for frames between a sandbox and its relays on the same bridge. Both are named
cloud_agent_ca plus the first five hex digits of the SHA-256 of
AGENT_SANDBOX_NAMESPACE, which on a host stack is the Compose project:
digits="$(printf '%s' "$COMPOSE_PROJECT" | sha256sum | cut -c1-5)"
table="cloud_agent_ca$digits"
The runner and the sandbox manager hold no NET_ADMIN and are not in the host’s
network namespace. They change host rules through a helper container: their own
image, run in the host’s network namespace with only NET_ADMIN and a read-only
root filesystem, as the host_nft function below does. Each keeps one helper
running and hands it one step at a time. A helper that fails a step is
discarded (network_guard_helper_discarded), and for five minutes every step
runs in a fresh helper. Helpers always run under runc, because a Kata VM would
change its own kernel’s rules, not the host’s.
Installed before anything joins a bridge. The runner’s and the sandbox manager’s preflight install the tables and read them back (every chain, its hook and rule count, the protected set, the registered pool). Any difference stops the runner claiming and the sandbox manager starting. Group network work repeats the check and trusts a pass for 60 seconds, and both services renew their pass in the background about every 45 seconds, so starting a group rarely waits for it. A turn process that reads a pass already 60 seconds old logs
network_guard_verification_aged_out, checks again itself, and runs only if that passes.Scoped to this deployment. The tables recognize traffic by the bridge interface prefix and never touch another deployment’s rules, so several deployments can share a host.
Relays by exact endpoint. A group’s relay bridge, address and port are written to a
relaysset in both tables when the relay attaches, and removed with the bridge. Every activation and workspace command re-syncs its bridge’s exceptions.Watched while groups run. While any group runs, the sandbox manager reads the tables back every five seconds, logs
network_guard_rules_changedwhen they differ, reinstalls what is missing, and restores each running group’s relay and SSH exceptions (chat_group_exceptions_not_restoredwhen it cannot). Two failed checks in a row logshared_chat_network_unguardedand stop every running group, keeping workspaces and native sessions. Waking a group reinstalls and verifies the rules first.Kept by the kernel. A runner exiting leaves the tables in place; a reboot clears them, and no group starts until they are installed again.
To read them, use the same kind of helper:
image="$(docker inspect --format '{{.Image}}' "${COMPOSE_PROJECT}-runner-1")"
host_nft() {
docker run --rm --network host --runtime runc --cap-drop ALL \
--cap-add NET_ADMIN --read-only --entrypoint nft "$image" "$@"
}
host_nft list table inet "$table" # chains; each refusal has a counter
host_nft list table bridge "$table"
host_nft list set inet "$table" relays # relay endpoints, per live bridge
host_nft list tables # every deployment's tables here
Keep --runtime runc: on a host whose default runtime is Kata, the listing would
otherwise come from a VM. The counters are totals across all of this
deployment’s groups; no per-connection log is kept.
Overlapping pools
After installing, each deployment compares its pool with those of the
cloud_agent_* tables created before its own. Of two whose pools overlap, the
later one refuses with this deployment's pool … overlaps …, registered earlier by …,
so a neighbour started with a copied pool cannot take a working deployment down.
Give each deployment its own AGENT_EGRESS_CHAT_NETWORK_POOL.
The pool must also stay clear of every network the host routes. Docker checks
only other Docker networks, so a group bridge inside a LAN, VPN or
private-service range would draw the host’s traffic for those addresses into a
sandbox. The guard reads every IPv4 route (ip -4 route show table all) and
refuses with this deployment's pool … overlaps the host route … on …. The
default route, catch-alls wider than a /8 (such as a full-tunnel VPN’s two
/1 halves) and this deployment’s own bridges do not count. A network reached
only through the default gateway has no route to find, so choose the pool with
the site’s addressing in mind.
A retired deployment’s tables stay, with its pool registered, until the host
reboots. Once it is gone for good, delete its two tables, and no one else’s,
with the helper above: host_nft delete table inet cloud_agent_ca<its digits>,
then the same for bridge. Never delete or flush a table that a running
deployment uses: Docker routes and masquerades every group bridge, and the table
is what limits it. Anything that flushes the whole ruleset removes these tables
too. They come back at the next check, but do not run such a reload on a host
with active groups.
Choosing the resolver
AGENT_EGRESS_DNS_SERVER is one IPv4 address and the only DNS a sandbox can use.
A public resolver works anywhere. A site resolver on a private address or on
this host works too, and becomes the one private address a sandbox can reach, on
port 53 only. It cannot be loopback (a sandbox cannot reach the host’s
127.0.0.53), unspecified, or inside the pool. Under runc, a container gets it
as --dns when it is created, and Docker’s resolver at 127.0.0.11 forwards to
it; in a Kata guest the helper writes it into /etc/resolv.conf
(Guest networking). The in-guest check at every cold start
confirms that the guest uses this resolver and that it answers a query for the
root’s name servers within three seconds.
Protecting more addresses
AGENT_EGRESS_PROTECTED_CIDRS adds comma-separated IPv4 blocks to refuse, such
as an institution’s services on public addresses; it can only add protection.
The resolver stays reachable on port 53 even inside an added block. A change
takes effect when the runner and the sandbox manager are redeployed with it.
When something is refused
Settings. sandbox_host.sh prepare reads them with the candidate image’s own
parser before any runner is drained. A refusal prints
the sandbox network settings were refused (see the error above) under one of:
AGENT_EGRESS_CHAT_NETWORK_POOL must name this deployment's group address poolor… must be RFC1918 space holding at least one /29: unset, outside10.0.0.0/8,172.16.0.0/12and192.168.0.0/16, or smaller than a/29;AGENT_EGRESS_DNS_SERVER='…' must be one IPv4 resolver addressor… must be reachable from a group bridge: unset, not IPv4, loopback, unspecified, or inside the pool;AGENT_SANDBOX_MCP_URL='…' names a relay by IP; use its network alias: each group bridge gives the relay a fresh address, so only its name carries over.
Preflight. Until it passes, the runner claims nothing and the sandbox manager does not start:
the relay network '…' does not exist: the stack is not up, orAGENT_RELAY_NETWORKnames something else;the relay network '…' is not `internal`: let Compose recreate it as declared;nft failed: …ornetwork guard helper could not run: …: the host kernel lacks nftables support, or Docker refused the helper container;the network guard runs its helper from this container's own image: the runner finds its image by inspecting its own container, named byHOSTNAME, so a customhostname:breaks it;… is missing chain …,… holds N rules, expected M,… is not hooked on …,… protects …, not the configured setor… registers pool …, not …, each naming the table: the tables changed after they were installed, or a runner and a sandbox manager with different settings are overwriting each other. Redeploy both from one.env;this deployment's pool … overlaps …or… overlaps the host route … on …: see Overlapping pools;the sandbox network needs Docker 28 or newer, client and daemon: see §0.
Group lifecycle. These fail the turn or operation that needed the group’s network, and keep the workspace:
relay alias '…' has no running container on relay network '…'(ormultiple running containers): a tunnel is down or restarting, or two stacks share one relay network;AGENT_EGRESS_CHAT_NETWORK_POOL … has no free /29 subnet: every/29in the pool is taken, by this deployment’s groups or by other Docker networks in the same range;group network check failed inside the sandbox: …: the in-guest check after a cold start found one of the problems below, and the sandbox is stopped, not deleted. Reaching the public internet is not part of the check.no default route, orresolver is […], expected […];resolver … did not answer: …or… did not answer the query usefully: the resolver is down, refuses recursion, or (under runc) the container was created with a resolver the rules no longer allow;relay host:port unreachable: …;the host at …:9/udp was refused by ECONNREFUSED, not by the network rules,the metadata address 169.254.169.254:80 answered; the network rules are not in this guest's path(or the same forthe platform address 168.63.129.16:80), or… was not refused within 2s: the guest’s traffic is not passing this deployment’s tables;
fixed relay joined the chat network without its gateway priority: the Docker daemon ignored--gw-priorityand needs Docker 28 or newer;Kata guest network sync failed: …: the guest-root helper could not write/etc/hostsor/etc/resolv.conf;a running retained chat is not on exactly its group bridge: a running guest is never rewired; stop it first.
In the sandbox manager’s log, chat_group_relay_exceptions_left means a removed bridge’s relay
entries could not be withdrawn from the tables. They match nothing once the
bridge is gone, and if the helper still cannot run, the next activation fails.
Runtime verification
After changing runtime integration code, run the adapter contract tests. They replay recorded and synthetic events against the normalized mapping, with no live model or deployment credential:
uv run pytest tests/unit/test_agent_runtimes.py
After changing the MCP path (catalogue, per-user registry, relay, filters, API or runtime adapter), run at least:
uv run pytest tests/unit/test_mcp_connection_config.py \
tests/unit/test_mcp_protocol_and_authorization.py \
tests/servers/test_mcp_relay.py tests/servers/test_agent_jobs_api.py \
tests/unit/test_agent_runtimes.py
These tests do not run the installed agent binaries. An installed-CLI smoke test and a live-model matrix belong to the deployment that operates those binaries, models and credentials, and their configuration belongs in that deployment’s overlay, not in this repository.
SSH servers
An owner registers their own Linux servers under Settings → SSH connections
(/settings/ssh-connections), checks each one, and turns servers on per chat from
+ → SSH servers. The agent then runs ssh, scp and rsync against them
from the sandbox; the platform never runs a command on a server. The
owner SSH servers entry in
AGENTS.md §7 describes the
accepted risks.
Key. Each server’s Ed25519 private key is encrypted with
AGENT_SOURCE_CONTROL_ENCRYPTION_KEYunder its ownhybridinference/ssh-server-key/v1domain. Without that key the settings section says so, and nothing can be added.Hosts. The sandbox image ships
openssh-client; every supported host can apply a group’s SSH state.What a turn does. Before setup and the agent start, the runner sends the sandbox manager the group’s SSH state from the claim. The manager records the newest state in the root-owned
/run/agent-members/.ssh-access-state(revisions and digests, no keys) and sets the bridge’sssh_targetsfrom it. It removes the SSH directories of members the state allows nothing, and writes the starting member’s servers into that member’s private tmpfs (key,known_hostsand aHostblock per server), with oneIncludeline at the top of its~/.ssh/config. A group none of whose chats ever selected a server gets no state at all.Taking access away is immediate; granting it waits for the next turn. Turning a server on or off, editing, checking, rekeying or deleting it pushes the new state to every running group it reaches. A push only removes: deleting an element cuts a live SSH session on its next packet, and a member’s directory for a server it may no longer use, or whose key changed, is deleted. A newly enabled server or a new key arrives with the chat’s next turn, whose runner masks the key. If the newest state fails to apply, the manager clears the bridge’s SSH elements and the call fails, so the group stays closed until a state applies whole. A host the control plane cannot reach gets the state with its next turn’s claim.
Checks dial out from the control plane. A check resolves the address and refuses it if any answer is private, reserved or protected, reads the host keys with
ssh-keyscan, and, after the owner confirms a fingerprint, logs in once with the platform key and runstrue. The control plane needs outbound TCP to owners’ SSH ports; setAGENT_EGRESS_PROTECTED_CIDRSon it to the hosts’ value so that checks refuse the same blocks. Each owner may run 20 checks an hour, and a check reads at most 64 KB of each output stream.Owner firewalls. A server that limits who may connect must allow the control plane (for checks) and every host its chats may run on.
Owner model connections
An owner adds their own inference endpoint under Settings → Models
(/settings/models): a name, a Base URL, an API key and up to sixteen model ids.
Verify and save verifies every model before anything is stored. The models
then appear in the composer for the agents that can use them, beside any
provided models, and take precedence over a same-named
provided model for that owner. Turns run on the owner’s key and bill. The
owner model connections entry in
AGENTS.md §7 describes the protocol matrix and the
accepted risks.
Turning it off.
AGENT_MODEL_CONNECTIONS_ENABLEDis on unless set to0,falseorno. Off, it stops new connections and new turns or messages on owners’ connections and provided models alike; admitted turns still run. Set it tofalseduring a rollout to hold new turns until every host and replica runs the new release. It does not stop running work.Key. Keys are encrypted with
AGENT_SOURCE_CONTROL_ENCRYPTION_KEYunder their ownhybridinference/model-connection-key/v1domain; without that key nothing can be saved. No owner route returns a key, and only the host’s authorized claim and residency responses carry it.Verification. Owners do not declare their provider’s APIs. Each model gets a streaming tool call and its result on OpenAI Chat Completions, OpenAI Responses and Anthropic Messages, side by side, and each API’s outcome is stored:
supported,unsupportedorfailed(undetermined). OpenCode, Kilo and pi need Chat Completions, Codex needs Responses, and Claude Code needs Anthropic Messages. Codex and Claude Code can also run on a model whose Chat Completions is supported, through a translator (below). Nothing falls back to another connection, model or API: an unservable pairing is refused at submission and at every claim and residency.Saving. Creating a connection, or an edit that changes its key or Base URL or adds models, verifies before writing anything, with the checks reserved from the owner’s hourly budget first, all or none. The save commits only if every model has an agent that can use it; otherwise it answers
422 model_connection_verification_failedwith each model’s result and writes nothing. An edit that lost a race answers409 model_connection_changed. Verification has a 240-second deadline (504 model_connection_verification_timeout), which every proxy in front of the API must allow. Renaming, removing models, enabling and disabling make no provider call.Network rules. Verification runs only on the owner’s explicit save, with at most six provider requests per model and one of the owner’s 20 hourly checks. It dials only public IPv4 HTTPS on port 443, through the MCP connection policy and the sandbox’s protected ranges (including
AGENT_EGRESS_PROTECTED_CIDRS), pinned to the checked addresses, with no redirects or proxy, and never echoes or logs an upstream body or key.Reasoning levels come only from the provider’s model listings, read with each verification and on Refresh reasoning levels:
GET <Base URL>/models(reasoning.supported_efforts, or DeepSeek’seffort.supported_levels) and the AnthropicGET /v1/models?limit=1000(capabilities.effort). An agent is offered the declared levels its CLI can send, plus Auto, which sends nothing extra. A provider that declares nothing, as OpenAI’s own listing and most self-hosted servers do, leaves its models at Auto only. A level not offered is refused (effort_unknown,effort_unsupportedoreffort_level_unsupported); see reasoning levels.Where requests go. The OpenAI CLIs append
/chat/completionsor/responsesto the Base URL as written. Claude Code appends/v1/messagestoANTHROPIC_BASE_URL, so one trailing/v1is dropped first:https://host,https://host/v1andhttps://host/anthropic/v1all reach…/v1/messages, withx-api-keyandanthropic-version: 2023-06-01.Model ID suggestions. The forms can list the provider’s models through
POST /v1/agent/model-connections/discover-models, with the entered key or a saved one (only at the Base URL it was saved with; otherwise422 model_connection_key_required). It spends one hourly check and writes nothing.Hosts. Runners advertise
model-connections-v1, andmodel-protocol-translation-v1when they can run a translated member; a runner without what a turn needs hands it back without spending an attempt.What a turn does. The claim carries the Base URL, protocol, credential revision and key (masked by the runner), and the residency binds the member to that revision. The CLI gets the key in its environment and activation tmpfs, never in argv. A turn after the key, Base URL or verified path changed starts a new process.
Translated turns. For Codex or Claude Code on a Chat-Completions-only model, the member runs
python3 -I model-protocol-translator.pyz <CLI argv>(installed digest-checked at/usr/local/libexec/), which forks a loopback translator as the same member UID and execs the CLI. The translator forwards only to the connection’s/chat/completions, answers only the member’s own token, refuses what Chat Completions cannot carry (hosted tools such as web search, files,previous_response_id) and dies with the CLI. Codex starts without web search and Claude Code without WebSearch on this path.Changes take effect at once. A verified new key or Base URL, disabling or deleting closes every process on the old state, stopping its turn; renaming or removing models closes nothing.
Scan copies. Binding a key to a residency still records an encrypted copy against the sandbox group, kept after the connection is deleted, though nothing reads it. Deleting a connection does not revoke the key at the provider.
The request meter
Every model request carries a system prompt and tool schemas ahead of the conversation. No CLI reports their size and the platform stores neither, so the member’s loopback service measures each request as it passes and writes the sizes, never the text, on the CLI’s stderr. The conversation’s Context tab shows them as estimates in Token Stats and the Context Browser, and as not recorded until one of the conversation’s turns is measured. A CLI or a sibling member can forge a record, so records are only shown to the owner and nothing acts on them; the request meter entry in AGENTS.md §7 describes the boundary.
Where it runs. On a translated turn, the translator measures. Every other turn, on an owner’s connection or a provided one, starts its CLI behind the same launcher (
model-protocol-translator.pyz) with the service in passthrough: bound to one upstream origin (for a provided model, the host’smodel-tunnel), it holds no key and forwards requests and answers unchanged. The CLI is toldhttp://127.0.0.1:<port>/<authority><path>, which keeps the provider’s host in the URL for CLIs that recognize a provider by it. Claude Code onapi.anthropic.comis not metered, because it decides features such as MCP tool search from the host it is pointed at (FIRST_PARTY_HOSTSincloud_agent_host/runtimes/base.py).It never holds up a turn. If the service cannot start, or does not report ready within 10 seconds, the launcher points the CLI at the provider directly and says so on the CLI’s stderr. A request body over 16 MiB, or one the meter cannot parse, is forwarded unmeasured, and a record that finds the CLI’s stderr backed up is dropped. No setting turns the meter off.
Records and events. A record is a stderr line starting with
\x1emodel-request-prefix, holding the character counts of the system prompt and of each tool (the largest 200) and a fingerprint of the exact prefix. The host takes these lines out of the stderr it keeps for diagnostics and reports each distinct prefix once per turn, up to 20, as alifecycleevent withphase: "request_prefix". A conversation’s own prefix is the first with tools in an attempt (a title or summary request offers none, and a subagent’s comes later): Token Stats shows the latest measured turn’s, and the Context Browser shows each request’s attempt’s, with its tools by size.
Signing in at a provider for a key
A deployment can name one model provider where an owner creates an account, or signs in to the one they have, and comes back with a key of their own. The owner never copies a key: the composer’s set-up notice and Settings → Models show Create or link a provider account while the owner has no connection with that provider’s Base URL. The flow follows OpenRouter’s PKCE key flow (design).
The browser asks
POST /v1/agent/model-sign-in. The control plane stores a single-use state for the owner, with a PKCE verifier only it holds (encrypted, ten minutes), and answers the provider’s authorization page withcallback_url,code_challengeandcode_challenge_method=S256added. The callback is<web app URL>/settings/models/connected?state=….At the provider, the owner signs up or signs in, and approves a key. The provider sends the browser back to the callback with a one-time
codeadded, or witherrorif the owner declined.The callback page sends the code and the state to
POST /v1/agent/model-sign-in/finish. The control plane consumes the state for that owner and re-checks the setting and the owner’s connections. It reserves the hourly checks for the configured models; models already on another of the owner’s connections are skipped. Only then does it exchange the code and the verifier at the key exchange URL: a JSON POST ofcode,code_verifierandcode_challenge_method, answered with{"key": "…"}. That call follows the same address rules as verification.The key is verified on each configured model, and a connection named after the provider is saved with the models an agent can use. It is an ordinary connection from then on.
Anything refused before step 3 issues no key. If the provider issues a key and no model verifies, or verification times out, nothing is saved here, and the message says the key can be deleted at the provider.
An owner may start five sign-ins an hour, finished or not; the sixth gets 429
model_sign_in_rate_limited. Every sign-in that comes back makes the control
plane exchange a code. A provider that limits failed exchanges per client
address counts all of them against the control plane’s one address, so
without this cap one account sending back made-up codes could use up that
allowance for every owner.
Configure it under Admin → Settings → Models → Provider sign-in. Fill in
the provider’s name, its authorization page URL, its key exchange URL, the
inference Base URL the connection uses, and up to sixteen model ids.
Then register <web app URL>/settings/models/connected as an allowed callback
with the provider. The web app URL (AGENT_WEB_BASE_URL) must be set. With any
of these empty, nothing is offered and both routes refuse. None of these
settings has an environment variable. This obtains the owner’s own key and
nothing else: it signs no one in to Cloud Agent, decides no admission, and
never runs during a turn (AGENTS.md §5).
Models the provider keeps for this deployment
A provider may serve some models to this deployment’s tasks only. An owner’s
key cannot prove a request is one of them: the owner can read their key at the
provider, and a sandbox holds it. The provider therefore issues the deployment
a secret and asks for it with each request, in the X-Application-Secret
header
(AGENTS.md §7).
Save it as Application secret in the same section. It is optional, takes at least 32 printable characters without spaces, and has no environment variable. While it is set, for every connection whose Base URL is on the inference Base URL’s host, whether sign-in made it or its owner typed it:
Verification, the model listing and the reasoning-level read send the secret.
A task on the connection reaches the provider through the model relay, as a task on a provided model does. The agent holds a placeholder, and the relay adds the owner’s key and the secret. Neither enters the sandbox. The relay records no use for these requests, since the owner’s provider bills the owner, and passes the provider’s answer through unchanged.
The secret is sent to that host and to no other.
Before you set it:
Upgrade every server that has a model relay. Only a server advertising
model-relay-owner-v1runs such a task, and a task waits until one is free. A deployment with no model relay should leave the secret empty.Register the same secret with the provider for this deployment. On the HybridInference Gateway, add
<web app host>=<secret>toAPI_KEY_AUTHORIZATION_APPLICATION_SECRETS, and list the models inAPI_KEY_AUTHORIZATION_RESERVED_MODELS.Add the model ids to the Models setting, so new sign-ins list them. An owner who already has the connection adds them on Settings → Models.
Setting or clearing the secret starts a new agent process on each connection’s next task; a task already running keeps the way it started. The model requests of these tasks pass through the control plane, so allow for that traffic. What an owner runs in their own sandbox during a running task can reach the provider through the relay too.
Provided models
A deployment can offer models of its own. An administrator saves a provider’s Base URL and the deployment’s key under Admin → Settings → Models; the connection offers every model the provider lists for that key, and every admitted owner finds them in the composer with nothing to set up. The provided models entry in AGENTS.md §7 describes the boundaries.
Where the key is. Only in the control plane, encrypted under the settings
root key. A member’s CLI on a provided model points at the host’s model-tunnel
and holds a residency placeholder (amd.) as its API key. The tunnel ends at the
control plane’s model relay (create_model_relay_app, port 8002), which
resolves the placeholder to the running turn, checks that the turn runs on that
connection, forwards only the inference and model-listing paths an agent CLI
calls, for listed models, to the connection’s Base URL with the deployment’s
key, and records what the answer says it used. Stop, a finished turn, a rotated
residency or a removed host takes effect on the next request.
Models and prices. The save reads the provider’s listing (GET …/models) and
offers what it lists, so limit the key at the provider to the models you want to
provide. An unreadable or empty listing, or one with more than 16 models, is
refused. Every model is verified like an owner’s, and one that no agent can use
is offered to nobody. Read models again picks up a changed listing. Prices
come from the listing’s pricing object (prompt, completion, and optionally
input_cache_reads and input_cache_writes, in US dollars per million tokens);
a model without one is recorded by tokens alone. A model ID can come from at most
one provided connection, and an owner’s own enabled connection offering the same
model takes precedence for that owner.
What a request records. When an answer ends, the relay adds its reported tokens, and their cost at the listed prices (rounded half up to a millionth of a dollar per request, as the inference gateway computes it), to the owner’s use for the day. An answer with no usage, or one cut short, is recorded by estimate (one token per four bytes of text; 85, 200 or 1,000 tokens per image, audio clip or video), and the usage table counts those separately. A request the provider did not serve records nothing.
Nothing limits use here. There is no budget, quota or cap, per owner or per model. The provider’s own budget and limits on the key bound spending, so set them there, knowing that one owner’s heavy use spends them for everyone. The recorded cost is arithmetic on listed prices, not a bill.
Setting it up. The control plane always runs the model-relay service on
127.0.0.1:8002 (AGENT_MODEL_RELAY_BIND / AGENT_MODEL_RELAY_PORT; keep it off
the public edge), refusing every request until a provided connection is enabled.
Every host has a model-tunnel service, idle until Add server gives it a
destination: its own SSH key and account on the control-plane machine, allowed
only that forward, plus AGENT_SANDBOX_MODEL_RELAY_URL and
AGENT_MODEL_TUNNEL_* in the host’s configuration. Such a host advertises
model-relay-v1; only those hosts get turns on provided models, and the admin
page warns while there are none.
Make sure at least one host advertises the model relay. Give a server set up before the model tunnel existed a new setup under Admin → Servers. A host that Add server did not set up needs a
model-tunnelkey of its own (AGENT_MODEL_TUNNEL_*) on its own account, allowed that one forward, andAGENT_SANDBOX_MODEL_RELAY_URL=http://agent-models:8000:command="",restrict,port-forwarding,permitopen="127.0.0.1:8002" ssh-ed25519 AAAA... models
In Admin → Settings → Models, add the connection (a name, the Base URL and the key), let the save verify it, then enable it.
Operating it:
A new key closes nothing, because no process holds it. A new Base URL, disabling and deleting close every member process on the connection.
The relay is on the path. Requests and answers pass through the control plane, which stores and logs none of their content: one log line per request (job, account id, model, status, duration) and
agent_model_relay_chargedfor its recorded use. Amodel-relayrestart, as in a control-plane release, cuts answers in flight; CLIs retry, and cut answers are recorded by estimate.Use that could not be written is retried after 1, 2, 5, 10, 30, 60 and 120 seconds, then every 5 minutes (
agent_model_relay_charge_retry,agent_model_relay_charged_late). A stopping relay logsagent_model_relay_charge_lostfor records it could not write, andagent_model_relay_charge_unknownfor one that may have landed.A refused key. If the provider answers
401, the relay answers502, logsagent_model_relay_key_refused, and the admin page shows since when, until a request succeeds or the key is replaced.Nothing falls back between a provided connection and an owner’s own.
AGENT_MODEL_CONNECTIONS_ENABLEDswitches both off.Claude Code decides some features from the host name it is pointed at, so a provided connection to its vendor’s own API behaves like any third-party endpoint.
Reusable cloud environments
Environments are always available: Settings, task selection and the Environment
tab always show them, and /config always returns environment limits. A task without an
environment keeps the base environment and runs no preparation.
Environment variables and Secrets are encrypted with
AGENT_SOURCE_CONTROL_ENCRYPTION_KEY under a separate
hybridinference/environment-variable/v1 domain. Back up this key with the
credential store; changing it without re-encryption makes old bindings
unreadable. Owner read and history APIs never return Secrets.
Environment tests obey the deployment pin, compute admission, replica attestation and host slot limits. Each reserves one local slot on a background worker, so other slots keep claiming coding tasks, and gets read-only source credentials with no inference, MCP or repository write grants. Cancelling fences the result at once, but the slot stays leased until cleanup is confirmed or the lease expires; the reaper expires leases and 30-minute executions. A host that returns with expired tests removes their labelled containers before it acknowledges cleanup, and claims nothing new until then. Do not delete unrelated groups, or bypass lease and container identity checks, to free capacity.
Host state. Keep these directories, in the host credential directory, across sandbox manager restarts:
environment-preparationholds preparation receipts: binding, container and boot identities and masked steps, never values. Installation succeeds once per fixed workspace, and startup runs once per boot. A failed step stays visible in the Environment tab and can be retried against the original binding.environment-actionsholds manual-action receipts. Each reserves its run before launching the command and keeps the masked result after the terminal is gone. Deleting the directory removes the host’s replay fence for requests whose acknowledgement was lost. An interrupted launch without a recoverable result is reported asunknownand never replayed automatically; check its external effects before starting a new run with a different idempotency key.
The output of tests, preparation and actions is stored masked and bounded, with each NUL and unpaired surrogate replaced by U+FFFD, because Postgres stores neither. Archived, unreferenced environment versions are collected after 30 days; existing workspace and test bindings keep their encrypted values for redaction.
Setup, startup and actions share executable package data in
/workspace/.cloud-agent-tools, excluded through Git’s local exclude file, and
member credential homes stay private. A runtime refresh applies from the next
turn, and running services keep their old values. Startup recovery allows one
further human turn; it is never a permanent success.
Owner-provided credentials can be read and sent outside by user code over the normal network. Masking known values does not cover encoded secrets, raw owner terminals or files, or Git pushes, and nothing on the platform scans a push. Platform-held long-lived credentials, reserved variable names and the fixed network stay protected.
Team environments
A team’s owner and admins can create environments for the team: in Settings → Environments, New environment or Copy offers the teams they own or administer. Every active member sees them there and in the new-task picker, marked with the team’s name, and can view, test, copy and choose them. Only the owner and admins can edit, restore, remove, rebuild or delete snapshots (anyone else gets 403), and creating, editing and removing a team environment is recorded in the team’s audit log. See Teams §6.
Each member’s own container. A team environment is shared configuration, not a shared workspace. A member’s task runs in that member’s own container, with the team’s variables and scripts, the member’s own model and MCP connections, and the member’s personal global variables at run time only (install-only ones are left out, and the team’s definition of a name wins). The installation is therefore the same for every member, which lets the team share snapshots.
Secrets are shared. Every member who can run a task with a team environment can read its Secrets from inside that task, as the dialog says. Treat them as known to the whole team, and rotate one after a member who should not keep it leaves.
Leaving. A binding records the team and the member’s access generation. When a member leaves or is removed, or the team is deleted, each of their conversations on a team environment fails its next turn at claim with
team_environment_revoked(403, logged asagent_job_team_environment_revoked); a running turn finishes. Terminals, actions, Fork, preparation and runtime refresh on such a conversation return 409. Rejoining does not revive old conversations, and a repository default naming a team environment the member can no longer use is cleared at their next task.Removal. Removing a team environment clears every member’s default that names it; conversations already bound keep their fixed configuration.