Skip to content

Comments

fix: Make HEARTBEAT.md creation match documentation#11807

Draft
HenryLoenwind wants to merge 1 commit intoopenclaw:mainfrom
HenryLoenwind:heartbeat
Draft

fix: Make HEARTBEAT.md creation match documentation#11807
HenryLoenwind wants to merge 1 commit intoopenclaw:mainfrom
HenryLoenwind:heartbeat

Conversation

@HenryLoenwind
Copy link
Contributor

@HenryLoenwind HenryLoenwind commented Feb 8, 2026

fixes #11766 - Missing HEARTBEAT.md behaviour doesn't match documentation

Summary

The documentation states that "If the file is missing, the heartbeat still runs and the model decides what to do." However, the actual behavior was that a missing HEARTBEAT.md disabled the heartbeat completely because OpenClaw silently created an empty one. This commit fixes the logic to match the documented behavior by creating HEARTBEAT.md only when the workspace is brand new, ensuring existing workspaces with missing HEARTBEAT.md files can still execute heartbeats as intended.

Change

Moved the HEARTBEAT.md creation inside the isBrandNewWorkspace check to prevent overwriting or creating empty files in existing workspaces.

Impact

This change technically is a behavioural change, but it now matches what the documentation promises, i.e. exactly what users expect.

Testing

pnpm check and test passed

Greptile Overview

Greptile Summary

This PR adjusts workspace bootstrapping so HEARTBEAT.md is only created for brand new workspaces (inside the isBrandNewWorkspace branch) rather than being created opportunistically whenever it’s missing.

That aligns ensureAgentWorkspace (src/agents/workspace.ts) with the heartbeat runner behavior (src/infra/heartbeat-runner.ts), which explicitly proceeds when HEARTBEAT.md is absent (letting the model decide) but skips when the file exists and is “effectively empty.”

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk.
  • The change is a small, localized logic adjustment in workspace bootstrapping that better matches the documented/expected heartbeat semantics. It removes an unintended side effect (creating an empty HEARTBEAT.md in existing workspaces) and is consistent with the heartbeat runner’s explicit behavior when the file is missing.
  • No files require special attention

@Takhoffman
Copy link
Contributor

Thanks for calling this out.

@Takhoffman
Copy link
Contributor

I'm going to let Peter handle this one since it has to do with HEARTBEAT.md and onboarding.

@HenryLoenwind
Copy link
Contributor Author

HenryLoenwind commented Feb 14, 2026

Thanks for calling this out.

No problem, it was pretty obvious to me as I created the original issue.

In the long run, heuristics like this will have to go, I think. They are hard to understand for people, and while "it just works after install" is nice, things break when people start to tweak stuff that is "black box magic". In the end, I can see a point where heartbeats only run when they are put into the config explicitely, and don't care about the files.

For now, I think moving the file created down two lines to be with the bootstrap creation makes the most sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Missing HEARTBEAT.md behaviour doesn't match documentation

2 participants