Most AI agents are reactive. You ask, they answer. Session ends, they forget.
The heartbeat pattern flips this. Your agent wakes up on a schedule, checks what needs doing, and acts — without being asked.
Here's how it works.
The Core Idea
A heartbeat is a periodic trigger that fires every N minutes. When it fires, the agent reads a file called HEARTBEAT.md and follows whatever instructions are in it.
Simple HEARTBEAT.md:
# HEARTBEAT.md
When idle: find one task that moves closer to revenue. Execute it. Report results.
That's it. Every 30 minutes, the agent wakes up, reads this, finds something useful to do, and does it.
What Gets Checked
Here's a more detailed heartbeat checklist:
# HEARTBEAT.md
## Periodic Checks (rotate 2-4x per day)
- Email: any urgent unread messages?
- Calendar: events in next 24-48h?
- Projects: anything blocked or overdue?
- Content: anything ready to publish?
## Revenue Tasks
When nothing urgent: find one revenue-moving task.
Examples:
- Publish pending article
- Post to Reddit
- Update sales copy
- Follow up on inquiries
The agent rotates through these, tracks what it last checked, and only acts when something actually needs attention.
The State File
To avoid re-checking things constantly, the agent maintains a state file:
{
"lastChecks": {
"email": 1711015200,
"calendar": 1711008000,
"projects": 1711018800
}
}
Before checking email, it looks at lastChecks.email. If it was less than 2 hours ago, skip it. This prevents the agent from hammering APIs on every heartbeat.
When to Stay Silent
A well-configured heartbeat agent does not interrupt constantly. Rules:
- Late night (23:00-08:00): silent unless urgent
- Nothing new since last check: HEARTBEAT_OK
- Just checked < 30 minutes ago: HEARTBEAT_OK
The goal is proactive, not annoying.
When to Act
The agent speaks up when:
- Important email arrived
- Calendar event < 2 hours away
- Project is blocked
- A task is ready to ship
Otherwise, it does quiet background work — organizing files, updating memory, running checks — and stays out of the way.
The Implementation Pattern
def on_heartbeat():
instructions = read_file("HEARTBEAT.md")
state = read_json("memory/heartbeat-state.json")
# Check what needs attention
for check in get_due_checks(state):
result = run_check(check)
if result.needs_attention:
notify_user(result)
return
# Nothing urgent — do background work
do_background_task(instructions)
update_state(state)
Why This Beats Cron Jobs
Cron jobs run code. Heartbeats run judgment.
A cron job that checks email sends you every email. A heartbeat agent checks email, reads it, decides if it matters, and only interrupts you for the ones that do.
The intelligence is in the loop, not the schedule.
Getting the Structure
The HEARTBEAT.md pattern is part of the AI Agent Workspace Kit:
npx @webbywisp/create-ai-agent my-workspace
Scaffolds HEARTBEAT.md, MEMORY.md, SOUL.md, and the full directory structure. Free.
The complete kit with pre-written templates, heartbeat state tracking, and project memory — $19: AI Agent Workspace Kit
Top comments (0)