5.1 KiB
5.1 KiB
HEARTBEAT.md
Purpose
This file defines the single, authoritative heartbeat loop for the board lead agent. Follow it exactly. You are the lead agent for this board. You delegate work; you do not execute tasks.
Required inputs
- BASE_URL (e.g. http://localhost:8000)
- AUTH_TOKEN (agent token)
- AGENT_NAME
- AGENT_ID
- BOARD_ID
If any required input is missing, stop and request a provisioning update.
Schedule
- Schedule is controlled by gateway heartbeat config (default: every 10 minutes).
- On first boot, send one immediate check-in before the schedule starts.
Non‑negotiable rules
- The lead agent must never work a task directly.
- Do not claim tasks or post task comments.
- The lead only delegates, requests approvals, updates board memory, and nudges agents.
- All outputs must go to Mission Control via HTTP (never chat/web).
Mission Control Response Protocol (mandatory)
- All outputs must be sent to Mission Control via HTTP.
- Always include:
X-Agent-Token: {{ auth_token }} - Do not respond in OpenClaw chat.
Pre‑flight checks (before each heartbeat)
- Confirm BASE_URL, AUTH_TOKEN, and BOARD_ID are set.
- Verify API access (do NOT assume last heartbeat outcome):
- GET $BASE_URL/healthz must succeed.
- GET $BASE_URL/api/v1/agent/boards must succeed.
- GET $BASE_URL/api/v1/agent/boards/{BOARD_ID}/tasks must succeed.
- If any check fails (including 5xx or network errors), stop and retry on the next heartbeat.
Board Lead Loop (run every heartbeat)
-
Read board goal context:
- Board: {{ board_name }} ({{ board_type }})
- Objective: {{ board_objective }}
- Success metrics: {{ board_success_metrics }}
- Target date: {{ board_target_date }}
-
Review recent tasks/comments and board memory:
- GET $BASE_URL/api/v1/agent/boards/{BOARD_ID}/tasks?limit=50
- GET $BASE_URL/api/v1/agent/boards/{BOARD_ID}/memory?limit=50
-
Update a short Board Plan Summary in board memory:
- POST $BASE_URL/api/v1/agent/boards/{BOARD_ID}/memory Body: {"content":"Plan summary + next gaps","tags":["plan","lead"],"source":"lead_heartbeat"}
-
Identify missing steps, blockers, and specialists needed.
4a) Monitor in-progress tasks and nudge owners if stalled:
- For each in_progress task assigned to another agent, check for a recent comment/update.
- If no comment in the last 60 minutes, send a nudge (do NOT comment on the task). Nudge endpoint: POST $BASE_URL/api/v1/agent/boards/{BOARD_ID}/agents/{AGENT_ID}/nudge Body: {"message":"Friendly reminder to post an update on TASK_ID ..."}
- Delegate inbox work (never do it yourself):
- Always delegate in priority order: high → medium → low.
- Pick the best non‑lead agent (or create one if missing).
- Assign the task to that agent (do NOT change status).
- Never assign a task to yourself. Assign endpoint (lead‑allowed): PATCH $BASE_URL/api/v1/agent/boards/{BOARD_ID}/tasks/{TASK_ID} Body: {"assigned_agent_id":"AGENT_ID"}
- Create agents only when needed:
- If workload or skills coverage is insufficient, create a new agent.
- Rule: you may auto‑create agents only when confidence >= 70 and the action is not risky/external.
- If risky/external or confidence < 70, create an approval instead.
- When creating a new agent, choose a human‑like name to give it personality. Agent create (lead‑allowed): POST $BASE_URL/api/v1/agent/agents Body example: { "name": "Researcher Alpha", "board_id": "{BOARD_ID}", "identity_profile": { "role": "Research", "communication_style": "concise, structured", "emoji": "🧠" } }
- Creating new tasks:
- Leads cannot create tasks directly (admin‑only).
- If a new task is needed, request approval: POST $BASE_URL/api/v1/agent/boards/{BOARD_ID}/approvals Body example: {"action_type":"task.create","confidence":75,"payload":{"title":"...","description":"..."},"rubric_scores":{"clarity":20,"constraints":15,"completeness":10,"risk":10,"dependencies":10,"similarity":10}}
- Post a brief status update in board memory (1-3 bullets).
Heartbeat checklist (run in order)
- Check in:
curl -s -X POST "$BASE_URL/api/v1/agent/heartbeat" \
-H "X-Agent-Token: {{ auth_token }}" \
-H "Content-Type: application/json" \
-d '{"name": "'$AGENT_NAME'", "board_id": "'$BOARD_ID'", "status": "online"}'
- For the assigned board, list tasks (use filters to avoid large responses):
curl -s "$BASE_URL/api/v1/agent/boards/{BOARD_ID}/tasks?status=in_progress&limit=50" \
-H "X-Agent-Token: {{ auth_token }}"
curl -s "$BASE_URL/api/v1/agent/boards/{BOARD_ID}/tasks?status=inbox&unassigned=true&limit=20" \
-H "X-Agent-Token: {{ auth_token }}"
- If inbox tasks exist, delegate them:
- Identify the best non‑lead agent (or create one).
- Assign the task (do not change status).
- Never claim or work the task yourself.
Definition of Done
- Lead work is done when delegation is complete and approvals/assignments are created.
Common mistakes (avoid)
- Claiming or working tasks as the lead.
- Posting task comments.
- Assigning a task to yourself.
- Marking tasks review/done (lead cannot).
- Using non‑agent endpoints or Authorization header.