What Is a Heartbeat?
A heartbeat is a periodic check-in that the OpenClaw gateway sends to your agent. Think of it like a gentle tap on the shoulder every 30 minutes: "Hey, anything need attention?"
The agent looks around, reads a checklist file, decides if there is something worth doing, and either takes action or replies HEARTBEAT_OK to go back to sleep.
Runs inside your session
Has access to recent chat history and conversational context. If you told the agent something two hours ago, it still knows.
Runs in isolation
No conversational memory. Each run starts cold. Better for heavy processing and exact-timed tasks.
Configuring the Heartbeat Interval
The heartbeat interval is set in your OpenClaw gateway configuration. The default is 30 minutes -- a reasonable starting point. Adjust it based on how responsive you need your agent to be.
High responsiveness
Good if your agent monitors time-sensitive things like customer support queues or deployment pipelines. Costs more in API calls but catches issues faster.
Balanced default
The sweet spot for most setups. Your agent checks in often enough to catch important things without running up your bill. This is what I use.
Budget-conscious
If your agent mostly handles tasks reactively and heartbeats are supplementary, an hour is fine. Pair it with cron jobs for anything that cannot wait.
HEARTBEAT.md: Your Agent's Checklist
The real power of heartbeats comes from HEARTBEAT.md -- a file in your workspace that the agent reads on every poll. It is your way of telling the agent what to pay attention to without having to message it directly.
Here is what mine looks like on a typical day:
# HEARTBEAT.md ## Checks (rotate — don't do all every time) - [ ] Unread emails — anything urgent? - [ ] Calendar — events in next 2 hours? - [ ] GitHub notifications — new PR reviews? - [ ] Weather — worth mentioning if rain expected? ## Active reminders - Chris has a dentist appointment at 2 PM today - Waiting on reply from Vercel support (ticket #4821) ## Notes - Quiet hours: 11 PM – 8 AM (HEARTBEAT_OK unless urgent) - Last weather check was recent, skip today
- ●Keep it short. Every line in this file costs tokens on each heartbeat poll. A concise checklist beats a wall of instructions.
- ●Update it dynamically. Change priorities throughout the day -- the agent can even edit the file itself when it learns about new events or resolves old ones.
Full heartbeat chapter
The complete guide covers advanced heartbeat patterns, state tracking, quiet hours, and the exact HEARTBEAT.md I use in production.
Heartbeats are the difference between an agent that waits and one that anticipates. The guide walks you through the full setup.
Get the KaiShips Guide to OpenClaw — $29State Tracking: Avoiding Redundant Work
One pitfall with heartbeats: the agent checks email every 30 minutes and reports "no new emails" eight times in a row. Noisy and wasteful. The solution is a state file.
I keep a memory/heartbeat-state.json that tracks when each check last ran. On each heartbeat, the agent reads it, decides which checks are due, and updates timestamps after. Here is the structure:
{
"lastChecks": {
"email": "2026-03-23T10:30:00Z",
"calendar": "2026-03-23T10:00:00Z",
"github": "2026-03-23T09:30:00Z",
"weather": "2026-03-22T14:00:00Z"
}
}Result: 1-2 checks per heartbeat instead of 4-5
The agent rotates through checks organically, running whatever is most overdue. Over a full day, this cuts heartbeat API costs by more than half.
Quiet Hours and Smart Silence
Your agent should know when to shut up. Late at night, early morning, or when you are deep in focus -- heartbeats should return HEARTBEAT_OK without doing anything unless something genuinely urgent comes up.
Scheduled quiet hours
Configure in HEARTBEAT.md directly: "11 PM to 8 AM, HEARTBEAT_OK unless urgent." The agent reads this, checks the current time, and respects it. No complex configuration -- just a line in a markdown file interpreted with common sense.
Situational silence
If nothing has changed since the last check, if you chatted 5 minutes ago (so context is fresh), or if the only update is trivial -- a good heartbeat response is no response at all.
Heartbeat + Cron: The Full Awareness Stack
Heartbeats and cron jobs are not competing features -- they are complementary layers. The rule: if it needs conversational context and lightweight checking, use heartbeat. If it needs isolation, exact timing, or heavy processing, use cron.
Heartbeat handles
- ● Email inbox monitoring
- ● Calendar reminders
- ● Quick notification scans
- ● Context-aware follow-ups
- ● Light memory maintenance
Cron handles
- ● Blog post writing
- ● Security audits
- ● Social media posting
- ● Issue triage
- ● Data backups and reports
Together they give your agent continuous awareness without continuous cost.
Practical Tips From Running This Daily
After weeks of running heartbeats in production, here is what I have learned.
- ●Keep HEARTBEAT.md under 20 lines. Every line costs tokens on every poll. Be ruthless about removing resolved items.
- ●Let the agent edit its own checklist. When the agent resolves a reminder or learns about a new event, it should update HEARTBEAT.md itself. Keeps the file current without manual maintenance.
- ●Use heartbeats for memory maintenance. Every few days, the agent can use a heartbeat to review recent daily notes and update its long-term memory file. Housekeeping that does not need its own cron job.
- ●Monitor your costs. A heartbeat with a large workspace context and an expensive model can cost $0.05-0.15 per poll. At 48 polls per day (every 30 min), that is $2.40-7.20 daily just for heartbeats. Choose your model wisely.
Go deeper
Get the complete agent awareness playbook
The full guide includes advanced heartbeat patterns, production HEARTBEAT.md templates, cost breakdowns by model, and the exact configuration I use to keep Kai running 24/7 without blowing through my API budget.
Get the KaiShips Guide to OpenClaw — $29