Skip to content

fix(heartbeat): keep private-text final replies from leaking to channel in message_tool_only mode - #94485

Closed
qingminglong wants to merge 1 commit into
openclaw:mainfrom
qingminglong:fix/issue-94053-heartbeat-text-leak
Closed

qingminglong wants to merge 1 commit into
openclaw:mainfrom
qingminglong:fix/issue-94053-heartbeat-text-leak

Conversation

@qingminglong

@qingminglong qingminglong commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • When visibleReplies is set to message_tool and the agent produces a text-only final reply without calling the heartbeat response tool, the heartbeat runner was falling through to normal delivery — leaking private heartbeat text to the channel
  • Now checks usesHeartbeatResponseTool && !heartbeatToolResponse and silently dismisses the turn, matching the user's privacy configuration
  • Payloads marked with deliverDespiteSourceReplySuppression (e.g. Codex runtime failure notices) still deliver normally — this flag is checked via getReplyPayloadMetadata

Fixes #94053

Real behavior proof

Behavior addressed: Heartbeat runner leaked text-final replies to Telegram even in message_tool_only mode when the model didn't call heartbeat_respond tool.

Real setup tested:

  • Runtime: node (unit test suite + standalone verification script)

Exact steps or command run after fix:

pnpm vitest run src/infra/heartbeat-runner.tool-response.test.ts
pnpm vitest run src/infra/heartbeat-runner.timeout-warning.test.ts
pnpm vitest run src/infra/heartbeat-runner.typing.test.ts
pnpm vitest run src/infra/heartbeat-runner.transcript-prune.test.ts
node verify-heartbeat-leak.mjs

After-fix evidence:

Tests:

PASS (15) FAIL (0) - tool-response.test.ts
PASS (3)  FAIL (0) - timeout-warning.test.ts
PASS (2)  FAIL (0) - typing.test.ts
PASS (2)  FAIL (0) - transcript-prune.test.ts

Standalone verification:

=== Heartbeat Text Leak Fix Verification ===

Scenario                                                    | Dismissed? | Status     | Leak Prevented
------------------------------------------------------------|------------|------------|----------------
usesHeartbeatResponseTool=true, heartbeatToolResponse=true| NO       | ok-token  | N/A
usesHeartbeatResponseTool=true, heartbeatToolResponse=false| YES      | ok-token  | YES
usesHeartbeatResponseTool=true, heartbeatToolResponse=false, emergencyPayload=true| NO       | leaked    | N/A
usesHeartbeatResponseTool=false, heartbeatToolResponse=true| NO       | ok-token  | N/A
usesHeartbeatResponseTool=false, heartbeatToolResponse=false| NO       | leaked    | N/A

Result: PASS
  - message_tool_only + no response tool call → turn silently dismissed
  - emergency payloads (deliverDespiteSourceReplySuppression) still delivered
  - normal heartbeat flow unchanged

Tests and validation

22 tests pass across 5 heartbeat-runner test files + standalone verification script covers 5 behavioral scenarios.

…el in message_tool_only mode

When visibleReplies is set to message_tool and the agent produces a text
final reply without calling the heartbeat response tool, the heartbeat
runner was falling through to the normal delivery path, leaking private
heartbeat text to the channel. Now checks usesHeartbeatResponseTool &&
!heartbeatToolResponse and silently dismisses the turn, matching the
user's privacy configuration. Payloads marked with
deliverDespiteSourceReplySuppression (e.g. Codex runtime failure notices)
still deliver normally.

Fixes openclaw#94053

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@qingminglong

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@openclaw-barnacle openclaw-barnacle Bot added triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. and removed proof: supplied External PR includes structured after-fix real behavior proof. labels Jun 19, 2026
@clawsweeper

clawsweeper Bot commented Jun 19, 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 the right heartbeat privacy bug, but the open canonical PR at #94088 is mergeable, proof-sufficient, and scopes the fix more safely than this branch.

Root-cause cluster
Relationship: superseded
Canonical: #94088
Summary: This PR is one of several competing candidate fixes for the same heartbeat message-tool privacy bug; the canonical PR is the strongest landing target because it is open, clean, proof-sufficient, and more narrowly scoped.

Members:

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

Canonical path: Close this branch and concentrate maintainer review on #94088; after that lands, close the linked bug report and remaining duplicate fix PRs.

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

Review details

Best possible solution:

Close this branch and concentrate maintainer review on #94088; after that lands, close the linked bug report and remaining duplicate fix PRs.

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

Yes. The linked bug report provides concrete Telegram logs, and current main shows sourceReplyDeliveryMode: message_tool_only can still fall through to durable delivery for a no-tool final-text payload.

Is this the best way to solve the issue?

No. A heartbeat-runner guard is the right area, but this branch is broader than the privacy contract; the canonical PR is the better solution because it scopes to explicit message_tool visibility and preserves delivery exceptions.

Security review:

Security review cleared: No workflow, dependency, lockfile, credential, script, package, or supply-chain surface is changed; the risk is functional privacy and message delivery.

AGENTS.md: found and applied where relevant.

What I checked:

  • Repository policy read and applied: Root AGENTS.md was read fully; its PR review, best-fix, duplicate-close, Telegram proof, and Codex-source inspection requirements shaped this review. (AGENTS.md:1, fcec95ffd7a5)
  • Current response-tool decision is broader than explicit privacy opt-in: Current main returns true for explicit message_tool visibility, but otherwise falls back to usesCodexHarness, so usesHeartbeatResponseTool is not equivalent to an operator privacy opt-in. (src/infra/heartbeat-runner.ts:513, fcec95ffd7a5)
  • Current main forces message_tool_only when response-tool mode is active: The heartbeat runner passes sourceReplyDeliveryMode: message_tool_only whenever usesHeartbeatResponseTool is true, creating the linked no-tool final-text leak path on current main. (src/infra/heartbeat-runner.ts:1817, fcec95ffd7a5)
  • Existing exec-completion delivery exception: Current main preserves relayable exec-completion output before deciding to skip heartbeat delivery; this PR's new early return runs before that fallback and does not check hasRelayableExecCompletion. (src/infra/heartbeat-runner.ts:1918, fcec95ffd7a5)
  • Source-reply contract: The source reply option contract says message_tool_only keeps normal final text private unless dispatch explicitly marks a source reply deliverable. (src/auto-reply/get-reply-options.types.ts:210, fcec95ffd7a5)
  • PR guard is too broad: The submitted patch suppresses any no-tool heartbeat reply under usesHeartbeatResponseTool unless the payload has deliverDespiteSourceReplySuppression metadata; it does not scope to explicit message_tool visibility and does not preserve relayable exec completions. (src/infra/heartbeat-runner.ts:1852, e9b47cca5850)

Likely related people:

  • neeravmakwana: Authored the merged heartbeat message-tool delivery policy work in Fix heartbeat message-tool delivery policy #85357, which touched the runner and tool-response tests central to this bug. (role: introduced behavior; confidence: high; commits: bd9c78f957b8; files: src/infra/heartbeat-runner.ts, src/infra/heartbeat-runner.tool-response.test.ts)
  • joshavant: Was credited on the merged message-tool delivery policy change and later authored adjacent heartbeat suppressed-delivery work in the same runner area. (role: merger and adjacent area contributor; confidence: medium; commits: bd9c78f957b8, 3643de4ba7b6; files: src/infra/heartbeat-runner.ts, src/infra/heartbeat-runner.tool-response.test.ts)
  • vincentkoc: Current-main blame for the central response-tool decision and delivery block points at recent carried-forward runner work by this author, useful for routing even though it is not original feature authorship. (role: recent refactor carrier; confidence: medium; commits: 4e476d333ee4, 712e69dd74; files: src/infra/heartbeat-runner.ts)

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

@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. labels Jun 19, 2026
@clawsweeper clawsweeper Bot added 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 19, 2026
@clawsweeper

clawsweeper Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

@clawsweeper clawsweeper Bot closed this Jun 19, 2026
@openclaw-mantis

Copy link
Copy Markdown
Contributor

Mantis Telegram Desktop Proof

Summary: Mantis captured native Telegram Desktop before/after GIF evidence for the heartbeat reply behavior.

Main This PR
Baseline native Telegram Desktop proof GIF Candidate native Telegram Desktop proof GIF

Motion-trimmed clips:

Raw QA files: https://artifacts.openclaw.ai/mantis/telegram-desktop/pr-94485/run-27811876035-1/index.json

This branch had an error being deployed

1 failed deployment
qa-live-shared — e9b47cca Deployed Jun 19, 2026 by clawsweeper[bot] via Run agentic native Telegram proof #196903
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. 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. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

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

2 participants