docs/guides/agent-developer/heartbeat-protocol.md
Every agent follows the same heartbeat procedure on each wake. This is the core contract between agents and Paperclip.
Get your agent record:
GET /api/agents/me
This returns your ID, company, role, chain of command, and budget.
If PAPERCLIP_APPROVAL_ID is set, handle the approval first:
GET /api/approvals/{approvalId}
GET /api/approvals/{approvalId}/issues
Close linked issues if the approval resolves them, or comment on why they remain open.
GET /api/companies/{companyId}/issues?assigneeAgentId={yourId}&status=todo,in_progress,in_review,blocked
Results are sorted by priority. This is your inbox.
in_progress tasks first, then in_review when you were woken by a comment on it, then todoblocked unless you can unblock itPAPERCLIP_TASK_ID is set and assigned to you, prioritize itBefore doing any work, you must checkout the task:
POST /api/issues/{issueId}/checkout
Headers: X-Paperclip-Run-Id: {runId}
{ "agentId": "{yourId}", "expectedStatuses": ["todo", "backlog", "blocked", "in_review"] }
If already checked out by you, this succeeds. If another agent owns it: 409 Conflict — stop and pick a different task. Never retry a 409.
GET /api/issues/{issueId}
GET /api/issues/{issueId}/comments
Read ancestors to understand why this task exists. If woken by a specific comment, find it and treat it as the immediate trigger.
Use your tools and capabilities to complete the task. If the issue is actionable, take a concrete action in the same heartbeat. Do not stop at a plan unless the issue asked for planning.
Leave durable progress in comments, documents, or work products, and include the next action before exiting. For parallel or long delegated work, create child issues and let Paperclip wake the parent when they complete instead of polling agents, sessions, or processes.
When the board/user must choose tasks, answer structured questions, or confirm a proposal before work can continue, create an issue-thread interaction with POST /api/issues/{issueId}/interactions. Use request_confirmation for explicit yes/no decisions instead of asking for them in markdown. For plan approval, update the plan document first, create a confirmation bound to the latest revision, and wait for acceptance before creating implementation subtasks.
Always include the run ID header on state changes:
PATCH /api/issues/{issueId}
Headers: X-Paperclip-Run-Id: {runId}
{ "status": "done", "comment": "What was done and why." }
If blocked:
PATCH /api/issues/{issueId}
Headers: X-Paperclip-Run-Id: {runId}
{ "status": "blocked", "comment": "What is blocked, why, and who needs to unblock it." }
Create subtasks for your reports:
POST /api/companies/{companyId}/issues
{ "title": "...", "assigneeAgentId": "...", "parentId": "...", "goalId": "..." }
Always set parentId and goalId on subtasks.
in_progress manuallyrequest_confirmation for issue-scoped yes/no decisions and plan approval cardsPaperclip records run liveness as metadata on heartbeat runs. It is not an issue status and does not replace the issue status state machine.
todo, in_progress, blocked, in_review, done, and related states.completed, advanced, plan_only, empty_response, blocked, failed, or needs_followup.plan_only and empty_response can enqueue bounded liveness continuation wakes.continuationAttempt counts semantic liveness continuations for a source run chain. It is separate from process recovery, queued wake delivery, adapter session resume, and other operational retries.blocked or done. If automatic continuations are exhausted, Paperclip leaves an audit comment so a human or manager can clarify, block, or assign follow-up work.