OpenClaw Heartbeats
Heartbeats turn your AI agent from reactive to proactive. Instead of waiting for commands, your agent periodically checks email, calendar, weather, and business metrics on its own.
How Heartbeats Work
Every ~30 Minutes
OpenClaw sends a heartbeat poll to your agent's main session.
Agent Reads HEARTBEAT.md
The agent checks your HEARTBEAT.md file for instructions on what to monitor.
Check → Act or Stay Quiet
If something needs attention, the agent notifies you. Otherwise, it replies HEARTBEAT_OK silently.
The beauty of heartbeats is they run in the main session, meaning your agent has full conversational context. It knows what you discussed earlier, what projects you're working on, and can make intelligent decisions about what's worth reporting.
Configuring HEARTBEAT.md
Example HEARTBEAT.md
# HEARTBEAT.md
## Checks (rotate through these, 2-4 per heartbeat)
### Email
- Check for unread emails from important senders
- Flag anything urgent, summarize the rest
### Calendar
- Any events in the next 2 hours?
- Remind me 30 min before meetings
### Weather
- Check if weather has changed significantly
- Alert if rain/storms expected
### Projects
- Run git status on active repos
- Check if any CI builds failed
## Quiet Hours
- 23:00 - 08:00: HEARTBEAT_OK unless urgent
- During focused work: minimal interruptionsKeep your HEARTBEAT.md concise. Every line gets read on each heartbeat, so shorter files = fewer tokens = lower cost.
⚠️ Token Optimization
HEARTBEAT.md is injected into every heartbeat session. A 500-word file means ~750 tokens per heartbeat. At 48 heartbeats/day, that's ~36,000 tokens just for instructions — roughly $0.10-0.50/day depending on your model.
- • Keep HEARTBEAT.md under 200 words
- • Move heavy tasks to cron jobs instead
- • Use a cheaper model for heartbeat sessions
Smart State Tracking
Your agent can track what it's already checked using a state file, avoiding redundant checks and distributing tasks across heartbeats efficiently.
heartbeat-state.json
{
"lastChecks": {
"email": 1741665600,
"calendar": 1741662000,
"weather": 1741648800,
"projects": 1741641600
},
"nextPriority": "email"
}The agent rotates through checks based on timestamps, ensuring each gets attention without doing everything on every heartbeat. This keeps costs low and responses fast.
Heartbeats vs Cron Jobs
💓 Heartbeats
- • Runs in main session with full context
- • Batch multiple checks together
- • Timing can drift (~30 min intervals)
- • Best for lightweight, rotating checks
- • Can reference recent conversations
⏰ Cron Jobs
- • Runs in isolated session
- • Exact timing (9:00 AM sharp)
- • Can use different model/thinking level
- • Best for heavy, scheduled tasks
- • Delivers output directly to channels
Real-World Heartbeat Setup
A Day in the Life of a Heartbeat Agent
Agent wakes up, checks email → "You have 3 emails. One from your client about the project deadline."
Checks calendar → "Meeting with design team in 90 minutes."
Checks weather → Nothing notable → HEARTBEAT_OK (silent)
Checks projects → "CI build failed on main branch. Error in auth module."
Checks email → New client reply → "Client approved the proposal! 🎉"
Total tokens used: ~15,000. Total cost: ~$0.05. Value delivered: priceless.
Keep Your Agent Running Smoothly
Get optimization tips, heartbeat patterns, and automation strategies from the OpenClaw builder community.
Heartbeat FAQ
What is an OpenClaw heartbeat?
A heartbeat is a periodic poll sent to your agent (typically every 30 minutes). The agent checks HEARTBEAT.md for instructions, performs configured checks, and either reports findings or stays quiet.
How much do heartbeats cost?
A quiet heartbeat (HEARTBEAT_OK) uses under 1,000 tokens. Active checks use more depending on what's monitored. Keep HEARTBEAT.md small and use cron for heavy tasks to stay under $1/day.
When should I use heartbeats vs cron?
Heartbeats for lightweight, rotating checks that benefit from conversational context. Cron for exact-time schedules, heavy tasks, and isolated processing with potentially different models.
Can I customize heartbeat frequency?
Yes. Configure the heartbeat interval in your OpenClaw settings. Default is ~30 minutes. You can also set quiet hours so the agent doesn't disturb you overnight.
Make Your Agent Proactive
Set up heartbeats and never miss important emails, meetings, or project issues again.