fix(broker): record a spawned worker's cli, host and owner
Why
Workers a fleet broker spawns are registered through the node with no owner or machine in their Relaycast metadata. Agent Relay Desktop decides "this agent is mine" from owner_hash and groups agents by host, so a worker spawned on your own fleet node (for example code-desktop-cool@finn-mini) is listed under Other live agents instead of under Me. And a worker whose name has no claude-/codex- prefix gets no harness icon, because nothing records its CLI.
What
Once a worker has launched, on every hosted credential path (node bind, HTTP fallback, a supplied token, and the API spawn), the detached declared-metadata PATCH also carries:
| key | value |
|---|---|
cli | the CLI the worker runs: a PTY harness's own command, else the requested cli (claude, codex, cursor-agent, ...) |
host | this machine's hostname, without a trailing .local (same as the desktop's label) |
owner_hash | SHA-256 hex of the signed-in Cloud user id (same as the desktop's identity_hash) |
The user id is read from the CLI's stored cloud-identity.json (honouring AGENT_RELAY_DATA_DIR) at each spawn, off the event loop, so signing in or out applies to the next worker without a restart. The inherited AGENT_RELAY_USER_ID is deliberately not used: it outlives a sign-out, and a broker started by a service manager has none. Unknown values are omitted, never sent blank. The PATCH stays best-effort, detached and a single request.
Verified on a real machine: the CLI's stored userId hashes to exactly the owner_hash Agent Relay Desktop stamps for the same person.
Note: every worker on a node is attributed to the person running that node's broker, including one a teammate spawned there.
Desktop side (reads cli for the icon; Mac roster draws it): AgentWorkforce/relay-desktop fix/roster-cli-icons.
Tests
cargo test -p agent-relay-broker: all pass, including newspawned_worker_metadata_*andpublish_declared_metadata_carries_the_spawned_worker_keys. The twohttp_spawn_*_publishes_declared_metadatatests match the full PATCH body, including this machine'shost/owner_hash.cargo clippy -D warningsfails only on pre-existing Rust 1.98 lints inpty_worker.rsandnode_control.rs, untouched here.
🤖 Generated with Claude Code
[!NOTE]
Medium Risk
Changes agent metadata published to Relaycast on every fleet spawn path and reads cloud identity from disk at spawn time; wrong or missing identity only affects roster attribution, not registration, but behavior is user-visible in Desktop.
Overview
Fleet-spawned workers now publish roster metadata (cli, host, owner_hash) in the same best-effort PATCH /v1/agents/:name used for declared workforce fields, so Agent Relay Desktop can attribute them to the signed-in user and machine (with the correct CLI icon) instead of listing them under “Other live agents”.
The broker builds that map at spawn time from the actual launched CLI (PTY harness command when present), normalized hostname (no .local), and SHA-256 of userId from cloud-identity.json (not AGENT_RELAY_USER_ID). Collection runs on a blocking task; publish is deferred until the worker has launched on every hosted credential path, with duplicate publishes removed from the earlier registration-only hooks in the WS spawn flow.
Also includes a delivery-retry test that models consecutive write failures (macOS pipe quirks) and an integration releaseAgent helper that retries while identity cleanup is still in flight.
Reviewed by Cursor Bugbot for commit 990fa112d4fea80f42c37e4cd4cbd89ba8dfa4ed. Bugbot is set up for automated code reviews on this repo. Configure here.
Agent Relay sessions
claudesession47f66dd9· opened viagh pr create· last active 2026-10-08