Skip to content

[Bug]: cron-owned exec completion events are incorrectly relayed to the user by heartbeat #66460

@nanli2000cn

Description

@nanli2000cn

[Bug]: cron-owned exec completion events are incorrectly relayed to the user by heartbeat

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

After an isolated cron run already completes with its own final result, OpenClaw still relays the cron-internal exec completion event to the user through heartbeat as a separate user-facing async-result message.

Steps to reproduce

  1. Start from a clean Linux runtime. In this reproduction, ~/.openclaw was archived and rebuilt with only:
    • openclaw.json
    • .env
    • cron/jobs.json
    • hooks/
    • extensions/
  2. Run:
    openclaw cron run --expect-final 392e2cfd-abd2-40a2-8aa2-fc05937e372b
  3. Observe the actual cron run transcript:
    • ~/.openclaw/agents/main/sessions/db42c881-a887-4cc6-a5bf-10b426cbfa58.jsonl
  4. Confirm the cron run itself finishes with:
    news_fetcher ok
    
  5. Observe the later heartbeat relay transcript:
    • ~/.openclaw/agents/main/sessions/e70f3c08-0015-4ba8-96ee-52f83e2f04a3.jsonl
  6. Confirm heartbeat receives a user message whose body starts with:
    An async command you ran earlier has completed. The result is:
    
    Exec completed (rapid-br, code 0) :: news snapshot written to temp/news/raw-latest.md
    
  7. Run:
    openclaw system heartbeat last --json
  8. Observe that Telegram receives a second user-facing completion report for the same internal cron execution.

Expected behavior

Once the cron run has already produced its own final result (news_fetcher ok), the internal exec completion should remain internal and should not later be relayed to the user by heartbeat as a separate async-result message.

Actual behavior

The cron run finishes correctly with news_fetcher ok, but OpenClaw still emits an internal exec completion event and later relays that event to the user through heartbeat.

In this clean-runtime reproduction, the final user-facing relay was:

[完成] 异步命令已完成

- 结果:成功,退出码 0
- 输出:`news snapshot written to temp/news/raw-latest.md`

如果你要,我也可以继续帮你查看这个快照内容。

This shows the bug still exists even after removing stale runtime state; only the language of the relay changed.

OpenClaw version

2026.4.11 (769908e)

Operating system

Ubuntu 24.04 (Linux x86_64)

Install method

npm global

Model

Observed cron path:

  • initial provider/model attempt: minimax/MiniMax-M2.7-highspeed
  • final successful cron result provider/model: openai/gpt-5.4-mini
  • later heartbeat relay model: openai/gpt-5.4-mini

Provider / routing chain

openclaw -> configured agent default model chain -> minimax first, then OpenAI fallback

Additional provider/model setup details

  • Agent default model chain in ~/.openclaw/openclaw.json:
    • primary: minimax/MiniMax-M2.7-highspeed
    • fallbacks include:
      • openai-codex/gpt-5.4-mini
      • openai/gpt-5.4-mini
      • openai-codex/gpt-5.4
      • openai/gpt-5.4
      • anthropic/claude-opus-4-6
      • google/gemini-3.1-flash-lite-preview
  • The reproduction was re-run after rebuilding ~/.openclaw from a minimal clean Linux runtime, so this report is not based on migrated stale session state.

Logs, screenshots, and evidence

Affected job:
- Name: 新闻原始抓取
- Job ID: 392e2cfd-abd2-40a2-8aa2-fc05937e372b

Cron run transcript:
- ~/.openclaw/agents/main/sessions/db42c881-a887-4cc6-a5bf-10b426cbfa58.jsonl

Observed final cron answer:
- news_fetcher ok

Run history:
- ~/.openclaw/cron/runs/392e2cfd-abd2-40a2-8aa2-fc05937e372b.jsonl

Observed run entry:
- summary: news_fetcher ok
- status: ok
- delivered: false

Heartbeat relay transcript:
- ~/.openclaw/agents/main/sessions/e70f3c08-0015-4ba8-96ee-52f83e2f04a3.jsonl

Observed heartbeat input:
An async command you ran earlier has completed. The result is:

Exec completed (rapid-br, code 0) :: news snapshot written to temp/news/raw-latest.md

Please relay the command output to the user in a helpful way. If the command succeeded, share the relevant output. If it failed, explain what went wrong.

Observed heartbeat output:
[完成] 异步命令已完成

- 结果:成功,退出码 0
- 输出:`news snapshot written to temp/news/raw-latest.md`

如果你要,我也可以继续帮你查看这个快照内容。

Observed heartbeat delivery preview from:
- openclaw system heartbeat last --json

Root-cause evidence from installed dist:

File: dist/bash-tools.exec-runtime-jfecOhNR.js

Current behavior:
- maybeNotifyOnExit(...) enqueues:
  Exec completed (...) :: <output>
- then requests heartbeat wake with reason "exec-event"

File: dist/heartbeat-runner-U2x6TbnN.js

Current behavior:
- buildExecEventPrompt(...) builds a user-facing relay request:
  "An async command you ran earlier has completed..."
- later heartbeat delivers the resulting reply to the user

Impact and severity

  • Affected users/systems/channels: direct Telegram user-facing heartbeat delivery on cron-owned isolated runs
  • Severity: Medium to High (incorrect user-visible completion reports from internal cron execution)
  • Frequency: Reproduced after clean runtime rebuild on the affected job
  • Consequence: internal control-plane exec completion events escape into user-visible chat and produce duplicate/misleading completion messages

Additional information

  • This issue is distinct from stale lastHeartbeatText inheritance and from missing exec-event body bugs.
  • In this reproduction, the bug persisted after rebuilding ~/.openclaw, which rules out stale migrated runtime state as the primary cause.
  • The minimal safe fix is to suppress notifyOnExit / user-facing exec-event relay for cron-owned internal exec runs, or otherwise mark cron-owned exec completion events so heartbeat consumes them internally instead of relaying them to the user.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions