Skip to content

fix(heartbeat): suppress raw reply delivery in message_tool_only mode - #94111

Closed
LiLan0125 wants to merge 1 commit into
openclaw:mainfrom
LiLan0125:fix/94053-heartbeat-message-tool-only-leak
Closed

LiLan0125 wants to merge 1 commit into
openclaw:mainfrom
LiLan0125:fix/94053-heartbeat-message-tool-only-leak

Conversation

@LiLan0125

Copy link
Copy Markdown
Contributor

Summary

  • When messages.visibleReplies is set to message_tool, the heartbeat runner was delivering the raw agent reply text to the channel even when the heartbeat response tool was not called with notify: true.
  • This leaked private model responses to the channel, bypassing the message_tool_only privacy mode.
  • The fix suppresses raw reply delivery when the message_tool mode is active and the response tool was not called, while preserving error/failure notices that explicitly opt into source-suppression delivery (e.g. Codex usage limit warnings).

Verification

  • node scripts/run-vitest.mjs run src/infra/heartbeat-runner.tool-response.test.ts → 13/13 passed

Impact Assessment

  • Scope: src/infra/heartbeat-runner.ts — adds a guard before the shouldSkipMain check
  • Downstream: only affects heartbeat delivery when visibleReplies: "message_tool" is configured; error notices are still delivered via deliverDespiteSourceReplySuppression
  • Edge cases: the check reads getReplyPayloadMetadata to allow error notices through; regular replies without the heartbeat tool invocation are suppressed
  • Hard-coded values: none

Real behavior proof

Behavior addressed: Heartbeat runner leaked private replies to Telegram in message_tool_only mode. After the fix, raw replies are suppressed unless the heartbeat response tool is called or the reply is an error notice.

Environment tested: Node 22.x on Linux, vitest test suite.

Steps run after the patch: Ran heartbeat tool response tests including the Codex failure notice scenario.

(cd /home/.../openclaw && node scripts/run-vitest.mjs run src/infra/heartbeat-runner.tool-response.test.ts)

Evidence after fix:

Test Files  1 passed (1)
     Tests  13 passed (13)

Observed result: All 13 tests pass, including the Codex runtime failure notice delivery test which verifies error messages are still delivered in message_tool mode.

Not tested: Live Telegram bot with visibleReplies: "message_tool" configuration was not exercised.

Closes #94053

When visibleReplies is set to message_tool, the heartbeat runner was
delivering the raw agent reply text to the channel even when the
heartbeat response tool was not called. This leaked private replies.

Suppress the delivery unless the reply is an error/failure notice
that explicitly opts into source-suppression delivery.

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
@clawsweeper

clawsweeper Bot commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

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

This PR should close in favor of the cleaner same-root-cause candidate because it suppresses every no-tool heartbeat reply whenever the heartbeat tool is forced, while the supported contract only makes missed-tool final text private after an explicit visibleReplies: "message_tool" opt-in.

Root-cause cluster
Relationship: superseded
Canonical: #94088
Summary: This PR is a narrower-looking but overbroad candidate for the same heartbeat message-tool-only privacy bug; the canonical open PR is cleaner, mergeable, and proof-positive.

Members:

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

Canonical path: Close this branch and review or land #94088 as the canonical fix 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 review or land #94088 as the canonical fix for the linked heartbeat privacy bug.

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

Yes. The linked report and current source show that sourceReplyDeliveryMode: "message_tool_only" can be set, no heartbeat_respond result can be present, and current main then falls through to durable channel delivery when shouldSkipMain is false.

Is this the best way to solve the issue?

No. The runner-level guard is the right area, but this branch scopes it too broadly; the safer solution is the canonical candidate that requires explicit message-tool visibility and preserves Codex default fallback behavior.

Security review:

Security review cleared: No dependency, workflow, script, credential, lockfile, or supply-chain changes were found; the remaining privacy and delivery concerns are functional merge risks.

AGENTS.md: found and applied where relevant.

What I checked:

  • PR guard is broader than the configured privacy mode: The patch keys suppression on usesHeartbeatResponseTool, which current main can set for Codex-harness heartbeat defaults even when the operator did not configure messages.visibleReplies: "message_tool". (src/infra/heartbeat-runner.ts:1868, 136b80dbd25b)
  • Current main sets heartbeat response tool mode for Codex defaults: Current main returns true for shouldUseHeartbeatResponseToolPrompt from explicit visibleReplies: "message_tool", but also falls back to usesCodexHarness(params) when no visible-replies override is set. (src/infra/heartbeat-runner.ts:525, aad0559de0e2)
  • Docs keep Codex default visible replies automatic until explicit opt-in: The Codex harness runtime docs say direct/source Codex turns default to automatic final assistant delivery and only keep final text private when messages.visibleReplies: "message_tool" is set. Public docs: docs/plugins/codex-harness-runtime.md. (docs/plugins/codex-harness-runtime.md:52, aad0559de0e2)
  • General message-tool contract is explicit opt-in: The group-channel docs say final text is kept private when the room is opted into messages.groupChat.visibleReplies: "message_tool"; automatic mode still posts final assistant text directly. Public docs: docs/channels/groups.md. (docs/channels/groups.md:47, aad0559de0e2)
  • Canonical candidate preserves the missing scope and adds proof: The open canonical PR adds an explicit-message-tool visibility helper, preserves marked notices and relayable exec completions, adds a regression test, is currently mergeable, and reports positive before/after runner proof. (src/infra/heartbeat-runner.ts:528, 799a52e8d1ac)
  • OpenClaw preserves internal failure notices with reply metadata: Current main marks known agent-run failure payloads with deliverDespiteSourceReplySuppression, which is why the PR's exception is necessary for usage-limit and runtime-failure notices. (src/auto-reply/reply/agent-runner-execution.ts:1004, aad0559de0e2)

Likely related people:

  • neeravmakwana: Authored the merged heartbeat message-tool delivery policy PR that made heartbeat runs enter message_tool_only for configured message-tool and Codex-runtime cases. (role: introduced behavior; confidence: high; commits: bd9c78f957b8; files: src/infra/heartbeat-runner.ts, src/infra/heartbeat-runner.tool-response.test.ts)
  • joshavant: Merged the heartbeat message-tool policy PR and later authored an adjacent heartbeat delivery fix in the same runner area. (role: merger and adjacent owner; confidence: medium; commits: bd9c78f957b8, 3643de4ba7b6; files: src/infra/heartbeat-runner.ts)
  • Vincent Koc: Current-main blame for the heartbeat reply/delivery block points to the recent refactor commit that carried this implementation forward in the shallow checkout. (role: recent refactor carrier; confidence: medium; commits: 95b6df834350, aad0559de0e2; files: src/infra/heartbeat-runner.ts)

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

@clawsweeper clawsweeper Bot added 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. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P2 Normal backlog priority with limited blast radius. 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. labels Jun 18, 2026
@clawsweeper

clawsweeper Bot commented Jun 18, 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 — 136b80db Deployed Jun 18, 2026 by clawsweeper[bot] via Run agentic native Telegram proof #191194
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