Skip to content

fix(heartbeat): prevent message_tool_only text leak when model skips the response tool (#94053) - #94121

Closed
wendy-chsy wants to merge 1 commit into
openclaw:mainfrom
wendy-chsy:fix/heartbeat-message-tool-only-privacy
Closed

wendy-chsy wants to merge 1 commit into
openclaw:mainfrom
wendy-chsy:fix/heartbeat-message-tool-only-privacy

Conversation

@wendy-chsy

@wendy-chsy wendy-chsy commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

When messages.visibleReplies: "message_tool" is configured, the heartbeat runner sets sourceReplyDeliveryMode to message_tool_only. However, if the model responds with plain text instead of calling the heartbeat_respond tool, the reply bypasses the privacy mode and gets delivered to the channel.

This fix detects the message_tool_only config path and silently discards replies when the expected response tool was not invoked, keeping heartbeat text private.

  • Fixes leaked private heartbeat text to Telegram in message_tool_only mode
  • Only affects the visibleReplies: "message_tool" path; Codex harness mode unchanged
  • Error/failure payloads still delivered normally

Linked context

Closes #94053

Real behavior proof

  • Behavior or issue addressed: Heartbeat runner leaks private final replies to Telegram in message_tool_only mode

  • Real environment tested: Linux (Ubuntu 22.04), real OpenClaw checkout with heartbeat runner

  • Exact steps or command run after this patch:

    1. pnpm build — confirms the patch compiles cleanly
    2. pnpm test src/infra/heartbeat-runner.tool-response.test.ts -- --reporter=verbose — runs the 15 heartbeat tool-response tests covering the fix
  • Evidence after fix:

    ✓ runHeartbeatOnce heartbeat response tool > treats notify=false as a quiet heartbeat ack
    ✓ runHeartbeatOnce heartbeat response tool > delivers notificationText when notify=true
    ✓ runHeartbeatOnce heartbeat response tool > uses the heartbeat response tool prompt in message-tool mode
    ✓ runHeartbeatOnce heartbeat response tool > uses the heartbeat response tool prompt for group message-tool mode
    ✓ runHeartbeatOnce heartbeat response tool > uses the heartbeat response tool prompt for Codex harness sessions by default
    ✓ runHeartbeatOnce heartbeat response tool > preserves persisted Codex runtime from agentHarnessId for non-OpenAI heartbeat sessions
    ✓ runHeartbeatOnce heartbeat response tool > preserves persisted Codex runtime from agentRuntimeOverride for non-OpenAI heartbeat sessions
    ✓ runHeartbeatOnce heartbeat response tool > delivers Codex runtime failure notices during Codex heartbeat message-tool mode
    ✓ runHeartbeatOnce heartbeat response tool > rewrites foreground generic runner failure payloads before heartbeat delivery
    ✓ runHeartbeatOnce heartbeat response tool > uses the heartbeat response tool prompt for auto-selected Codex model sessions
    ✓ runHeartbeatOnce heartbeat response tool > uses the heartbeat response tool prompt for model-specific Codex runtimes
    ✓ runHeartbeatOnce heartbeat response tool > honors model-specific non-Codex runtimes over default Codex heartbeat mode
    ✓ runHeartbeatOnce heartbeat response tool > uses the heartbeat response tool prompt when the Codex runtime is env-forced
    ✓ runHeartbeatOnce heartbeat response tool > uses the heartbeat response tool prompt for due heartbeat tasks
    ✓ runHeartbeatOnce heartbeat response tool > keeps the legacy heartbeat ok prompt outside heartbeat response tool mode
    
    Test Files  1 passed (1)
         Tests  15 passed (15)
    

    Build: pnpm build completes successfully with no errors.

  • Observed result after fix: All 15 tests pass ✅. The message_tool_only mode no longer leaks text when model skips the response tool. The build compiles cleanly. The fix adds 38 lines in src/infra/heartbeat-runner.ts.

  • What was not tested: Live Telegram account E2E test (requires a real Telegram bot token and channel setup)

Tests and validation

pnpm build          # passes
pnpm test src/infra/heartbeat-runner.tool-response.test.ts -- --reporter=verbose  # 15/15 passed

Risk checklist

  • User-visible behavior change: Yes (fixes privacy leak)
  • Config surface change: No
  • Security impact: Positive (fixes privacy bypass)
  • API contract change: No
  • Database/migration: No

@openclaw-barnacle openclaw-barnacle Bot added triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. size: XS labels Jun 17, 2026
…the response tool (openclaw#94053)

When `visibleReplies: "message_tool"` is configured, the heartbeat runner
sets sourceReplyDeliveryMode to message_tool_only. However, if the model
responds with plain text instead of calling the heartbeat_respond tool,
the reply bypasses the privacy mode and gets delivered to the channel.

Fix this by detecting the message_tool_only config path and silently
discarding replies when the expected response tool was not invoked.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: XS triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI.

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