Skip to main content

First Heartbeat

Benchmarked against: Anthropic — Install an SDK / Try the Workbench Tool: agent_heartbeat Scope: Agent registration and online status

The heartbeat is an agent's "I'm alive" signal. It registers the agent in Cloud UB's agent registry, making it visible on the factory floor and available for work order assignment.


What is a heartbeat?

agent_heartbeat()

This single call:

  1. Registers the agent as online in Cloud UB
  2. Updates the last_seen timestamp
  3. Reports the agent's ship, platform, and current task
  4. Returns registry confirmation

Response:

{
"status": "registered",
"agent_id": "Mac CLI 小克",
"ship": "SS1",
"platform": "mac",
"last_seen": "2026-03-05T10:15:00Z",
"current_task": ""
}

When to send heartbeats

EventRequired?Why
Session startYes — mandatoryRegisters agent online
Task startOptionalUpdates current_task for floor visibility
Periodic (long sessions)OptionalRefreshes last_seen timestamp
Session endNoAgent goes offline naturally

Session start protocol

Every agent session begins with exactly 2 calls:

# 1. Register online
agent_heartbeat()

# 2. Check for messages
check_agent_mailbox()

That's it. No UB reads, no bulletin board checks, no dispatch center queries. Ask the Captain what to do, then read UB on demand for the assigned task.


Agent registry

The agent registry lives in Cloud UB's agent_registry table:

FieldTypeDescription
agent_idStringUnique agent identity
shipStringShip ID (SS1, SS2, SS3)
platformStringmac, win, web
statusStringonline, offline
last_seenTimestampLast heartbeat time
current_taskStringWhat the agent is doing

Visibility on factory floor

After heartbeat, the agent appears on the factory floor:

factory_floor_status()

Shows all agents with their status:

Team Status:
Mac CLI 小克 — online (SS1) — working on WO-2026-0305-001
Mac App 小克 — idle (SS1)
Win CLI 小克 — offline (SS2)

Heartbeat with task context

Report what you're working on:

agent_heartbeat(current_task="Writing docs site Engines section")

This updates the factory floor display so the Captain and other agents know your current focus.


Agent identity system

Each agent has a unique identity composed of: Ship + Interface + Name

IdentityShipInterfaceRole
Mac CLI 小克SS1Claude Code CLIChief Engineer (Opus)
Mac App 小克SS1Claude Desktop App Code tabChief Engineer (Opus)
Mac CLI 小ASS1Claude Code CLIExecutor (Sonnet)
Mac App 小ASS1Claude Desktop AppExecutor (Sonnet)
Win CLI 小克SS2Claude Code CLIChief Engineer
Win App 小克SS2Claude Desktop AppChief Engineer
Web 小克SS3Cloudflare WorkersCloud agent
小西SS1Claude Desktop App Chat tabStrategist

Identity rules

  • Identity is set via SP_AGENT_ID environment variable
  • Must match exactly — typos break routing (messages, WO assignment)
  • One identity per active session — don't run duplicate agents

Offline detection (planned)

Currently, agents go "offline" when they simply stop sending heartbeats. The registry entry persists with its last last_seen timestamp.

Planned improvement: Alert when an expected agent (e.g., Mac CLI 小克 during work hours) misses a heartbeat window. This enables proactive incident detection.


Troubleshooting

SymptomCauseFix
Heartbeat returns errorCloud UB unreachableCheck network, Worker health
Agent shows wrong shipSP_SHIP_ID misconfiguredUpdate environment variable
Agent not on factory floorHeartbeat not sentCall agent_heartbeat()
Duplicate agent entriesMultiple sessions with same IDClose extra sessions

PageRelationship
QuickstartFull first-run guide
Setup MCP & ENVConfiguration
Fleet ManagementFactory floor details
SRE StatusHealth monitoring