Repository navigation
fix(heartbeat): periodic-task heartbeat prompts are shown as user messages - #174815
Conversation
…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.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesRecognize 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.”
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial 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 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe 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]
Technical reviewBest 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
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +7, Tests +12. Total +19 across 4 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)Reviewed October 26, 2026, 11:33 AM ET / 15:33 UTC (Revision 4). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…claude-cli-heartbeat-task-prompt-display # Conflicts: # src/infra/heartbeat-runner-prompt.ts
…eat-task-prompt-display
|
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 |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…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]>


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. ...".
isHeartbeatUserMessageonly 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 asksisHeartbeatUserMessageas well. A configured custom heartbeat prompt is still not recognized by the importer (unchanged, noted in the code).Evidence
heartbeat-filter.test.tsgets a case with the exact saved periodic-task prompt, and the importer's internal-wake table incli-session-history.claude-input.test.tsgets 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-inputandcli-session-historysuites pass on Linux after merging currentmain(27 + 83 tests).oxfmt --check,oxlintandgit diff --checkare 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
mainb582963, Gateway 2026.10.4), 10 messages:After (same session data, Gateway rebuilt with #174780, #174798 and #174815 applied together), 5 messages:
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 main32276e16fb780, twice each. Synthetic native Claude sessions imported with the shippedsessions import claudeCLI into isolated real built Gateways. Real chat.history and compiled Control UI agree: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.