Skip to content

fix(heartbeat): harden commitment check-in delivery - #79504

Closed
Countermarch wants to merge 1 commit into
openclaw:mainfrom
Countermarch:codex/commitment-heartbeat-no-thinking
Closed

Countermarch wants to merge 1 commit into
openclaw:mainfrom
Countermarch:codex/commitment-heartbeat-no-thinking

Conversation

@Countermarch

@Countermarch Countermarch commented May 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Commitment-only heartbeat runs use OpenClaw's built-in inferred-commitment prompt, which can bypass HEARTBEAT.md. This hardens that path so inferred-commitment check-ins stay usable and conversation-aware.

Problem

We observed Telegram receiving an inferred-commitment heartbeat message that began with visible reasoning:

think
The user's message is a heartbeat poll.
...
If your wife has posted in Travel Agent, I can grab her Telegram ID and update the topic access.

The existing commitment prompt already tells the model not to mention commitment machinery, but it does not tell the model to suppress visible analysis/reasoning preambles. Deployments that add that guard in HEARTBEAT.md are still exposed because commitment-only runs can use buildCommitmentHeartbeatPrompt directly.

There is also a follow-on usability gap: a visible heartbeat check-in can be delivered to Telegram without being mirrored into the source session transcript. When the user replies to that check-in in Telegram, the agent may not see the proactive message it is replying to.

Fix

  • Add a no-visible-reasoning/no-preamble instruction to buildCommitmentHeartbeatPrompt.
  • Keep the instruction narrowly scoped to final visible heartbeat output: either concise check-in text or exactly HEARTBEAT_OK.
  • Mirror visible heartbeat deliveries into the base session transcript so user replies have the proactive check-in in conversation history.
  • Pass the owning session-store path through delivery mirror metadata so mirrors append to the correct store, including custom/test session stores.
  • Add regression coverage in the existing commitment heartbeat tests for both the prompt guard and transcript mirror behavior.
  • Add an Unreleased changelog entry.

Real Behavior Proof

Ran a disposable local heartbeat with a fake Telegram transport and redacted identifiers. The run used the real runHeartbeatOnce delivery path, a pending inferred commitment scoped to agent:main:telegram:user-redacted, and a mocked model reply that verified the prompt contained the no-reasoning/no-think guard before returning a visible check-in.

{
  "result": {
    "status": "ran",
    "durationMs": 5198
  },
  "telegramSends": [
    {
      "to": "redacted-chat-id",
      "text": "If the Travel Agent post is available, I can update the topic access.",
      "accountId": "primary"
    }
  ],
  "commitment": {
    "id": "cm_pr_proof",
    "status": "sent",
    "attempts": 1,
    "sentAtMs": 1778269543261
  },
  "transcript": {
    "fileBasename": "proof-session.jsonl",
    "hasDeliveryMirror": true,
    "hasVisibleCheckIn": true,
    "hasVisibleThinkLeak": false,
    "tail": [
      {
        "type": "session"
      },
      {
        "type": "message",
        "idempotencyKey": "heartbeat:commitments:agent:main:telegram:user-redacted:cm_pr_proof",
        "role": "assistant",
        "provider": "openclaw",
        "model": "delivery-mirror",
        "text": "If the Travel Agent post is available, I can update the topic access."
      }
    ]
  }
}

This demonstrates that the visible check-in is delivered to the Telegram-equivalent transport, does not include a visible think leak, marks the commitment sent, and appends the same check-in as a delivery-mirror assistant message to the source session transcript.

Test Plan

  • pnpm test src/infra/heartbeat-runner.commitments.test.ts
  • pnpm check:changed

Notes

I checked open PRs/issues first. There are several related thinking/reasoning leak fixes, and PR #75469 touches inferred-commitment heartbeat scheduling. PR #79502 mirrors Telegram outbound replies in another delivery path, but I did not find an open PR covering commitment heartbeat prompt leakage plus heartbeat delivery mirroring.

@openclaw-barnacle openclaw-barnacle Bot added size: XS triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 8, 2026
@clawsweeper

clawsweeper Bot commented May 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 7, 2026, 7:22 PM ET / 23:22 UTC.

Summary
This branch adds no-visible-reasoning wording to inferred-commitment heartbeat prompts, attempts to mirror visible heartbeat sends into session transcripts, adds regression assertions, and edits CHANGELOG.md.

PR surface: Source +15, Tests +12, Docs +1. Total +28 across 5 files.

Reproducibility: yes. Current source shows the prompt lacks the proposed guard and replay filters delivery-mirror rows; the Mantis Telegram Desktop artifact for this head also reports the candidate still misses proactive check-in context.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: serialized state: src/infra/heartbeat-runner.commitments.test.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: partial_overlap
Canonical: #88757
Summary: This PR overlaps the broader proactive-message/session-context bug, while stale commitment revalidation and pending-question linkage remain tracked separately.

Members:

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

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🧂 unranked krab
Result: blocked until stronger real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Rebase against current main and decide whether this should be prompt-only or should replace the context layer with provider-visible pending-question/system-event state.
  • [P1] Add after-fix Telegram or equivalent real behavior proof showing both no visible reasoning leak and a follow-up reply that sees the proactive check-in context.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The PR body's fake-transport proof does not prove the real Telegram follow-up context path, and the linked Mantis Telegram Desktop artifact reports this head still fails that behavior. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] The patch stores the proactive check-in as a delivery-mirror transcript row, but provider replay intentionally filters those rows, so user replies can still lack the proactive question context.
  • [P1] The branch is based on an older heartbeat delivery call shape and is now conflicting with current main's sendDurableMessageBatch path.
  • [P1] The available Telegram Desktop proof is negative for the claimed follow-up-context behavior, so merging would risk a false sense that the conversation-desynchronization bug is fixed.

Maintainer options:

  1. Narrow to prompt hardening
    Drop the transcript-mirror context change, rebase onto current main, and prove the commitment prompt no longer leaks visible reasoning.
  2. Replace with provider-visible context
    Keep the context goal only if the branch stores delivered questions in a path that provider replay actually sees and proves the Telegram follow-up end to end.
  3. Pause or close this branch (recommended)
    Close this stale conflicting branch and keep the remaining context work on the canonical tracker instead of merging a failed proof path.

Next step before merge

  • [P1] Maintainer choice is needed because automation should not merge or repair a conflicting external PR whose context half failed real proof and overlaps open canonical work.

Maintainer decision needed

  • Question: Should maintainers close this stale conflicting PR in favor of the canonical proactive-context issues, or ask for a narrow current-main refresh that keeps only the prompt guard?
  • Rationale: Automation cannot safely choose because the branch contains one useful prompt hardening change, but its context fix failed real proof, overlaps open canonical work, and now conflicts with current main.
  • Likely owner: vignesh07 — The decision centers on the inferred-commitments behavior introduced and owned in the feature history.
  • Options:
    • Close stale branch (recommended): Close this PR and keep the broad proactive-context and commitment-revalidation issues as the remaining trackers, inviting a new narrow prompt-guard PR if still wanted.
    • Request prompt-only refresh: Ask the author to rebase on current main and split the no-visible-reasoning prompt guard away from the failed session-context fix.
    • Adopt context work here: Require replacing transcript-only mirroring with provider-visible pending-question or system-event context plus fresh Telegram proof before merge.

Security
Cleared: The diff changes heartbeat prompt/delivery code, transcript mirror metadata, tests, and changelog text without new dependencies, workflows, package scripts, permissions, or credential handling.

Review findings

  • [P2] Use provider-visible context for heartbeat follow-ups — src/infra/heartbeat-runner.ts:1896
Review details

Best possible solution:

Close this stale PR as superseded: Pause or close this branch. Close this stale conflicting branch and keep the remaining context work on the canonical tracker instead of merging a failed proof path.

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

Yes. Current source shows the prompt lacks the proposed guard and replay filters delivery-mirror rows; the Mantis Telegram Desktop artifact for this head also reports the candidate still misses proactive check-in context.

Is this the best way to solve the issue?

No. The prompt hardening is a good narrow fix, but transcript-only mirroring is the wrong context layer because those rows are filtered before provider replay.

Full review comments:

  • [P2] Use provider-visible context for heartbeat follow-ups — src/infra/heartbeat-runner.ts:1896
    Late formal finding: this line mirrors the check-in as openclaw/delivery-mirror, but current replay drops delivery-mirror rows before model calls, so a user's Telegram reply can still lack the proactive question. The Mantis artifact for this head confirms the candidate failed the expected follow-up-context behavior; use a provider-visible pending-question/system-event path or remove the context fix from this branch.
    Confidence: 0.91
    Late finding: first raised on code an earlier review cycle already covered.

Overall correctness: patch is incorrect
Overall confidence: 0.88

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • remove proof: 📸 screenshot: Current real behavior proof evidence kind is linked_artifact.

Label justifications:

  • P2: The PR targets a real heartbeat/session-context bug with limited blast radius and no crash, security incident, or full channel outage.
  • merge-risk: 🚨 session-state: The diff changes how proactive heartbeat check-ins are represented in session history, and the chosen representation is filtered from model replay.
  • merge-risk: 🚨 message-delivery: The diff changes visible heartbeat delivery and mirroring, while negative Telegram proof shows the follow-up delivery semantics remain wrong.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR body's fake-transport proof does not prove the real Telegram follow-up context path, and the linked Mantis Telegram Desktop artifact reports this head still fails that behavior. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The PR changes visible Telegram heartbeat check-in and follow-up context behavior that can be demonstrated in a short Telegram Desktop recording.
Evidence reviewed

PR surface:

Source +15, Tests +12, Docs +1. Total +28 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 26 11 +15
Tests 1 13 1 +12
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 40 12 +28

What I checked:

  • recommended close path: the latest review's recommended merge-risk option is Pause or close this branch, categorized as pause_or_close.
  • stale PR: PR was opened 2026-05-08T19:23:55Z, which is older than the 60-day stale promotion threshold.
  • no human follow-up: live comments and timeline hydrated by apply contain no non-automation activity after the ClawSweeper review.

Likely related people:

  • vignesh07: Authored and merged the inferred-commitments feature that introduced the commitment extraction, store, runtime, CLI, tests, and heartbeat delivery surfaces. (role: feature introducer; confidence: high; commits: de19854cf42b, aecde2b3ac8b; files: src/commitments/extraction.ts, src/commitments/store.ts, src/infra/heartbeat-runner.ts)
  • joshavant: Authored and merged the recent suppressed heartbeat commitment delivery fix that a refreshed version of this PR must preserve. (role: recent adjacent contributor; confidence: high; commits: 3643de4ba7b6; files: src/infra/heartbeat-runner.ts, src/infra/heartbeat-runner.commitments.test.ts)
  • steipete: Commit history for delivered outbound message mirroring traces the transcript and outbound mirror path to this commit author. (role: introduced related transcript mirror behavior; confidence: high; commits: fdaeada3ec76; files: src/config/sessions/transcript.ts, src/infra/outbound/deliver.ts)
  • Benjamin Badejo: Recently changed commitment heartbeat fan-out scoping in the same runner and test files now conflicting with this branch. (role: recent heartbeat contributor; confidence: medium; commits: ee8652d004e5; files: src/infra/heartbeat-runner.ts, src/infra/heartbeat-runner.commitments.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@Countermarch
Countermarch force-pushed the codex/commitment-heartbeat-no-thinking branch from 2f7f5b8 to 4cf7f38 Compare May 8, 2026 19:41
@Countermarch Countermarch changed the title fix(heartbeat): suppress commitment thinking leaks fix(heartbeat): harden commitment check-in delivery May 8, 2026
@Countermarch
Countermarch force-pushed the codex/commitment-heartbeat-no-thinking branch from 4cf7f38 to e9d2c77 Compare May 8, 2026 19:46
@Countermarch

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Added an Unreleased changelog entry and updated the PR body with redacted real behavior proof from a disposable local inferred-commitment heartbeat run. The proof shows the Telegram-equivalent send, sent commitment status, no visible think leak, and a delivery-mirror assistant entry appended to the source session transcript.

@Countermarch

Copy link
Copy Markdown
Contributor Author

Additional live behavior evidence from our production OpenClaw install, collected after the hot-patched runtime had been running most of a day. This is intentionally scoped: it supports the visible-output hardening portion of this PR, but it does not prove the transcript-mirroring portion yet.

Live Setup

  • Runtime: OpenClaw package install 2026.5.6
  • Gateway: LaunchAgent-backed local gateway on the Mac mini
  • Channel: real Telegram direct chat 8254974239
  • Heartbeat target: telegram / explicit accountId
  • Heartbeat model observed in transcript: google-vertex/gemini-2.5-flash
  • Main agent model observed in gateway logs: openai-codex/gpt-5.5

Observed Run

A real heartbeat ran at 2026-05-09 09:53 EDT / 2026-05-09T13:53Z. The run executed the Structured schedule check and produced an alert about macOS privacy access.

Evidence from the heartbeat transcript a52f7a9c-7e2f-4d4c-9c55-635fb657f5ee.jsonl:

  • The heartbeat poll is present at 2026-05-09T13:53:42.775Z.
  • The model emitted internal thinking content while preparing and processing the schedule check.
  • The tool result contained ALERTS_BEGIN / ALERTS_END.
  • The final assistant-visible text was only the alert body:
- Structured schedule lookup is blocked by macOS privacy. Grant Full Disk Access to Homebrew node, then dismiss any existing node App Data dialog.

That final visible text did not include think, <think>, reasoning preamble text, or the alert delimiter lines.

Telegram delivery evidence:

  • sessions.json.telegram-sent-messages.json records Telegram message 14425 for chat 8254974239 at 2026-05-09T13:53:58Z.
  • Gateway log records the matching heartbeat start at 2026-05-09T09:53:41-04:00.

What This Proves

This is real runtime evidence that a heartbeat alert can contain internal model reasoning in the transcript while the Telegram-visible delivery remains clean and alert-only. It supports the no-visible-reasoning/no-preamble hardening in this PR.

What This Does Not Prove Yet

This run does not prove the transcript-mirroring portion of the PR. The user reply came in as Telegram message 14426, and the direct Telegram session 342c99a2-16ae-4d38-985c-0d7479fe6ebe begins with that reply. I did not find the prior heartbeat alert mirrored into that direct session before the reply.

So this live evidence should be treated as partial proof for the visible-output fix, and as confirmation that the mirror gap remains important. A separate controlled real-path run is still needed to prove the delivery-mirror behavior end to end.

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jun 1, 2026
@clawsweeper clawsweeper Bot added rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. and removed mantis: telegram-visible-proof Mantis should capture Telegram visible proof. labels Jun 1, 2026
@clawsweeper

clawsweeper Bot commented Jun 1, 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.

Re-review progress:

@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. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. and removed rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. labels Jun 1, 2026
@openclaw-mantis

Copy link
Copy Markdown
Contributor

Mantis Telegram Desktop Proof

Summary: Mantis captured Telegram Desktop GIFs for a proactive check-in follow-up; this PR still replied without the check-in context.

Main screenshot This PR screenshot
Baseline native Telegram Desktop screenshot Candidate native Telegram Desktop screenshot
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-79504/run-26737011167-1/index.json

@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Jun 2, 2026
@clawsweeper clawsweeper Bot added the proof: 🎥 video Contributor real behavior proof includes video or recording evidence. label Jun 2, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jun 2, 2026
@clawsweeper clawsweeper Bot added proof: 🎥 video Contributor real behavior proof includes video or recording evidence. 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. and removed proof: 🎥 video Contributor real behavior proof includes video or recording evidence. 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 15, 2026
@clawsweeper clawsweeper Bot removed the proof: 🎥 video Contributor real behavior proof includes video or recording evidence. label Jun 20, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jun 20, 2026
@clawsweeper clawsweeper Bot added proof: 🎥 video Contributor real behavior proof includes video or recording evidence. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. and removed proof: 🎥 video Contributor real behavior proof includes video or recording evidence. labels Jun 21, 2026
@clawsweeper clawsweeper Bot removed the proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. label Jul 7, 2026
@steipete steipete closed this Jul 9, 2026

This branch had an error being deployed

1 failed deployment
qa-live-shared — e9d2c777 Deployed Jun 18, 2026 by clawsweeper[bot] via Run agentic native Telegram proof #192846
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: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. 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.

2 participants