openclaw - 💡(How to fix) Fix Feature Request: Add HEARTBEAT_MSG Environment Variable to Disable Worker Heartbeats [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#71852Fetched 2026-04-26 05:07:29
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

When an OpenClaw agent runs its systemd-worker.sh script, it automatically emits a HEARTBEAT turn every 30 seconds. In many use-cases—such as data-collector agents or batch jobs—this heartbeat is unnecessary noise and can confuse downstream consumers.

Root Cause

When an OpenClaw agent runs its systemd-worker.sh script, it automatically emits a HEARTBEAT turn every 30 seconds. In many use-cases—such as data-collector agents or batch jobs—this heartbeat is unnecessary noise and can confuse downstream consumers.

Fix Action

Fix / Workaround

Example Patch (in systemd-worker.sh)

HEARTBEAT_MSG="${HEARTBEAT_MSG:-HEARTBEAT}"

Code Example

if openclaw agent --agent "$AGENT" --message "HEARTBEAT" 2>>"$LOGFILE"; then

---

HEARTBEAT_MSG="${HEARTBEAT_MSG:-HEARTBEAT}"

if [[ -n "$HEARTBEAT_MSG" ]]; then
  if openclaw agent --agent "$AGENT" --message "$HEARTBEAT_MSG" 2>>"$LOGFILE"; then
    run_hook after_send || true
    backoff=0
  else
    run_hook on_send_fail || true
    backoff=$(( backoff + 1 ))
    sleep_n=$(( INTERVAL * backoff ))
    if [[ $sleep_n -gt $MAX_BACKOFF ]]; then sleep_n=$MAX_BACKOFF; fi
    echo "$(date -u +%Y-%m-%dT%H:%M:%SZ) send failed; backoff ${sleep_n}s" | tee -a "$LOGFILE"
    sleep "$sleep_n"
    continue
  fi
fi
RAW_BUFFERClick to expand / collapse

Summary

When an OpenClaw agent runs its systemd-worker.sh script, it automatically emits a HEARTBEAT turn every 30 seconds. In many use-cases—such as data-collector agents or batch jobs—this heartbeat is unnecessary noise and can confuse downstream consumers.

Current Behavior

The worker loop contains a hard-coded line:

if openclaw agent --agent "$AGENT" --message "HEARTBEAT" 2>>"$LOGFILE"; then

If the agent has nothing else to report, the gateway automatically substitutes a NO_REPLY payload. No configuration option exists to disable this behavior without editing the script.

Proposed Fix

Add a configurable environment variable HEARTBEAT_MSG (default: "HEARTBEAT").

  • If the variable is empty or set to DISABLE, the worker skips sending the message entirely.
  • If unset or set to HEARTBEAT, the old behavior is preserved.

Example Patch (in systemd-worker.sh)

HEARTBEAT_MSG="${HEARTBEAT_MSG:-HEARTBEAT}"

if [[ -n "$HEARTBEAT_MSG" ]]; then
  if openclaw agent --agent "$AGENT" --message "$HEARTBEAT_MSG" 2>>"$LOGFILE"; then
    run_hook after_send || true
    backoff=0
  else
    run_hook on_send_fail || true
    backoff=$(( backoff + 1 ))
    sleep_n=$(( INTERVAL * backoff ))
    if [[ $sleep_n -gt $MAX_BACKOFF ]]; then sleep_n=$MAX_BACKOFF; fi
    echo "$(date -u +%Y-%m-%dT%H:%M:%SZ) send failed; backoff ${sleep_n}s" | tee -a "$LOGFILE"
    sleep "$sleep_n"
    continue
  fi
fi

This allows operators to set HEARTBEAT_MSG="" or HEARTBEAT_MSG=DISABLE to silence the heartbeat without modifying the script.

extent analysis

TL;DR

To disable the unnecessary heartbeat in OpenClaw agents, set the HEARTBEAT_MSG environment variable to an empty string or "DISABLE".

Guidance

  • Review the proposed patch for systemd-worker.sh to understand the changes required to add the HEARTBEAT_MSG environment variable.
  • Set HEARTBEAT_MSG to an empty string or "DISABLE" to silence the heartbeat, allowing for more control over agent behavior.
  • Test the updated script with the new environment variable to verify the desired behavior.
  • Consider the implications of disabling the heartbeat on downstream consumers and monitoring systems.

Example

The provided patch example demonstrates how to modify the systemd-worker.sh script to include the HEARTBEAT_MSG environment variable:

HEARTBEAT_MSG="${HEARTBEAT_MSG:-HEARTBEAT}"
if [[ -n "$HEARTBEAT_MSG" ]]; then
  # ...

This code checks if HEARTBEAT_MSG is set and not empty before sending the heartbeat message.

Notes

The proposed fix requires modifying the systemd-worker.sh script, which may have implications for future updates or maintenance. Ensure that any changes are properly tested and documented.

Recommendation

Apply the proposed patch to add the HEARTBEAT_MSG environment variable, allowing for more control over the heartbeat behavior. This change provides a flexible solution for operators to silence the heartbeat as needed.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Feature Request: Add HEARTBEAT_MSG Environment Variable to Disable Worker Heartbeats [1 participants]