Heartbeat (Gateway)
Heartbeat vs Cron? See Cron vs Heartbeat for guidance on when to use each.Heartbeat runs periodic agent turns in the main session so the model can surface anything that needs attention without spamming you.
Quick start (beginner)
- Leave heartbeats enabled (default is
30m, or1hfor Anthropic OAuth/setup-token) or set your own cadence. - Create a tiny
HEARTBEAT.mdchecklist in the agent workspace (optional but recommended). - Decide where heartbeat messages should go (
target: "last"is the default). - Optional: enable heartbeat reasoning delivery for transparency.
- Optional: restrict heartbeats to active hours (local time).
Defaults
- Interval:
30m(or1hwhen Anthropic OAuth/setup-token is the detected auth mode). Setagents.defaults.heartbeat.everyor per-agentagents.list[].heartbeat.every; use0mto disable. - Prompt body (configurable via
agents.defaults.heartbeat.prompt):Read HEARTBEAT.md if it exists (workspace context). Follow it strictly. Do not infer or repeat old tasks from prior chats. If nothing needs attention, reply HEARTBEAT_OK. - The heartbeat prompt is sent verbatim as the user message. The system prompt includes a “Heartbeat” section and the run is flagged internally.
- Active hours (
heartbeat.activeHours) are checked in the configured timezone. Outside the window, heartbeats are skipped until the next tick inside the window.
What the heartbeat prompt is for
The default prompt is intentionally broad:- Background tasks: “Consider outstanding tasks” nudges the agent to review follow-ups (inbox, calendar, reminders, queued work) and surface anything urgent.
- Human check-in: “Checkup sometimes on your human during day time” nudges an occasional lightweight “anything you need?” message, but avoids night-time spam by using your configured local timezone (see /concepts/timezone).
agents.defaults.heartbeat.prompt (or
agents.list[].heartbeat.prompt) to a custom body (sent verbatim).
Response contract
- If nothing needs attention, reply with
HEARTBEAT_OK. - During heartbeat runs, Clawdia treats
HEARTBEAT_OKas an ack when it appears at the start or end of the reply. The token is stripped and the reply is dropped if the remaining content is ≤ackMaxChars(default: 300). - If
HEARTBEAT_OKappears in the middle of a reply, it is not treated specially. - For alerts, do not include
HEARTBEAT_OK; return only the alert text.
HEARTBEAT_OK at the start/end of a message is stripped
and logged; a message that is only HEARTBEAT_OK is dropped.
Config
Scope and precedence
agents.defaults.heartbeatsets global heartbeat behavior.agents.list[].heartbeatmerges on top; if any agent has aheartbeatblock, only those agents run heartbeats.channels.defaults.heartbeatsets visibility defaults for all channels.channels.<channel>.heartbeatoverrides channel defaults.channels.<channel>.accounts.<id>.heartbeat(multi-account channels) overrides per-channel settings.
Per-agent heartbeats
If anyagents.list[] entry includes a heartbeat block, only those agents
run heartbeats. The per-agent block merges on top of agents.defaults.heartbeat
(so you can set shared defaults once and override per agent).
Example: two agents, only the second agent runs heartbeats.
Field notes
every: heartbeat interval (duration string; default unit = minutes).model: optional model override for heartbeat runs (provider/model).includeReasoning: when enabled, also deliver the separateReasoning:message when available (same shape as/reasoning on).session: optional session key for heartbeat runs.main(default): agent main session.- Explicit session key (copy from
clawdia sessions --jsonor the sessions CLI). - Session key formats: see Sessions and Groups.
target:last(default): deliver to the last used external channel.- explicit channel:
whatsapp/telegram/discord/googlechat/slack/msteams/signal/imessage. none: run the heartbeat but do not deliver externally.
to: optional recipient override (channel-specific id, e.g. E.164 for WhatsApp or a Telegram chat id).prompt: overrides the default prompt body (not merged).ackMaxChars: max chars allowed afterHEARTBEAT_OKbefore delivery.
Delivery behavior
- Heartbeats run in the agent’s main session by default (
agent:<id>:<mainKey>), orglobalwhensession.scope = "global". Setsessionto override to a specific channel session (Discord/WhatsApp/etc.). sessiononly affects the run context; delivery is controlled bytargetandto.- To deliver to a specific channel/recipient, set
target+to. Withtarget: "last", delivery uses the last external channel for that session. - If the main queue is busy, the heartbeat is skipped and retried later.
- If
targetresolves to no external destination, the run still happens but no outbound message is sent. - Heartbeat-only replies do not keep the session alive; the last
updatedAtis restored so idle expiry behaves normally.
Visibility controls
By default,HEARTBEAT_OK acknowledgments are suppressed while alert content is
delivered. You can adjust this per channel or per account:
What each flag does
showOk: sends aHEARTBEAT_OKacknowledgment when the model returns an OK-only reply.showAlerts: sends the alert content when the model returns a non-OK reply.useIndicator: emits indicator events for UI status surfaces.
Per-channel vs per-account examples
Common patterns
| Goal | Config |
|---|---|
| Default behavior (silent OKs, alerts on) | (no config needed) |
| Fully silent (no messages, no indicator) | channels.defaults.heartbeat: { showOk: false, showAlerts: false, useIndicator: false } |
| Indicator-only (no messages) | channels.defaults.heartbeat: { showOk: false, showAlerts: false, useIndicator: true } |
| OKs in one channel only | channels.telegram.heartbeat: { showOk: true } |
HEARTBEAT.md (optional)
If aHEARTBEAT.md file exists in the workspace, the default prompt tells the
agent to read it. Think of it as your “heartbeat checklist”: small, stable, and
safe to include every 30 minutes.
If HEARTBEAT.md exists but is effectively empty (only blank lines and markdown
headers like # Heading), Clawdia skips the heartbeat run to save API calls.
If the file is missing, the heartbeat still runs and the model decides what to do.
Keep it tiny (short checklist or reminders) to avoid prompt bloat.
Example HEARTBEAT.md:
Can the agent update HEARTBEAT.md?
Yes — if you ask it to.HEARTBEAT.md is just a normal file in the agent workspace, so you can tell the
agent (in a normal chat) something like:
- “Update
HEARTBEAT.mdto add a daily calendar check.” - “Rewrite
HEARTBEAT.mdso it’s shorter and focused on inbox follow-ups.”
HEARTBEAT.md — it becomes part of the prompt context.
Manual wake (on-demand)
You can enqueue a system event and trigger an immediate heartbeat with:heartbeat configured, a manual wake runs each of those
agent heartbeats immediately.
Use --mode next-heartbeat to wait for the next scheduled tick.
Reasoning delivery (optional)
By default, heartbeats deliver only the final “answer” payload. If you want transparency, enable:agents.defaults.heartbeat.includeReasoning: true
Reasoning: (same shape as /reasoning on). This can be useful when the agent
is managing multiple sessions/codexes and you want to see why it decided to ping
you — but it can also leak more internal detail than you want. Prefer keeping it
off in group chats.
Cost awareness
Heartbeats run full agent turns. Shorter intervals burn more tokens. KeepHEARTBEAT.md small and consider a cheaper model or target: "none" if you
only want internal state updates.