fix(heartbeat): exempt wake and hook reasons from empty-heartbeat skip (openclaw#14532) thanks @arosstale

Verified:
- pnpm build
- pnpm check
- pnpm test

Co-authored-by: arosstale <117890364+arosstale@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
Artale
2026-02-14 02:05:02 +01:00
committed by GitHub
parent e18f94a347
commit 7f0d6b1fcb
3 changed files with 142 additions and 3 deletions

View File

@@ -426,10 +426,11 @@ export async function runHeartbeatOnce(opts: {
// Skip heartbeat if HEARTBEAT.md exists but has no actionable content.
// This saves API calls/costs when the file is effectively empty (only comments/headers).
// EXCEPTION: Don't skip for exec events or cron events - they have pending system events
// to process regardless of HEARTBEAT.md content.
// EXCEPTION: Don't skip for exec events, cron events, or explicit wake requests -
// they have pending system events to process regardless of HEARTBEAT.md content.
const isExecEventReason = opts.reason === "exec-event";
const isCronEventReason = Boolean(opts.reason?.startsWith("cron:"));
const isWakeReason = opts.reason === "wake" || Boolean(opts.reason?.startsWith("hook:"));
const workspaceDir = resolveAgentWorkspaceDir(cfg, agentId);
const heartbeatFilePath = path.join(workspaceDir, DEFAULT_HEARTBEAT_FILENAME);
try {
@@ -437,7 +438,8 @@ export async function runHeartbeatOnce(opts: {
if (
isHeartbeatContentEffectivelyEmpty(heartbeatFileContent) &&
!isExecEventReason &&
!isCronEventReason
!isCronEventReason &&
!isWakeReason
) {
emitHeartbeatEvent({
status: "skipped",