Skip to main content

Synopsis

Description

crucihil agent starts a persistent daemon on the bench machine. The agent:
  1. Loads the rig TOML and connects all configured backends
  2. Establishes a WebSocket connection to the cloud control plane
  3. Listens for run_suite commands pushed from the cloud
  4. Executes tests and syncs results back to the cloud via the WebSocket
  5. Caches results locally in SQLite when the cloud is unreachable, syncing on reconnect
The agent is a long-running process — it exits only on Ctrl-C or a fatal error. In production, it runs as a systemd service.

Options

path
required
Path to the rig TOML config. The file must exist. Short form: -r.
path
default:"~/.crucihil/results.db"
Path to the local SQLite result cache. Created if it does not exist. Results are written here first, then synced to the cloud on connection.
boolean
default:"false"
Enable debug logging including WebSocket frames and backend I/O. Short form: -v.

Cloud connection

The agent connects to the cloud when [rig.cloud] is present in the rig TOML:
On first boot with a registration_token, the agent:
  1. Calls POST /api/v1/rigs/register with the token
  2. Receives a permanent API key
  3. Saves the key to ~/.crucihil/credentials.toml
  4. Connects the WebSocket using the new key
On subsequent boots, the agent reads the saved key from credentials — no token needed. Without a [rig.cloud] section, the agent runs in local-only mode: tests can be triggered via crucihil run but the cloud dashboard and MCP tools will not see this rig.

WebSocket protocol

The agent maintains a single persistent WebSocket connection to /ws/agent on the control plane. The protocol uses JSON messages: The connection uses JWT auth. If the connection drops, the agent reconnects with exponential backoff. Queued runs that arrived while the agent was offline are redelivered by the cloud on reconnect.

Local result cache

Results are written to the SQLite cache before being synced to the cloud. This ensures no results are lost even if the cloud is unreachable during a test run. The sync happens automatically when the WebSocket reconnects. The cache path defaults to ~/.crucihil/results.db. Override with --cache.

Production deployment with systemd

CruciHiL ships a systemd template unit for running the agent as a service.

Install the service

This installs systemd/crucihil-agent@.service to /etc/systemd/system/.

Enable for a rig

The @bench_01 suffix maps to rigs/bench_01.toml — the unit file looks for the TOML at /opt/crucihil/rigs/<instance_name>.toml.

Service unit

Check status

Environment variables

The agent respects these environment variables for cloud connectivity:

Example startup output

Exit codes

See also