Skip to content

fix(cron): deliver final results after heartbeat acknowledgements - #113924

Merged
steipete merged 1 commit into
mainfrom
codex/fix-cron-heartbeat-terminal-e3fc85
Aug 9, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/fix-cron-heartbeat-terminal-e3fc85

Conversation

@steipete

@steipete steipete commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where scheduled agent jobs could silently lose a completed result when an earlier payload contained a heartbeat acknowledgement. Cron treated any acknowledgement anywhere in the payload batch as the terminal outcome, so a later substantive result was never sent.

Why This Change Was Made

Cron payload resolution now records one authoritative delivery disposition from the producer-owned terminal assistant text while it constructs the canonical delivery batch. Earlier standalone heartbeat acknowledgements are removed before delivery, terminal acknowledgements remain intentionally quiet, and structured or media payloads remain visible. The downstream finalizer consumes that recorded disposition instead of re-deriving it from the batch; the obsolete standalone predicate and duplicate tests were removed.

This is the owner-boundary repair rather than the stale branch's last-payload guard: the stale approach would still have sent the control token before the final result, allowing it to leak or fail before the result reached recipient custody.

User Impact

Scheduled reports, alerts, and actionable failures now reach the configured channel when a model first emits a heartbeat acknowledgement and then completes the task. Genuine terminal heartbeat-only responses remain quiet, and media or structured cron output is preserved.

Evidence

  • Reviewed head: a0b5f504a713185eabd12edb7b68f917a2b20543.
  • Regression before the repair:
    • Payload-owner plus isolated-turn seam: 2 failed, 34 passed; both failures retained HEARTBEAT_OK before the final result.
    • Real Slack outbound boundary: 1 failed, 15 passed; the run reported delivered: false and made no send.
  • Regression after the repair:
    • node scripts/run-vitest.mjs src/cron/isolated-agent.helpers.test.ts src/cron/isolated-agent/helpers.test.ts src/cron/isolated-agent/run.interim-retry.test.ts src/cron/isolated-agent/run.meta-error-status.test.ts src/cron/isolated-agent/run.message-tool-policy.test.ts src/cron/isolated-agent.direct-delivery-core-channels.test.ts — 6 files passed, 140 tests passed.
    • Real Slack outbound boundary with deleteAfterRun: 1 file passed, 16 tests passed; exactly one final result was sent and guarded session cleanup ran afterward.
  • node scripts/check-changed.mjs — passed on Blacksmith Testbox tbx_01kzk24h21bbk1bbjd2q88sg5x; formatting, core and test typechecks, lint, boundary checks, dead exports, import cycles, and database-first guards passed. Run: https://github.com/openclaw/openclaw/actions/runs/31309181158
  • Codex-backed autoreview completed cleanly with no accepted or actionable findings.
  • ClawSweeper rank-up moves addressed:
    • Earlier pure heartbeat acknowledgements are filtered at the payload-outcome owner.
    • The real outbound seam asserts that only intended user-visible payloads are sent.
  • Production LOC: +73/-68 (net +5) for the recorded owner-boundary disposition; tests: +156/-141 (net +15), including deletion of the obsolete policy suite and wrapper mocks.
  • Exact-head pull-request CI passed for a0b5f504a713185eabd12edb7b68f917a2b20543: https://github.com/openclaw/openclaw/actions/runs/31310172102
  • AI-assisted implementation, testing, and independent review.

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Jul 26, 2026
@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. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jul 26, 2026
@clawsweeper

clawsweeper Bot commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 8, 2026, 3:45 AM ET / 07:45 UTC.

ClawSweeper review

What this changes

The PR changes isolated cron delivery so a heartbeat acknowledgement or trailing empty payload does not suppress a later scheduled-job result.

Merge readiness

⛔ Blocked by patch quality or review findings - 5 items remain

This PR remains necessary, but its exact head still sends an earlier HEARTBEAT_OK with the final result, so it does not fully prevent the reported delivery failure.

Priority: P1
Reviewed head: 8e9441330e14ea86cf89a12390af49fde9cff8f6

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch has a concrete P1 delivery defect despite otherwise focused scope.
Proof confidence 🌊 off-meta tidepool Not applicable: The repository context identifies this as a maintainer-authored PR, so the external-contributor proof gate does not apply; the body’s mock-backed test claim nevertheless does not prove the outbound batch behavior.
Patch quality 🧂 unranked krab (1/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The repository context identifies this as a maintainer-authored PR, so the external-contributor proof gate does not apply; the body’s mock-backed test claim nevertheless does not prove the outbound batch behavior.
Evidence reviewed 5 items Incomplete exact-head behavior: The changed terminal-only heartbeat predicate stops suppression for a final substantive result but does not remove preceding heartbeat control payloads from the batch.
Payload owner retains the acknowledgement: The isolated-agent payload outcome retains every successful deliverable payload, while dispatch sends the retained batch in order.
Added regression locks the bad batch: The new integration-style test expects the outbound request to retain both the heartbeat acknowledgement and final result while the dispatcher is mocked.
Findings 1 actionable finding [P1] Filter earlier heartbeat acknowledgements before dispatch
Security None None.

How this fits together

Scheduled isolated-agent jobs collect agent payloads, decide whether a heartbeat-only response should stay quiet, and dispatch the resulting batch to the configured channel. This change sits between payload selection and outbound channel delivery.

flowchart LR
  A[Scheduled job] --> B[Isolated agent turn]
  B --> C[Selected payload batch]
  C --> D[Heartbeat decision]
  D --> E[Outbound delivery batch]
  E --> F[Configured channel]
Loading

Before merge

  • Filter earlier heartbeat acknowledgements before dispatch (P1) - When the final payload is substantive, this change only clears suppression; the payload outcome still retains the earlier HEARTBEAT_OK, and dispatch sends the whole batch. Recipients therefore see the control token, and failure of that first item can still prevent the final result. Filter pure earlier acknowledgements before dispatch and assert the resulting batch.
  • Resolve merge risk (P1) - Merging still exposes users to a visible heartbeat control token, and a failure delivering that first batch item can leave the substantive scheduled result undelivered.
  • Complete next step (P2) - The P1 repair is concrete, but the protected maintainer label and maintainer authorship require human handling of the existing branch.
  • Improve patch quality - Filter earlier pure heartbeat acknowledgements at the payload-outcome owner when later substantive output exists.
  • Improve patch quality - Exercise the real dispatch or injected outbound seam and assert that only intended user-visible payloads are sent.

Findings

  • [P1] Filter earlier heartbeat acknowledgements before dispatch — src/cron/heartbeat-policy.ts:28-40
Agent review details

Security

None.

PR surface

Source +4, Tests +63. Total +67 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 11 7 +4
Tests 3 64 1 +63
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 75 8 +67

Review metrics

Metric Value Why it matters
Production versus test delta production +11/-7 (net +4); tests +64/-1 (net +63) The small production change alters the delivery boundary, but the added tests currently assert the batch that leaks the control acknowledgement.

Merge-risk options

Maintainer options:

  1. Filter control acknowledgements before dispatch (recommended)
    Amend the existing branch so the selected outbound batch excludes pure earlier heartbeat acknowledgements when a later substantive payload exists, then add a dispatch-boundary assertion.

Technical review

Best possible solution:

Canonicalize cron delivery payloads before dispatch: remove pure earlier heartbeat acknowledgements when later substantive content exists, while retaining terminal-heartbeat suppression and media or structured payloads.

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

Yes—source establishes that a [HEARTBEAT_OK, substantive result] batch is retained and sent in order after this PR disables suppression.

Is this the best way to solve the issue?

No; changing only the suppression boolean is too narrow because payload selection still forwards the earlier control acknowledgement. Filtering at the selected delivery-batch owner is the narrower durable repair.

Full review comments:

  • [P1] Filter earlier heartbeat acknowledgements before dispatch — src/cron/heartbeat-policy.ts:28-40
    When the final payload is substantive, this change only clears suppression; the payload outcome still retains the earlier HEARTBEAT_OK, and dispatch sends the whole batch. Recipients therefore see the control token, and failure of that first item can still prevent the final result. Filter pure earlier acknowledgements before dispatch and assert the resulting batch.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: Scheduled jobs can still silently lose substantive results after an earlier heartbeat acknowledgement fails during delivery.
  • merge-risk: 🚨 message-delivery: The patch changes which cron payloads are dispatched and currently preserves a control payload that can affect final-result delivery.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🌊 off-meta tidepool and patch quality is 🧂 unranked krab.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The repository context identifies this as a maintainer-authored PR, so the external-contributor proof gate does not apply; the body’s mock-backed test claim nevertheless does not prove the outbound batch behavior.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the prior multi-payload heartbeat suppression work and the current proposed repair. (role: feature-history contributor; confidence: high; commits: 7253e913004a, 8e9441330e14; files: src/cron/heartbeat-policy.ts, src/cron/isolated-agent/helpers.ts)
  • joshavant: Recent current-main history carries the policy and helper boundary implicated by this delivery path. (role: recent area contributor; confidence: medium; commits: c8ff43d828; files: src/cron/heartbeat-policy.ts, src/cron/isolated-agent/helpers.ts)
  • adhishthite: Authored the earlier multi-payload heartbeat suppression work that the later cron fix credits. (role: original multi-payload contributor; confidence: medium; commits: 2330c71b633f; files: src/cron/heartbeat-policy.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (3 earlier review cycles)
  • reviewed 2026-07-26T00:18:16.437Z sha 8e94413 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-02T02:31:08.769Z sha 8e94413 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-08T04:38:39.925Z sha 8e94413 :: found issues before merge. :: [P1] Filter earlier heartbeat acknowledgements before dispatch

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 2, 2026
@steipete steipete self-assigned this Aug 9, 2026
@steipete
steipete force-pushed the codex/fix-cron-heartbeat-terminal-e3fc85 branch from 8e94413 to a0b5f50 Compare August 9, 2026 11:11
@steipete

steipete commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@steipete
steipete merged commit 05e534e into main Aug 9, 2026
142 checks passed
@steipete
steipete deleted the codex/fix-cron-heartbeat-terminal-e3fc85 branch August 9, 2026 11:27
@steipete

steipete commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant