Skip to content
Rezha Julio
Go back

Reducing OpenClaw Heartbeat Token Usage

4 min read

Running an AI agent 24/7 sounds cool until you see the token bill. One of the biggest culprits? Heartbeats, those periodic check-ins that keep your agent aware.

Here’s how I cut mine down.

What Are Heartbeats?

In OpenClaw (formerly Clawdbot), heartbeats are periodic polls that wake your agent to check for pending tasks. The default behavior:

  1. Agent receives a heartbeat prompt
  2. Agent reads HEARTBEAT.md and workspace context
  3. Agent either takes action or replies HEARTBEAT_OK

Every heartbeat consumes tokens for:

At the default 30-minute interval, that’s 48 heartbeats per day. The tokens add up fast.

Strategy 1: Slim Down HEARTBEAT.md

Your HEARTBEAT.md gets read on every single heartbeat. Keep it minimal.

Before (token-heavy):

# Heartbeat Checklist
## Routine Checks
1. Daily Log: Check if memory/YYYY-MM-DD.md exists...
2. Inbox Check: Check urgent emails or notifications...
3. Moltbook Check: Read skills/moltbook/HEARTBEAT.md for full routine...
4. Log Rotation: Check date header in memory/moltbook_activity.md...
5. Self-Correction: If IDENTITY.md or SOUL.md is missing...
## Pending Tasks
- [ ] Retry Moltbook Post (Security)...
- [ ] Retry Moltbook Post (Sandboxing)...

After (lean):

# Heartbeat
- Ensure `memory/YYYY-MM-DD.md` exists
- Check DMs if due (see heartbeat-state.json)

Move pending tasks to cron jobs instead of tracking them in HEARTBEAT.md. Cron jobs run in isolated sessions and don’t bloat your main context.

Strategy 2: Increase the Interval

Edit your ~/.openclaw/openclaw.json (or %USERPROFILE%\.openclaw\openclaw.json on Windows) and add heartbeat configuration:

{
"agents": {
"defaults": {
"heartbeat": {
"every": "60m"
}
}
}
}

The every field accepts duration strings (ms, s, m, h); default unit is minutes. Going from 30 to 60 minutes cuts your heartbeat tokens in half. Hourly check-ins are fine for most agents.

Strategy 3: Use a Cheaper Model

Heartbeats are usually simple “check and respond” operations. They don’t need your most powerful model.

{
"agents": {
"defaults": {
"heartbeat": {
"model": "qwen-portal/coder-model"
}
}
}
}

A lighter model means:

Note: This saves on generation costs. The input context (files, memory) is still loaded, so keeping HEARTBEAT.md small (Strategy 1) is still crucial.

Strategy 4: Replace Heartbeats with Cron Jobs

Heartbeats are convenient but inefficient for scheduled tasks. Compare:

FeatureHeartbeatCron Job
SessionMain (carries context)Isolated (clean slate)
TimingApproximate (~30 min)Exact (cron expression)
Token costHigh (loads full context)Low (minimal context)
Best forQuick checks, batchingScheduled tasks, reports

If your heartbeat is mostly running scheduled tasks, migrate them to cron:

Terminal window
openclaw cron add --name "daily-log-check" \
--schedule "0 9 * * *" \
--message "Ensure memory/$(date +%Y-%m-%d).md exists"

Strategy 5: Disable Heartbeats Entirely

If you’re fully cron-driven, turn off heartbeats:

{
"agents": {
"defaults": {
"heartbeat": {
"enabled": false
}
}
}
}

Your agent will only wake for:

No more background token burn.

Quick wins

The math

Say your heartbeat consumes ~2,000 tokens per cycle:

IntervalDaily HeartbeatsDaily Tokens
15 min96192,000
30 min4896,000
60 min2448,000
2 hours1224,000

Doubling your interval = halving your cost. Simple.

Summary

Heartbeats are easy to over-use. Trim your HEARTBEAT.md, bump the interval to 60 minutes, move scheduled work to cron jobs, and consider a lighter model.

Your agent can still respond when you need it without running up the bill.


0 reposts 0 favorites

Comments

You can comment on this blog post by publicly replying to this post using a Mastodon or other ActivityPub/Fediverse account. Known non-private replies are displayed below.

Open Post

Related Posts


Previous Post
The Reality of AI Pair Programming: It's Not Magic, It's Management
Next Post
Adding a Links Section to My Blog