Skip to content

Commit e55f06e

Browse files
committed
docs(heartbeat): align retired config options with fixed runtime policies
The runtime retirement already shipped: busy deferral is automatic, reasoning payloads stay internal, the HEARTBEAT_OK ack budget is fixed at 300 chars, the Heartbeats prompt section follows cadence, and tool-error warnings are always on. Docs still advertised skipWhenBusy, ackMaxChars, includeReasoning, includeSystemPromptSection, and suppressToolErrorWarnings as live options; this aligns seven pages with the fixed policies and the strict heartbeat field list, locks the claw-profile skipWhenBusy rejection diagnostic with a dedicated test, renames includeReasoning-era test/comments, and canonicalizes claw add-plan workspace path assertions (macOS realpath).
1 parent 877ae06 commit e55f06e

13 files changed

Lines changed: 63 additions & 40 deletions

‎docs/automation/index.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ See [Hooks](/automation/hooks).
9595

9696
### Heartbeat
9797

98-
Heartbeat is a periodic main-session turn (default every 30 minutes). It batches checklist-style monitoring (inbox, calendar, notifications) in one agent turn with full session context. Heartbeat turns do not create task records and do not extend daily/idle session reset freshness. Heartbeat scratch is small prompt context; schedule recurring work as cron jobs. Empty heartbeat scratch skips as `empty-heartbeat-file`. Heartbeats defer while cron work is active or queued, and `heartbeat.skipWhenBusy` can also defer an agent while that same agent's session-keyed subagent or nested lanes are busy.
98+
Heartbeat is a periodic main-session turn (default every 30 minutes). It batches checklist-style monitoring (inbox, calendar, notifications) in one agent turn with full session context. Heartbeat turns do not create task records and do not extend daily/idle session reset freshness. Heartbeat monitor scratch is small prompt context; schedule recurring work as cron jobs. Empty scratch skips as `empty-heartbeat-file`. Scheduled heartbeats automatically defer while the main queue or cron work is busy, another reply or embedded run for the same agent is active, or the resolved target session has active or queued work.
9999

100100
See [Heartbeat](/gateway/heartbeat).
101101

‎docs/concepts/system-prompt.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,14 @@ Bootstrap files are resolved from the active workspace and routed to the prompt
9494
- `TOOLS.md`
9595
- `IDENTITY.md`
9696
- `USER.md`
97-
- `HEARTBEAT.md`
9897
- `BOOTSTRAP.md` (only on brand-new workspaces)
9998
- `MEMORY.md` when present
10099

101-
On the native Codex harness, OpenClaw avoids repeating stable workspace files in every user turn. Codex loads `AGENTS.md` through its own project-doc discovery. `TOOLS.md` is forwarded as inherited Codex developer instructions. `SOUL.md`, `IDENTITY.md`, and `USER.md` are forwarded as turn-scoped collaboration developer instructions so native Codex sub-agents do not inherit them. `HEARTBEAT.md` content is not injected directly; heartbeat turns get a collaboration-mode note pointing to the file when it exists and is non-empty. `MEMORY.md` content is not pasted into every native Codex turn either: when memory tools are available for the workspace, Codex turns get a small workspace-memory note directing the model to `memory_search` or `memory_get`. If tools are disabled, memory search is unavailable, or the active workspace differs from the agent memory workspace, `MEMORY.md` falls back to the normal bounded turn-context path. `BOOTSTRAP.md` keeps the normal turn-context role.
100+
On the native Codex harness, OpenClaw avoids repeating stable workspace files in every user turn. Codex loads `AGENTS.md` through its own project-doc discovery. `TOOLS.md` is forwarded as inherited Codex developer instructions. `SOUL.md`, `IDENTITY.md`, and `USER.md` are forwarded as turn-scoped collaboration developer instructions so native Codex sub-agents do not inherit them. `MEMORY.md` content is not pasted into every native Codex turn either: when memory tools are available for the workspace, Codex turns get a small workspace-memory note directing the model to `memory_search` or `memory_get`. If tools are disabled, memory search is unavailable, or the active workspace differs from the agent memory workspace, `MEMORY.md` falls back to the normal bounded turn-context path. `BOOTSTRAP.md` keeps the normal turn-context role.
102101

103-
On non-Codex harnesses, bootstrap files compose into the OpenClaw prompt per their existing gates. `HEARTBEAT.md` is omitted on normal runs when heartbeats are disabled for the default agent or `agents.defaults.heartbeat.includeSystemPromptSection` is false. Keep injected files concise, especially non-Codex `MEMORY.md`: it should stay a curated long-term summary, with detailed daily notes in `memory/*.md` retrievable on demand via `memory_search` / `memory_get`. Oversized non-Codex `MEMORY.md` files increase prompt usage and can be partially injected under the bootstrap file limits below.
102+
Heartbeat monitor scratch is not a bootstrap file. The heartbeat runner appends it only to heartbeat turns; normal turns do not receive it. The default agent's system prompt automatically includes heartbeat guidance while its cadence is enabled, with no independent heartbeat setting to hide that section.
103+
104+
On non-Codex harnesses, the remaining bootstrap files compose into the OpenClaw prompt per their existing gates. Keep injected files concise, especially non-Codex `MEMORY.md`: it should stay a curated long-term summary, with detailed daily notes in `memory/*.md` retrievable on demand via `memory_search` / `memory_get`. Oversized non-Codex `MEMORY.md` files increase prompt usage and can be partially injected under the bootstrap file limits below.
104105

105106
<Note>
106107
`memory/*.md` daily files are **not** part of the normal bootstrap Project Context. On ordinary turns they are accessed on demand via `memory_search` / `memory_get`, so they do not count against the context window unless the model explicitly reads them. Bare `/new` and `/reset` turns are the exception: the runtime can prepend recent daily memory as a one-shot startup-context block for that first turn.

‎docs/gateway/config-agents.md‎

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -543,20 +543,17 @@ Periodic heartbeat runs.
543543
defaults: {
544544
heartbeat: {
545545
every: "30m", // 0m disables
546+
activeHours: { start: "08:00", end: "24:00" },
546547
model: "openai/gpt-5.4-mini",
547-
includeReasoning: false,
548-
includeSystemPromptSection: true, // default: true; false omits the Heartbeat section from the system prompt
549-
lightContext: false, // default: false; true skips workspace bootstrap files for heartbeat runs
550-
isolatedSession: false, // default: false; true runs each heartbeat in a fresh session (no conversation history)
551-
skipWhenBusy: false, // default: false; true also waits for this agent's subagent/nested lanes
552548
session: "main",
553-
to: "+15555550123",
554-
directPolicy: "allow", // allow (default) | block
555549
target: "none", // default: none | options: last | whatsapp | telegram | discord | ...
550+
directPolicy: "allow", // allow (default) | block
551+
to: "+15555550123",
552+
accountId: "ops-bot",
556553
prompt: "Follow the heartbeat monitor scratch context...",
557-
ackMaxChars: 300,
558-
suppressToolErrorWarnings: false,
559554
timeoutSeconds: 45,
555+
lightContext: false, // default: false; true skips workspace bootstrap files for heartbeat runs
556+
isolatedSession: false, // default: false; true runs each heartbeat in a fresh session (no conversation history)
560557
},
561558
},
562559
},
@@ -565,13 +562,13 @@ Periodic heartbeat runs.
565562

566563
- `every`: duration string (ms/s/m/h). Default: `30m` (API-key auth) or `1h` (OAuth auth). Set to `0m` to disable.
567564
- Cadence is written into a system-owned cron monitor row. Run `openclaw doctor --fix` to materialize a missing or stale row. If cron is disabled, scheduled heartbeats do not run and the gateway logs a startup warning.
568-
- `includeSystemPromptSection`: when false, omits the Heartbeat section from the system prompt. Default: `true`.
569-
- `suppressToolErrorWarnings`: when true, suppresses tool error warning payloads during heartbeat runs.
565+
- The heartbeat object is strict. Its supported fields are `every`, `activeHours`, `model`, `session`, `target`, `directPolicy`, `to`, `accountId`, `prompt`, `timeoutSeconds`, `lightContext`, and `isolatedSession`.
570566
- `timeoutSeconds`: maximum time in seconds allowed for a heartbeat agent turn before it is aborted. Leave unset to use `agents.defaults.timeoutSeconds` when set, otherwise the heartbeat cadence capped at 600 seconds.
571567
- `directPolicy`: direct/DM delivery policy. `allow` (default) permits direct-target delivery. `block` suppresses direct-target delivery and emits `reason=dm-blocked`.
572568
- `lightContext`: when true, heartbeat runs use lightweight bootstrap context and skip workspace bootstrap files. Monitor scratch is injected by the heartbeat runner either way.
573569
- `isolatedSession`: when true, each heartbeat runs in a fresh session with no prior conversation history. Same isolation pattern as cron `sessionTarget: "isolated"`. Reduces per-heartbeat token cost from ~100K to ~2-5K tokens.
574-
- `skipWhenBusy`: when true, heartbeat runs defer on that agent's extra busy lanes: its own session-keyed subagent or nested command work. Cron lanes always defer heartbeats, even without this flag.
570+
- Busy deferral is automatic: scheduled heartbeats wait for main/cron activity, same-agent active runs, and target-session work. Immediate and manual wakes bypass only the broad same-agent active-run precheck.
571+
- The default agent's Heartbeats system-prompt section is included automatically while its cadence is enabled. Ack suppression uses a fixed 300-character remainder budget, reasoning payloads remain internal, and tool error warnings remain enabled.
575572
- Per-agent: set `agents.entries.*.heartbeat`. When any agent defines `heartbeat`, **only those agents** run heartbeats.
576573
- Heartbeats run full agent turns — shorter intervals burn more tokens.
577574

‎docs/gateway/configuration-examples.md‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ Save to `~/.openclaw/openclaw.json` and you can DM the bot from that number.
256256
directPolicy: "allow", // allow (default) | block
257257
to: "+15555550123",
258258
prompt: "HEARTBEAT",
259-
ackMaxChars: 300,
260259
},
261260
sandbox: {
262261
mode: "non-main",

‎docs/gateway/heartbeat.md‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ Example config:
6565
- Interval: `30m`. Applying Anthropic provider defaults bumps this to `1h` when the resolved auth mode is OAuth/token (including Claude CLI reuse), but only while `heartbeat.every` is unset. Set `agents.defaults.heartbeat.every` or per-agent `agents.entries.*.heartbeat.every`; use `0m` to disable.
6666
- Prompt body (configurable via `agents.defaults.heartbeat.prompt`): `Follow the heartbeat monitor scratch context when provided. Recurring tasks are cron jobs; create or change their schedules with cron tools or the openclaw cron CLI, not heartbeat scratch. Do not infer or repeat old tasks from prior chats. If nothing needs attention, reply HEARTBEAT_OK.`
6767
- Timeout: unset heartbeat turns use `agents.defaults.timeoutSeconds` when set. Otherwise, they use the heartbeat cadence capped at 600 seconds. Set `agents.defaults.heartbeat.timeoutSeconds` or per-agent `agents.entries.*.heartbeat.timeoutSeconds` for longer heartbeat work.
68-
- The heartbeat prompt is sent **verbatim** as the user message. The system prompt includes a "Heartbeats" section when heartbeats are enabled for the default agent, and the run is flagged internally.
68+
- The heartbeat prompt is sent **verbatim** as the user message. The system prompt automatically includes a "Heartbeats" section when cadence is enabled for the default agent; that guidance has no separate heartbeat toggle.
6969
- When heartbeats are disabled with `0m`, the monitor cron job stays but is disabled, and its scratch is retained for when you re-enable the cadence.
7070
- When cron itself is disabled, scheduled heartbeats do not run even if heartbeat cadence remains enabled.
7171
- Active hours (`heartbeat.activeHours`) are checked in the configured timezone. Outside the window, heartbeats are skipped until the next tick inside the window.
72-
- Heartbeats automatically defer while cron work is active or queued, or while that agent's session-keyed subagent or nested command lanes are busy. Sibling agents do not pause each other.
72+
- Scheduled heartbeats defer while the main queue or cron work is active or queued, while any reply or embedded run for the same agent is active, and while the resolved target session has active or queued work. Immediate and manual wakes bypass the broad same-agent active-run check, but still honor the main, cron, and target-session busy guards. Sibling agents do not pause each other.
7373

7474
## What the heartbeat prompt is for
7575

@@ -87,9 +87,11 @@ If you want a heartbeat to do something very specific (e.g. "check Gmail PubSub
8787
- If nothing needs attention, reply with **`HEARTBEAT_OK`**.
8888
- Heartbeat runs may instead call `heartbeat_respond` with `notify: false` for no visible update, or `notify: true` plus `notificationText` for an alert. When present, the structured tool response takes precedence over the text fallback.
8989
- A meaningful `heartbeat_respond` result with `notify: false` remains silent but is remembered as bounded internal context for the next user turn in that session. `no_change` acknowledgments and visible notifications are not stored this way.
90-
- During heartbeat runs, OpenClaw treats `HEARTBEAT_OK` as 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 at most 300 characters.
90+
- During heartbeat runs, OpenClaw treats `HEARTBEAT_OK` as 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 at most 300 characters. This suppression budget is fixed, not configurable per heartbeat.
9191
- If `HEARTBEAT_OK` appears in the **middle** of a reply, it is not treated specially.
9292
- For alerts, **do not** include `HEARTBEAT_OK`; return only the alert text.
93+
- Delivery selects the last outbound-capable non-reasoning payload. Separate reasoning or thinking payloads remain internal; a reasoning-only result produces no alert.
94+
- Tool error warnings remain enabled during heartbeat turns.
9395

9496
Outside heartbeats, stray `HEARTBEAT_OK` at the start/end of a message is stripped and logged; a message that is only `HEARTBEAT_OK` is dropped.
9597

@@ -277,6 +279,10 @@ Use `accountId` to target a specific account on multi-account channels like Tele
277279

278280
</ParamField>
279281

282+
<Note>
283+
Heartbeat configuration is strict: only the fields listed above are accepted. Acknowledgment suppression, reasoning visibility, system-prompt guidance, busy deferral, and tool-error warning behavior are fixed runtime policies rather than heartbeat configuration fields.
284+
</Note>
285+
280286
## Delivery behavior
281287

282288
<AccordionGroup>
@@ -285,7 +291,7 @@ Use `accountId` to target a specific account on multi-account channels like Tele
285291
- `session` only affects the run context; delivery is controlled by `target` and `to`.
286292
- To deliver to a specific channel/recipient, set `target` + `to`. With `target: "last"`, delivery uses the last external channel for that session.
287293
- Heartbeat deliveries allow direct/DM targets by default. Set `directPolicy: "block"` to suppress direct-target sends while still running the heartbeat turn.
288-
- If the main queue, target session lane, cron lane, or an active cron job is busy, the heartbeat is skipped and retried later.
294+
- Scheduled heartbeats are skipped and retried later when the main queue or cron work is busy, any reply or embedded run for the same agent is active, or the resolved target session has active or queued work. Immediate and manual wakes bypass only the broad same-agent active-run precheck.
289295
- If `target` resolves to no external destination, the run still happens but no outbound message is sent.
290296

291297
</Accordion>

‎docs/start/openclaw.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ Set `agents.defaults.heartbeat.every: "0m"` to disable. Heartbeat checklists liv
173173

174174
- If the monitor scratch exists but is effectively empty (only blank lines, Markdown/HTML comments, Markdown headings like `# Heading`, fence markers, or empty checklist stubs), OpenClaw skips the heartbeat run to save API calls.
175175
- If no scratch exists, the heartbeat still runs and the model decides what to do.
176-
- If the agent replies with `HEARTBEAT_OK` (optionally with short padding; see `agents.defaults.heartbeat.ackMaxChars`), OpenClaw suppresses outbound delivery for that heartbeat.
176+
- If the agent replies with `HEARTBEAT_OK`, optionally with at most 300 characters of remaining text, OpenClaw suppresses outbound delivery for that heartbeat. The 300-character budget is fixed.
177177
- By default, heartbeat delivery to DM-style `user:<id>` targets is allowed. Set `agents.defaults.heartbeat.directPolicy: "block"` to suppress direct-target delivery while keeping heartbeat runs active.
178178
- Heartbeats run full agent turns - shorter intervals burn more tokens.
179179

‎docs/tools/thinking.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ Malformed local-model reasoning tags are handled conservatively. Closed `<think>
123123
## Heartbeats
124124

125125
- Heartbeat probe body is the configured heartbeat prompt (default: `Follow the heartbeat monitor scratch context when provided. Recurring tasks are cron jobs; create or change their schedules with cron tools or the openclaw cron CLI, not heartbeat scratch. Do not infer or repeat old tasks from prior chats. If nothing needs attention, reply HEARTBEAT_OK.`). Inline directives in a heartbeat message apply as usual (but avoid changing session defaults from heartbeats).
126-
- Heartbeat delivery defaults to the final payload only. To also send the separate `Thinking` message (when available), set `agents.defaults.heartbeat.includeReasoning: true` or per-agent `agents.entries.*.heartbeat.includeReasoning: true`.
126+
- Heartbeat delivery uses the last outbound-capable non-reasoning payload. Separate reasoning or `Thinking` payloads remain internal, and a reasoning-only heartbeat result produces no alert.
127127

128128
## Web chat UI
129129

‎src/auto-reply/heartbeat-reply-payload.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ export function resolveHeartbeatTerminalToolFailure(
3737
* Reasoning payloads are skipped using the shared SDK classifier
3838
* `isReasoningReplyPayload`, which recognizes the `isReasoning` flag plus the
3939
* common reasoning/thinking text prefixes (including lowercased and Markdown
40-
* blockquoted forms). Heartbeat reasoning is delivered separately and only when
41-
* `includeReasoning` is enabled; without this guard a trailing reasoning
42-
* payload (which reasoning models can emit after the final answer) would be
43-
* selected as the user-visible heartbeat reply.
40+
* blockquoted forms). Heartbeat delivery keeps separate reasoning payloads
41+
* internal; without this guard, a trailing reasoning payload (which reasoning
42+
* models can emit after the final answer) would be selected as the visible
43+
* heartbeat reply.
4444
*/
4545
export function resolveHeartbeatReplyPayload(
4646
replyResult: ReplyPayload | ReplyPayload[] | undefined,

‎src/auto-reply/reply/get-reply.fast-path.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ describe("getReplyFromConfig fast test bootstrap", () => {
346346
defaults: {
347347
model: "openai/gpt-5.5",
348348
workspace: home,
349-
heartbeat: { ackMaxChars: 300 },
349+
heartbeat: {},
350350
},
351351
},
352352
session: { store: storePath },
@@ -414,7 +414,7 @@ describe("getReplyFromConfig fast test bootstrap", () => {
414414
defaults: {
415415
model: "openai/gpt-5.5",
416416
workspace: home,
417-
heartbeat: { ackMaxChars: 300 },
417+
heartbeat: {},
418418
},
419419
},
420420
session: { store: storePath },

‎src/claws/openclaw-profile.test.ts‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,26 @@ describe("OpenClaw profile schema", () => {
4040
expect(result.ok).toBe(false);
4141
});
4242

43+
it("rejects retired heartbeat fields with a heartbeat-scoped diagnostic", () => {
44+
const result = parseClawOpenClawProfile({
45+
schemaVersion: 1,
46+
agent: { heartbeat: { every: "30m", skipWhenBusy: true } },
47+
});
48+
49+
expect(result.ok).toBe(false);
50+
if (result.ok) {
51+
return;
52+
}
53+
expect(result.diagnostics).toContainEqual(
54+
expect.objectContaining({
55+
path: "$.agent.heartbeat",
56+
message: expect.stringContaining("skipWhenBusy"),
57+
}),
58+
);
59+
});
60+
4361
it("rejects invalid profile policy", () => {
4462
for (const agent of [
45-
{ heartbeat: { skipWhenBusy: true } },
4663
{ tools: { profile: "future-profile" } },
4764
{ tools: { allow: ["read"], alsoAllow: ["write"] } },
4865
{ memory: { search: { provider: "openai" } } },

0 commit comments

Comments
 (0)