An OpenClaw heartbeat burns tokens all day checking an inbox; which heartbeat settings cut its per-run cost, and what does each trade away?
answer
- every tick is a full agent turn
- history versus a fresh session
- bootstrap files on every run
- a cheaper model can bleed
- skips that never call the model
basics
~20 sEach OpenClaw heartbeat is a full agent turn. Cut cost with isolatedSession: true (no chat history), lightContext: true (no workspace bootstrap files), a cheaper model, a longer every and activeHours; each trades away context or judgment.
solid answer
~40 sA heartbeat runs a full agent turn in the main session, so by default it resends the whole conversation history each tick. `isolatedSession: true` runs each heartbeat in a fresh session, which the docs put at roughly 100K tokens down to 2-5K per run, at the price of no conversation awareness; delivery still follows the selected conversation. `lightContext: true` skips the workspace bootstrap files such as `AGENTS.md` and `SOUL.md`; monitor scratch is still injected. A cheaper `model` lowers the price per token, but in a shared session it can leave a small-window model behind for the next real turn, which isolation avoids. A longer `every` and `activeHours` cut the number of turns. `target: "none"` and `directPolicy: "block"` stop delivery, not the model call.
code
json · 13 lines{
"agents": {
"defaults": {
"heartbeat": {
"every": "1h",
"isolatedSession": true,
"lightContext": true,
"timeoutSeconds": 120,
"activeHours": { "start": "08:00", "end": "22:00" }
}
}
}
}go deeper
Recall that every heartbeat is a full model turn, so a shorter interval costs more and a quiet reply is not free.
Explain what isolatedSession and lightContext each strip from the prompt, and what the heartbeat model setting changes.
Separate settings that skip the model call from those that only hide output, and spot model bleed and an unbounded turn timeout in production.
Weigh ambient awareness against spend: decide which checks need main-session context and which belong in cheap isolated monitors or their own jobs.
## Why a heartbeat costs what it costs A heartbeat is not a cheap ping; it is a **full agent turn**. With defaults it runs in the agent's **main session**, so each tick sends the model the system prompt, the workspace bootstrap files, the conversation history of that session, the heartbeat prompt and any monitor scratch. At the default cadence of `30m` that is up to 48 turns a day per agent. Cost is roughly *turns per day x tokens per turn x price per token*, and OpenClaw has a setting for each factor. ## Settings that shrink each turn | Setting | What it removes | What you give up | | --- | --- | --- | | `isolatedSession: true` | conversation history: each heartbeat gets a fresh session (docs: about 100K tokens down to about 2-5K per run) | awareness of recent chats, the main reason to run in the main session | | `lightContext: true` | workspace bootstrap files such as `AGENTS.md`, `SOUL.md`, `USER.md` | persona, operating rules and preferences during the check | | `model: "provider/model"` | price per token, by routing heartbeats to a cheaper model | judgment quality; context-window bleed in a shared session | | small monitor scratch | the checklist resent every tick | breadth of what the check considers | Notes on each: - **`isolatedSession`** uses the same isolation pattern as automation jobs with an isolated session target. Delivery routing still follows the selected conversation, including its channel, account and topic, so alerts still reach the owner. - **`lightContext`** keeps the monitor scratch: the heartbeat runner injects it either way. Combine it with `isolatedSession` for the smallest prompt. - **`model`** has a known trap. Heartbeats preserve the shared session's runtime model after the run, so a heartbeat that switched the main session to a small local model, for example an Ollama model with a 32k window, can leave it in place and the next real turn can hit context overflow. OpenClaw's recovery message names heartbeat model bleed when the session's last model matches `heartbeat.model`. Use `isolatedSession: true`, or pick a heartbeat model whose window fits the shared session. ## Settings that cut the number of turns 1. **Longer `every`**: `1h` halves the turns of `30m`; `0m` stops the recurring cadence. 2. **`activeHours`**: ticks outside the window are skipped before any model call. 3. **Built-in skips**: effectively empty scratch skips as `empty-heartbeat-file`; a heartbeat with no resolvable owner skips as `no-route`; if `showOk`, `showAlerts` and `useIndicator` are all false the run is skipped up front with no model call. 4. **Busy deferral**: scheduled heartbeats defer while the agent or the target session has active or queued work, and a plain poll that has not started waits for its next tick instead of running alongside that work. ## Settings that look like savings but are not - **`target: "none"`** keeps results internal; the docs list it under cost awareness for when you only want internal state updates, but the turn and its model call still happen. - **`directPolicy: "block"`** suppresses direct-message delivery while still running the turn. - **`heartbeatVisibility.showAlerts: false` alone** still runs the heartbeat and only hides the alert payload. ## Bounding a runaway turn A heartbeat turn that starts tool work can run long. With `timeoutSeconds` unset, the turn uses `agents.defaults.timeoutSeconds` when that is set, otherwise the heartbeat cadence capped at 600 seconds. Set `agents.defaults.heartbeat.timeoutSeconds` explicitly when a check needs more or should get less. Continuations after a background command completes use the ordinary agent timeout instead, so the heartbeat timeout does not bound them. ## The inbox case An assistant polling an inbox every 30 minutes in its main session pays for the whole chat history 48 times a day to answer *anything new?* Typical fixes, in order of impact: - run the check isolated and light; - move the inbox sweep into its own automation job with its own schedule if it is really a recurring task (the default heartbeat prompt itself says recurring tasks are automations); - lengthen the cadence and add active hours; - try a cheaper model only after isolating, to avoid model bleed. Measure before and after rather than guessing: the `/usage` chat command's token and cost output and `openclaw system heartbeat last` show what turns cost and why a tick skipped.
- After setting a cheap local heartbeat `model`, an OpenClaw owner's next normal message fails with context overflow; why?The heartbeat ran in the shared main session and OpenClaw preserves that session's runtime model after the run, so the small-window model stayed for the next real turn. The recovery message names heartbeat model bleed when the last model matches `heartbeat.model`. Run heartbeats with `isolatedSession: true`, or choose a heartbeat model whose window fits the shared session.
- Which OpenClaw heartbeat settings skip the model call entirely, rather than only hiding the result?A tick outside `activeHours`, effectively empty monitor scratch (`empty-heartbeat-file`), no resolvable owner for the default target (`no-route`), and all three of `showOk`, `showAlerts` and `useIndicator` set to false each skip before the model runs. `target: "none"`, `directPolicy: "block"` and `showAlerts: false` on its own still run the turn.
- A heartbeat is a cheap health ping, so its interval does not matter.
- target none stops heartbeats from calling the model.
- lightContext drops the monitor scratch along with the bootstrap files.
- A cheaper heartbeat model is always safe in the main session.
- isolatedSession stops heartbeat alerts from reaching the owner.
Assumes OpenClaw 2026.9.9: lightContext still injects the monitor scratch, and the unset heartbeat timeout falls back to the cadence capped at 600 seconds.