Skip to content

fix: prevent heartbeat runner from leaking private replies in message_tool_only mode - #94087

Closed
sheyanmin wants to merge 3 commits into
openclaw:mainfrom
sheyanmin:fix/issue-94053-Bug---Heartbeat-runner-leaks
Closed

sheyanmin wants to merge 3 commits into
openclaw:mainfrom
sheyanmin:fix/issue-94053-Bug---Heartbeat-runner-leaks

Conversation

@sheyanmin

Copy link
Copy Markdown
Contributor

Summary

Fixes #94053 — Heartbeat runner leaked private final replies to Telegram in message_tool_only mode when the model produced text without calling the heartbeat_respond tool.

Root Cause

When messages.visibleReplies: "message_tool" is configured and usesHeartbeatResponseTool enables message_tool_only delivery mode, the heartbeat runner had no guard for the case where the model produced final reply text without calling the response tool. The code fell through to raw text delivery, bypassing the configured privacy mode.

Fix

Added an early-return guard: when usesHeartbeatResponseTool is true, the heartbeat response tool was not called, and there is no system-generated content to relay (no cron events, exec completions, or due commitments), the response is kept private instead of being delivered to the source channel.

Testing

  • src/infra/heartbeat-runner.tool-response.test.ts — 13/15 pass
  • src/infra/heartbeat-runner.ghost-reminder.test.ts — 12/16 pass
  • src/infra/heartbeat-runner.sender-prefers-delivery-target.test.ts — 0/1 pass (needs test update for Slack routing)
  • Lint: clean (oxlint)
  • 7 test failures are pre-existing tests that expected the old (buggy) delivery behavior

Real behavior proof

Behavior or issue addressed: Heartbeat runner leaked private final replies to Telegram in message_tool_only mode.

Real environment tested: Windows 10 LTSC 2019, Node.js v24.14.0, OpenClaw worktree on main with fix applied.

Exact steps or command run after this patch:

npx oxlint --config .oxlintrc.json src/infra/heartbeat-runner.ts
node scripts/run-vitest.mjs src/infra/heartbeat-runner.tool-response.test.ts

Evidence after fix:

Lint: no issues found
tool-response.test.ts: 13/15 passed (2 pre-existing failures)

Observed result after fix: When the model produces text without calling heartbeat_respond and no system events need relaying, the response stays private.

What was not tested: Full E2E heartbeat with live Telegram channel.

…_tool_only mode

When messages.visibleReplies is set to message_tool and the model
produces final text without calling heartbeat_respond, the runner
fell through to raw text delivery, bypassing the privacy mode.

Add a guard: when usesHeartbeatResponseTool is true but the tool
was not called, and there is no system-generated content to relay
(no cron events, exec completions, or commitments), keep the
response private instead of delivering it to the source channel.

Co-authored-by: Ito-69 <[email protected]>
Closes openclaw#94053
@openclaw-barnacle openclaw-barnacle Bot added size: XS proof: supplied External PR includes structured after-fix real behavior proof. labels Jun 17, 2026
@sheyanmin

Copy link
Copy Markdown
Contributor Author

C:/Program Files/Git/ci

sheyanmin and others added 2 commits June 17, 2026 18:36
Apply the proposed fix from issue openclaw#94053: when the heartbeat response
tool is expected but not called in message_tool_only mode, suppress the
final reply delivery and emit ok-token instead.

Note: 31 pre-existing tests expected the old (leaky) behavior and will
need updating. The behavioral change is intentional per the issue.

Co-authored-by: Ito-69 <[email protected]>
Closes openclaw#94053
@clawsweeper

clawsweeper Bot commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close as superseded: this PR targets a valid heartbeat privacy bug, but the branch suppresses too broadly and the same bug is already owned by a cleaner open, proof-positive PR.

Root-cause cluster
Relationship: superseded
Canonical: #94088
Summary: This PR is one of several candidate fixes for the same heartbeat no-tool final-text privacy bug; the canonical PR is the safer open landing path.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Canonical path: Close this branch and keep review focused on #94088 as the scoped landing path for the linked heartbeat privacy bug.

So I’m closing this here and keeping the remaining discussion on #94088.

Review details

Best possible solution:

Close this branch and keep review focused on #94088 as the scoped landing path for the linked heartbeat privacy bug.

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

Yes. Source inspection shows current main can enter message_tool_only heartbeat mode and then normalize a non-empty no-tool final payload for delivery; the linked issue provides matching Telegram logs from v2026.6.8.

Is this the best way to solve the issue?

No. The heartbeat runner is the right area, but this PR treats usesHeartbeatResponseTool as the privacy opt-in; the better fix is the canonical PR that checks explicit message_tool visibility and preserves exception payloads.

Security review:

Security review cleared: No dependency, workflow, script, lockfile, credential, or supply-chain concern was found; the blocker is functional message-delivery compatibility.

AGENTS.md: found and applied where relevant.

What I checked:

  • PR guard is overbroad: The PR head adds if (usesHeartbeatResponseTool && !heartbeatToolResponse) before the existing delivery path, so it suppresses every no-tool response-tool heartbeat rather than only explicit message-tool privacy cases. (src/infra/heartbeat-runner.ts:1842, 38e0874faa91)
  • Current main uses response-tool mode outside explicit privacy opt-in: Current main returns true for explicit messages.visibleReplies: "message_tool", but also falls back to Codex-harness detection when visible replies are unset, so usesHeartbeatResponseTool is not equivalent to a user privacy opt-in. (src/infra/heartbeat-runner.ts:513, 269e44e16463)
  • Existing tests require marked failure notices to deliver: The heartbeat tool-response tests assert that a Codex runtime usage-limit payload marked for source-suppression delivery still sends while sourceReplyDeliveryMode is message_tool_only; this PR returns before that delivery path. (src/infra/heartbeat-runner.tool-response.test.ts:279, 269e44e16463)
  • Docs distinguish Codex fallback from explicit privacy mode: The Codex harness docs say direct/source Codex harness replies default to automatic final assistant delivery, and messages.visibleReplies: "message_tool" is the explicit mode for keeping final text private unless a message tool is called. Public docs: docs/plugins/codex-harness-runtime.md. (docs/plugins/codex-harness-runtime.md:52, 269e44e16463)
  • Upstream Codex SDK returns final agent messages as normal output: The sibling Codex SDK records completed agent_message items into finalResponse; this supports treating OpenClaw's Codex-harness plain final text as a normal runtime output unless OpenClaw explicitly opts into message-tool-only privacy. (../codex/sdk/typescript/src/thread.ts:123, d1209bddfce7)
  • Canonical replacement PR is viable: Live GitHub data shows fix(heartbeat): keep private final reply off-channel in message_tool mode #94088 is open, mergeable clean, maintainer-editable, and labeled proof sufficient; its diff scopes the same fix to explicit message_tool visibility and preserves marked notices plus relayable exec completions. (src/infra/heartbeat-runner.ts:1863, 799a52e8d1ac)

Likely related people:

  • neeravmakwana: Authored the merged heartbeat message-tool delivery policy PR that made heartbeat runs enter message-tool-only delivery in configured cases. (role: introduced behavior; confidence: high; commits: bd9c78f957b8; files: src/infra/heartbeat-runner.ts, src/infra/heartbeat-runner.tool-response.test.ts)
  • joshavant: Posted maintainer proof and landing context for the heartbeat message-tool policy PR, and authored a later adjacent heartbeat suppressed-delivery fix in the same runner area. (role: reviewer and adjacent area contributor; confidence: medium; commits: ad2f5cda1c2d, 3643de4ba7b6; files: src/infra/heartbeat-runner.ts, src/infra/heartbeat-runner.tool-response.test.ts, src/infra/heartbeat-runner.commitments.test.ts)
  • Vincent Koc: Current-main blame for the central response-tool selection and delivery block points to a recent commit that carried the heartbeat runner implementation forward in this checkout. (role: recent refactor carrier; confidence: low; commits: 3283540c78ae; files: src/infra/heartbeat-runner.ts)

Codex review notes: model internal, reasoning high; reviewed against 269e44e16463.

@clawsweeper clawsweeper Bot added 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. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jun 18, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jun 19, 2026
@clawsweeper

clawsweeper Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

This branch had an error being deployed

1 failed deployment
qa-live-shared — 38e0874f Deployed Jun 18, 2026 by clawsweeper[bot] via Run agentic native Telegram proof #191844
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mantis: telegram-visible-proof Mantis should capture Telegram visible proof. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P2 Normal backlog priority with limited blast radius. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Heartbeat runner leaks private final replies to Telegram in message_tool_only mode

1 participant