2026-02-04 03:46:46 +05:30
|
|
|
|
# HEARTBEAT.md
|
|
|
|
|
|
|
2026-02-05 15:11:27 +05:30
|
|
|
|
> This file is provisioned from HEARTBEAT_LEAD.md or HEARTBEAT_AGENT.md. If you see this template directly, follow the agent loop below.
|
|
|
|
|
|
|
2026-02-04 19:15:51 +05:30
|
|
|
|
## Purpose
|
2026-02-05 15:11:27 +05:30
|
|
|
|
This file defines the single, authoritative heartbeat loop for non-lead agents. Follow it exactly.
|
2026-02-04 19:15:51 +05:30
|
|
|
|
|
2026-02-04 03:46:46 +05:30
|
|
|
|
## Required inputs
|
|
|
|
|
|
- BASE_URL (e.g. http://localhost:8000)
|
2026-02-04 14:58:14 +05:30
|
|
|
|
- AUTH_TOKEN (agent token)
|
2026-02-04 03:46:46 +05:30
|
|
|
|
- AGENT_NAME
|
2026-02-04 20:21:33 +05:30
|
|
|
|
- AGENT_ID
|
2026-02-04 16:04:52 +05:30
|
|
|
|
- BOARD_ID
|
2026-02-04 03:46:46 +05:30
|
|
|
|
|
2026-02-04 20:21:33 +05:30
|
|
|
|
If any required input is missing, stop and request a provisioning update.
|
|
|
|
|
|
|
2026-02-04 15:16:28 +05:30
|
|
|
|
## Schedule
|
2026-02-04 17:05:58 +05:30
|
|
|
|
- Schedule is controlled by gateway heartbeat config (default: every 10 minutes).
|
2026-02-04 15:16:28 +05:30
|
|
|
|
- On first boot, send one immediate check-in before the schedule starts.
|
|
|
|
|
|
|
2026-02-04 19:15:51 +05:30
|
|
|
|
## Non‑negotiable rules
|
|
|
|
|
|
- Task updates go only to task comments (never chat/web).
|
2026-02-05 03:05:14 +05:30
|
|
|
|
- Comments must be markdown. Write naturally; be clear and concise.
|
2026-02-04 19:15:51 +05:30
|
|
|
|
- Every status change must have a comment within 30 seconds.
|
|
|
|
|
|
- Do not claim a new task if you already have one in progress.
|
|
|
|
|
|
|
|
|
|
|
|
## Pre‑flight checks (before each heartbeat)
|
|
|
|
|
|
- Confirm BASE_URL, AUTH_TOKEN, and BOARD_ID are set.
|
|
|
|
|
|
- Verify API access:
|
2026-02-04 20:21:33 +05:30
|
|
|
|
- GET $BASE_URL/healthz must succeed.
|
2026-02-04 19:15:51 +05:30
|
|
|
|
- GET $BASE_URL/api/v1/boards must succeed.
|
|
|
|
|
|
- GET $BASE_URL/api/v1/boards/{BOARD_ID}/tasks must succeed.
|
|
|
|
|
|
- If any check fails, stop and retry next heartbeat.
|
|
|
|
|
|
|
|
|
|
|
|
## Heartbeat checklist (run in order)
|
2026-02-04 03:46:46 +05:30
|
|
|
|
1) Check in:
|
|
|
|
|
|
```bash
|
|
|
|
|
|
curl -s -X POST "$BASE_URL/api/v1/agents/heartbeat" \
|
2026-02-04 14:58:14 +05:30
|
|
|
|
-H "X-Agent-Token: $AUTH_TOKEN" \
|
2026-02-04 03:46:46 +05:30
|
|
|
|
-H "Content-Type: application/json" \
|
2026-02-04 16:04:52 +05:30
|
|
|
|
-d '{"name": "'$AGENT_NAME'", "board_id": "'$BOARD_ID'", "status": "online"}'
|
2026-02-04 03:46:46 +05:30
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
2) List boards:
|
|
|
|
|
|
```bash
|
|
|
|
|
|
curl -s "$BASE_URL/api/v1/boards" \
|
2026-02-04 14:58:14 +05:30
|
|
|
|
-H "X-Agent-Token: $AUTH_TOKEN"
|
2026-02-04 03:46:46 +05:30
|
|
|
|
```
|
|
|
|
|
|
|
2026-02-04 20:21:33 +05:30
|
|
|
|
3) For the assigned board, list tasks (use filters to avoid large responses):
|
|
|
|
|
|
```bash
|
|
|
|
|
|
curl -s "$BASE_URL/api/v1/boards/{BOARD_ID}/tasks?status=in_progress&assigned_agent_id=$AGENT_ID&limit=5" \
|
|
|
|
|
|
-H "X-Agent-Token: $AUTH_TOKEN"
|
|
|
|
|
|
```
|
2026-02-04 03:46:46 +05:30
|
|
|
|
```bash
|
2026-02-04 20:21:33 +05:30
|
|
|
|
curl -s "$BASE_URL/api/v1/boards/{BOARD_ID}/tasks?status=inbox&unassigned=true&limit=20" \
|
2026-02-04 14:58:14 +05:30
|
|
|
|
-H "X-Agent-Token: $AUTH_TOKEN"
|
2026-02-04 03:46:46 +05:30
|
|
|
|
```
|
|
|
|
|
|
|
2026-02-04 19:15:51 +05:30
|
|
|
|
4) If you already have an in_progress task, continue working it and do not claim another.
|
2026-02-04 03:46:46 +05:30
|
|
|
|
|
2026-02-04 19:15:51 +05:30
|
|
|
|
5) If you do NOT have an in_progress task, claim one inbox task:
|
2026-02-05 03:05:14 +05:30
|
|
|
|
- Move it to in_progress AND add a markdown comment describing the update.
|
2026-02-04 19:08:14 +05:30
|
|
|
|
|
2026-02-04 19:15:51 +05:30
|
|
|
|
6) Work the task:
|
|
|
|
|
|
- Post progress comments as you go.
|
|
|
|
|
|
- Completion is a two‑step sequence:
|
2026-02-05 03:05:14 +05:30
|
|
|
|
6a) Post the full response as a markdown comment using:
|
2026-02-04 19:15:51 +05:30
|
|
|
|
POST $BASE_URL/api/v1/boards/{BOARD_ID}/tasks/{TASK_ID}/comments
|
2026-02-05 03:05:14 +05:30
|
|
|
|
Example:
|
|
|
|
|
|
```bash
|
|
|
|
|
|
curl -s -X POST "$BASE_URL/api/v1/boards/$BOARD_ID/tasks/$TASK_ID/comments" \
|
|
|
|
|
|
-H "X-Agent-Token: $AUTH_TOKEN" \
|
|
|
|
|
|
-H "Content-Type: application/json" \
|
|
|
|
|
|
-d '{"message":"- Update: ...\n- Result: ..."}'
|
|
|
|
|
|
```
|
2026-02-04 19:15:51 +05:30
|
|
|
|
6b) Move the task to review.
|
2026-02-04 19:08:14 +05:30
|
|
|
|
|
2026-02-04 19:15:51 +05:30
|
|
|
|
6b) Move the task to "review":
|
2026-02-04 03:46:46 +05:30
|
|
|
|
```bash
|
|
|
|
|
|
curl -s -X PATCH "$BASE_URL/api/v1/boards/{BOARD_ID}/tasks/{TASK_ID}" \
|
2026-02-04 14:58:14 +05:30
|
|
|
|
-H "X-Agent-Token: $AUTH_TOKEN" \
|
2026-02-04 03:46:46 +05:30
|
|
|
|
-H "Content-Type: application/json" \
|
|
|
|
|
|
-d '{"status": "review"}'
|
|
|
|
|
|
```
|
2026-02-04 19:08:14 +05:30
|
|
|
|
|
|
|
|
|
|
## Definition of Done
|
|
|
|
|
|
- A task is not complete until the draft/response is posted as a task comment.
|
2026-02-05 03:05:14 +05:30
|
|
|
|
- Comments must be markdown.
|
2026-02-04 03:46:46 +05:30
|
|
|
|
|
2026-02-04 19:15:51 +05:30
|
|
|
|
## Common mistakes (avoid)
|
|
|
|
|
|
- Changing status without posting a comment.
|
|
|
|
|
|
- Posting updates in chat/web instead of task comments.
|
|
|
|
|
|
- Claiming a second task while one is already in progress.
|
|
|
|
|
|
- Moving to review before posting the full response.
|
2026-02-05 03:05:14 +05:30
|
|
|
|
- Sending Authorization header instead of X-Agent-Token.
|
2026-02-04 19:15:51 +05:30
|
|
|
|
|
|
|
|
|
|
## Success criteria (when to say HEARTBEAT_OK)
|
|
|
|
|
|
- Check‑in succeeded.
|
|
|
|
|
|
- Tasks were listed successfully.
|
|
|
|
|
|
- If any task was worked, a markdown comment was posted and the task moved to review.
|
|
|
|
|
|
- If any task is inbox or in_progress, do NOT say HEARTBEAT_OK.
|
|
|
|
|
|
|
2026-02-04 03:46:46 +05:30
|
|
|
|
## Status flow
|
|
|
|
|
|
```
|
|
|
|
|
|
inbox -> in_progress -> review -> done
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
Do not say HEARTBEAT_OK if there is inbox work or active in_progress work.
|