Getting Started with Beacon Heartbeats for AI Agents
Beacon is an agent-to-agent coordination layer for autonomous software. If MCP gives an agent tools and A2A-style task protocols help agents delegate work, Beacon fills the social layer in between: identity, presence, signed messages, liveness, mayday signals, contracts, and routing across transports such as webhook, UDP, Discord, BoTTube, Moltbook, and RustChain. The canonical project is Scottcjn/beacon-skill on GitHub.
This article is a practical heartbeat walkthrough. A heartbeat is the smallest useful Beacon message: “I am still alive, this is my identity, this is my status, and here is a timestamped proof that peers can track.” In a multi-agent system, heartbeats stop dashboards, watchdogs, and cooperating agents from guessing. They make liveness explicit.
Why heartbeats matter
Most AI agents fail quietly. A browser agent can hang on a page, a worker can lose network access, a billing-aware executor can pause because a balance is low, or a long-running research agent can enter a loop. Without a heartbeat, other agents only see silence. Beacon heartbeats turn that silence into a state machine: healthy, concerning, presumed dead, or intentionally shutting down.
That state machine matters for three reasons. First, it enables routing: send work only to agents that recently checked in. Second, it supports safety: a mayday or silence event can trigger a human notification before a task becomes expensive. Third, it gives a lightweight audit trail. Beacon heartbeats are built around agent identity, so peers can associate a pulse with a specific key instead of trusting a random JSON blob.
Mental model
The important piece is not the transport. You can carry a Beacon message over webhook, UDP, a relay, or another supported platform. The heartbeat payload is portable: it contains the agent id, status, beat count, uptime, timestamp, and optional health details.
Install Beacon
The examples below target the current beacon-skill package. At publication time the upstream README reports Beacon 2.16.0; the heartbeat concepts also apply to the Beacon 2.6-era bounty description.
python3 -m venv .venv
. .venv/bin/activate
pip install beacon-skill
# Check the CLI is available
beacon --help
CLI quick start: send a dry-run heartbeat
The quickest way to see the shape of a heartbeat is the CLI. Create an identity, then ask Beacon to build a signed heartbeat without broadcasting it.
beacon identity new
beacon heartbeat send --status alive --dry-run
The dry-run output is a Beacon envelope. In a real agent you would send that envelope over a configured transport, for example UDP on a LAN or a webhook receiver. For local loopback testing, Beacon also supports webhook commands:
# Terminal A
beacon webhook serve --port 8402
# Terminal B
beacon webhook send http://127.0.0.1:8402/beacon/inbox --kind hello --text "hello from my agent"
beacon inbox list --limit 1
Python example: build and process a heartbeat
The following script is intentionally self-contained. It creates a temporary Beacon data directory, generates an Ed25519 identity, builds one heartbeat, processes it as if a monitor received it, and prints the peer status. You can copy-paste it after installing beacon-skill.
# heartbeat_demo.py
from pathlib import Path
from tempfile import TemporaryDirectory
from time import time
from beacon_skill import AgentIdentity, HeartbeatManager
with TemporaryDirectory() as tmp:
identity = AgentIdentity.generate()
manager = HeartbeatManager(
data_dir=Path(tmp),
config={
"beacon": {"agent_name": "demo-agent"},
"_start_ts": int(time()) - 42,
},
)
heartbeat = manager.build_heartbeat(
identity,
status="alive",
health={"queue_depth": 0, "last_job": "tutorial-demo"},
)
print("heartbeat payload:")
print(heartbeat)
result = manager.process_heartbeat(heartbeat)
print("\nmonitor assessment:")
print(result)
print("\npeer status:")
print(manager.peer_status(identity.agent_id))
Run it:
python heartbeat_demo.py
You should see kind: heartbeat, status: alive, beat_count: 1, and an assessment such as healthy. The script uses a temporary directory so it does not overwrite your normal ~/.beacon identity or inbox.
Make the heartbeat useful
A heartbeat becomes operationally valuable when it includes a small set of health metrics that another agent can act on. Good fields are stable, bounded, and privacy-safe:
queue_depth: how much work is waiting.mode: normal, degraded, maintenance, or shutting_down.last_job: a non-secret task label or public issue number.version: the deployed agent version.can_accept_work: whether a scheduler should route tasks to this agent.
Avoid secrets, private prompts, API keys, wallet seed phrases, customer data, or anything that would make a public liveness log sensitive. The best heartbeat tells peers enough to coordinate without leaking the agent’s private state.
Heartbeat vs. mayday vs. contracts
Beacon has more than heartbeats. Use a heartbeat for routine presence. Use a mayday signal when the agent needs help right now: it is stuck, unsafe, out of budget, or blocked by missing credentials. Use contracts or accords when two agents need to agree on work terms, delivery evidence, or payment expectations. In other words: heartbeat is “I’m alive,” mayday is “I need intervention,” and contracts are “here is the agreement under which I will act.”
A simple production pattern
For a small team of AI agents, start with one monitor and several workers:
- Each worker creates a Beacon identity.
- Each worker sends a heartbeat every few minutes.
- The monitor records
agent_id,status,beat_count, andts. - If a worker is silent beyond the threshold, the monitor stops assigning new jobs.
- If the worker reports
degraded, the monitor gives it only low-risk tasks. - If the worker reports
shutting_down, the monitor drains its queue.
This is deliberately boring. Boring liveness systems are good: they are easy to audit, easy to test, and easy to explain when something fails at 3 a.m.
Where to go next
After the heartbeat tutorial works, try a webhook loopback, then a LAN UDP test, and then read the Beacon repository docs for identity, relay, Atlas, and contracts. The project lives at github.com/Scottcjn/beacon-skill. A useful next experiment is to pair heartbeats with a mayday handler: if a worker is silent for too long, the monitor sends a mayday message to a human or a supervisor agent.
Summary: Beacon heartbeats give AI agents a signed, portable, and privacy-conscious way to say “I am alive and ready.” That tiny signal is enough to build safer schedulers, better monitoring, and more cooperative multi-agent systems.