| name | heartbeat |
| description | Agent wake-up and health monitoring protocol. 9-step startup cycle that grounds the agent in identity, fetches tasks, selects work, and begins execution. Also serves as a periodic health check — detect stalled or dead agents. Scheduled or event-triggered. Triggers on: "heartbeat", "wake up", "agent health", "check agents"
|
/heartbeat
Agent wake-up protocol and health monitoring.
Purpose
Two functions in one. First: the startup ritual every agent runs when it wakes up — a 9-step cycle that establishes identity, checks approvals, fetches available work, selects a task, locks it, understands context, executes, updates status, and optionally delegates sub-work. Second: a monitoring heartbeat that detects stalled, crashed, or unresponsive agents and triggers recovery.
Usage
/heartbeat
/heartbeat --agent researcher
/heartbeat --check-all
/heartbeat --interval 60s
/heartbeat --history --last 10
/heartbeat --wake researcher
Arguments
| Flag | Type | Default | Description |
|---|
--agent | string | self | Agent to run heartbeat for |
--check-all | flag | false | Health check all registered agents |
--interval | duration | 60s | Time between heartbeat pings |
--timeout | duration | 180s | Mark agent as stalled after this silence |
--history | flag | false | Show heartbeat event history |
--last | int | 10 | Number of history entries to show |
--wake | string | — | Force wake-up of a specific agent |
--on-stall | enum | warn | Action on stall: warn, restart, reassign, kill |
Workflow
Wake-Up Cycle (9 steps)
- Identity — Load agent identity: name, role, capabilities, system prompt. Confirm workspace scope and permissions.
- Approvals — Check for any pending approval requests (from
/approve). Process approvals before starting new work.
- Fetch tasks — Query task store for available tasks matching this agent's capabilities. Filter by priority and dependencies.
- Select work — Pick the highest-priority task that isn't locked. Consider: deadline proximity, complexity match, budget remaining.
- Checkout — Lock the selected task via
/checkout. If lock fails (409), return to step 4.
- Understand — Load task context: read referenced files, check parent chain, review related messages in inbox.
- Execute — Perform the task. Use available commands within scope. Track token consumption.
- Update — Write result to task store. Update status:
in_progress → complete or blocked. Send result message to parent.
- Delegate — If sub-tasks were identified during execution, create them via
/delegate. Return to step 3 if more work available.
Health Monitoring
- Ping — Each agent writes a heartbeat file with timestamp every
--interval.
- Check — Monitor reads all heartbeat files. Flag any agent whose last heartbeat exceeds
--timeout.
- Respond — Based on
--on-stall: warn (log + alert), restart (kill + respawn), reassign (release tasks + redistribute), kill (terminate).
Output
Wake-up cycle output
## Heartbeat — researcher (agent-a1b2)
| Step | Status | Detail |
|------|--------|--------|
| 1. Identity | done | researcher / Market Analyst / scope: read-only |
| 2. Approvals | done | 0 pending |
| 3. Fetch tasks | done | 3 available tasks |
| 4. Select work | done | task-d4e5: "Analyze competitor pricing" (priority: high) |
| 5. Checkout | done | Lock acquired |
| 6. Understand | done | Loaded 4 context files (8,200 tokens) |
| 7. Execute | running | ... |
Health check output
## Agent Health — All Agents
| Agent | Status | Last Heartbeat | Current Task | Budget Used |
|-------|--------|---------------|--------------|-------------|
| researcher | healthy | 12s ago | task-d4e5 | 23,400/50,000 |
| writer | healthy | 8s ago | task-f6g7 | 11,200/30,000 |
| analyst | stalled | 4m 12s ago | task-h8i9 | 45,100/50,000 |
| coder | idle | 3s ago | — | 0/100,000 |
### Alerts
- analyst: STALLED (exceeded 180s timeout). Last activity: writing to processed/report.md. Action: warn.
Dependencies
- Agent registry
/checkout — Task locking (step 5)
/inbox — Message checking (step 2) and result delivery (step 8)
/delegate — Sub-task creation (step 9)
/budget — Budget tracking
- File system for heartbeat files