Skip to content

fix(heartbeat): periodic-task heartbeat prompts are shown as user messages - #174815

Merged
obviyus merged 3 commits into
openclaw:mainfrom
maliv2:fix/claude-cli-heartbeat-task-prompt-display
Oct 26, 2026
Merged

obviyus merged 3 commits into
openclaw:mainfrom
maliv2:fix/claude-cli-heartbeat-task-prompt-display

Conversation

@maliv2

@maliv2 maliv2 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Related: #151962

What Problem This Solves

Fixes: a periodic-task heartbeat prompt ("Run the following periodic tasks...") saved in an older session is treated as a real user message instead of an internal heartbeat prompt when the run did not use the heartbeat response tool. It stays in the history that heartbeat artifact filtering is meant to clean, and a Claude CLI session that imports it shows it as a user message.

User Impact

User impact: periodic-task heartbeat prompts already saved in sessions are filtered like the other heartbeat prompts, and no longer show up as user bubbles for sessions that import Claude CLI history. Real user messages stay visible.

Why This Change Was Made

Before the heartbeat executor was retired, a periodic-task prompt without the response tool ended with "After completing all due tasks, reply with exactly NO_REPLY as the entire final answer. ...". isHeartbeatUserMessage only knew the older "...reply NO_REPLY." and "...reply HEARTBEAT_OK." closings and the response-tool ones, so transcripts that kept the later form never matched. This adds that closing to the saved-transcript list in the filter. The Claude CLI importer recognized only the default heartbeat prompts by prefix, so it also missed these prompts; it now asks isHeartbeatUserMessage as well. A configured custom heartbeat prompt is still not recognized by the importer (unchanged, noted in the code).

Evidence

  • heartbeat-filter.test.ts gets a case with the exact saved periodic-task prompt, and the importer's internal-wake table in cli-session-history.claude-input.test.ts gets the same prompt. Without the source change the filter test fails (and the importer case with it); with it they pass.
  • heartbeat-filter, cli-session-history.claude-input and cli-session-history suites pass on Linux after merging current main (27 + 83 tests).
  • oxfmt --check, oxlint and git diff --check are clean on the touched files.

Runtime proof (running Gateway)

A real Gateway process (openclaw gateway run, isolated state dir, loopback port, token auth) with a session bound to Claude CLI whose project file (~/.claude/projects/.../<id>.jsonl) holds the rows below. History is read through the shipped CLI entry point: openclaw gateway call chat.history --params '{"sessionKey":"..."}'. Output shows role and the first characters of each returned message.

Rows in the Claude project file: a real question and answer; the silent exec prompt; the silent exec prompt with heartbeat scratch; a cron reminder; a cron wake with no content; a periodic-task prompt; and two real user messages that quote a silent exec / cron prompt.

Before (upstream main b582963, Gateway 2026.10.4), 10 messages:

user      (local anchor)
user      What is the status of the deploy?
assistant The deploy finished.
user      An async command completion event was triggered, but user delivery is disabled
user      An async command completion event was triggered, but user delivery is disabled
user      A scheduled reminder has been triggered. The reminder content is: Stand-up rem
user      A scheduled cron event was triggered, but no event content was found. Reply wi
user      Run the following periodic tasks (only those due based on their intervals): -
user      Please explain this: An async command completion event was triggered, but user
user      What does this mean? A scheduled reminder has been triggered. The reminder con

After (same session data, Gateway rebuilt with #174780, #174798 and #174815 applied together), 5 messages:

user      (local anchor)
user      What is the status of the deploy?
assistant The deploy finished.
user      Please explain this: An async command completion event was triggered, but user
user      What does this mean? A scheduled reminder has been triggered. The reminder con
Row Hidden by
silent exec, silent exec + scratch #174780
cron reminder, cron without content #174798
periodic-task prompt #174815

The two real user messages that quote an internal prompt stay visible. Nothing in this output is private; the session, transcript and Claude project file are synthetic.

Current built-entry proof

Inspected screenshots and shipped-import observations on merged head ca8630fe15ec99e90620285ccbbe04235ad07714, versus main 32276e16fb780, twice each. Synthetic native Claude sessions imported with the shipped sessions import claude CLI into isolated real built Gateways. Real chat.history and compiled Control UI agree:

Main, 2/2: user=human control, user=internal periodic-task heartbeat, user=quoted cron/exec control.
Candidate, 2/2: user=human control, user=quoted cron/exec control; heartbeat absent from human projection.
Assistant response and imported-reference notice remain on both.

Not fixed here

This addresses only the periodic-task heartbeat subtype of #151962 at the existing internal-source classifier. Other phantom-message shapes, including silent background-command completion envelopes, remain separate. This PR does not claim to close #151962.

Simplification: reuse the existing heartbeat recognizer and internal-source projection; no second display filter or state owner. Production +8/-1; tests +12.

…rnal heartbeat prompt

The runner closes a periodic-task prompt with 'reply with exactly NO_REPLY as the entire final answer' when the response tool is unused, but the heartbeat filter only knew older closings, so the prompt was kept as a user message. Define the closing once next to the other heartbeat prompt constants, use it in the prompt builder and the filter, and let the Claude CLI importer ask the filter as well.
@clawsweeper

clawsweeper Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XS labels Oct 16, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 16, 2026
@clawsweeper

clawsweeper Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Recognize saved periodic-task heartbeat prompts and classify their imported Claude CLI rows as internal messages.

Example: Import a Claude session containing an inbox task ending with “reply with exactly NO_REPLY as the entire final answer.”

  • Before: The internal periodic-task prompt appears as a human user bubble.
  • After: The internal prompt is hidden while genuine human messages and the assistant response remain visible.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch has shipped-entry proof and no findings; the overall tier reflects its intentionally partial coverage of the broader linked issue.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): Inspected before-and-after screenshots and the collaborator’s exact-head Linux report exercise synthetic native Claude sessions through sessions import claude, real built Gateways, chat.history, and compiled Control UI; the periodic-task row disappears while genuine human controls and the assistant response remain.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: An internal periodic-task heartbeat saved in Claude history appears as a message the user typed.
Reason: The bounded fix restores the existing internal-message contract with no new option or owner; Related wording correctly leaves the broader linked report open.

Merge readiness

✅ Ready for maintainer review

This PR provides a useful, narrow fix for a classification gap still present on current main; no actionable patch defects were found.

Priority: P2
Reviewed head: ca8630fe15ec99e90620285ccbbe04235ad07714

Before merge

None.

Findings

None.

Agent review details

How this fits together

The shared heartbeat recognizer identifies saved runtime prompts; the Claude history adapter applies existing internal provenance and display metadata before history projection.

flowchart LR
  A[Claude session JSONL] --> B[Claude history adapter]
  B --> C[Shared heartbeat recognizer]
  C --> D[Internal message metadata]
  D --> E[History merge and projection]
  E --> F[Gateway history and Control UI]
Loading

Technical review

Best possible solution:

Land the focused recognizer and importer repair after required checks pass, while retaining the broader phantom-message report.

Do we have a high-confidence way to reproduce the issue?

Current-main source demonstrates both missing recognition paths, and supplied exact-head shipped-entry proof shows the before-and-after behavior; this read-only review did not run a reproduction.

Is this the best way to solve the issue?

This is the smallest complete fix for the stated subtype: extend the existing fixed-format recognizer and reuse it at the native import boundary.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 5f1d487758a8.

Provenance checked

  • Claude CLI internal-input classification keeps the original intent (667b2e5: Classify complete producer-owned runtime frames at the native adapter while preserving original text and canonical human matches.)
  • Saved periodic-task heartbeat recognition keeps the original intent (6d1c1c9: Centralize heartbeat automation classification under existing cron ownership while preserving legacy acknowledgements and silent transcript handling.)
  • Retired heartbeat executor compatibility keeps the original intent (5b4f83c: Remove unreachable heartbeat execution machinery after ordinary automation and session-event owners took over.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +7, Tests +12. Total +19 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 8 1 +7
Tests 2 12 0 +12
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 20 1 +19

Labels

Label changes:

  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

Label justifications:

  • P2: Saved periodic-task prompts can appear as human messages in imported history, causing bounded conversation confusion.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-16T23:26:35.374Z sha 85c2a7c :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-17T10:42:15.788Z sha 85c2a7c :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-21T23:25:48.374Z sha 85c2a7c :: needs maintainer review before merge. :: none

Reviewed October 26, 2026, 11:33 AM ET / 15:33 UTC (Revision 4).

@maliv2

maliv2 commented Oct 17, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 17, 2026
@maliv2

maliv2 commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Oct 21, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 21, 2026
@obviyus

obviyus commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

Built-entry Linux proof on merged candidate ca8630f versus main 32276e1, twice each. Synthetic native Claude JSONL only, explicit isolated Claude home and OpenClaw state. The shipped sessions import claude <thread-id> --host gateway:local --json imports each source into the actual built Gateway. Real chat.history and the compiled Control UI transcript agree: main has three user messages (human control, internal periodic-task heartbeat, quoted cron/exec control); candidate has only the two genuine human messages, with the periodic-task row absent from human projection. Both runs preserve the assistant response and imported-reference notice. No mocked Gateway, renderer or classifier. Screenshots inspected and attached. Not fixed here: the wider phantom-message family in #151962, including unrelated silent background completion envelopes; this fixes only periodic-task heartbeat recognition at the existing classifier owner.

Before: imported internal periodic tasks appear as a human user bubble

After: internal heartbeat disappears while both genuine human controls remain

@obviyus

obviyus commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 26, 2026
@obviyus
obviyus merged commit 503bc1b into openclaw:main Oct 26, 2026
125 checks passed
@obviyus

obviyus commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

Landed in 503bc1b. Thanks @maliv2. Imported Claude history no longer shows heartbeat instructions as user messages.

@obviyus

obviyus commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

Thanks @maliv2 for the focused periodic-task history classification fix. Merged with real import/Gateway/UI proof; broader #151962 remains open for other message shapes.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 27, 2026
…sages (openclaw#174815)

fix(claude-cli): stop imported periodic-task heartbeat instructions showing as user messages

Imported Claude native history projected OpenClaw's internal periodic-task heartbeat instructions as human user messages, so the Control UI transcript showed them as if the user had typed them. They are now left out of the human projection; real user text, quoted cron or exec text, assistant replies and the import notice are unchanged.

Evidence: synthetic native Claude sessions imported with the shipped `sessions import claude` into built Gateways. On main chat.history and the Control UI in Chromium both showed the "Run the following periodic tasks" instruction as a user message (twice); with this change it is gone (twice), while the real and quoted controls remain. Screenshots: openclaw#174815 (comment). The broader openclaw#151962 and silent completion envelopes are not addressed here.

Thanks @maliv2.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

2 participants