Repository navigation
fix(heartbeat): prevent replies disappearing during active heartbeats - #123458
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 14, 2026, 8:16 AM ET / 12:16 UTC. ClawSweeper reviewWhat this changesThe PR makes visible turns preempt same-session heartbeats, suppresses preempted heartbeat output, and defers retained heartbeat work before retrying it. Regression provenancePossible regression — suspected (reviewed change; failure trace). No predecessor PR is attributed. Merge readinessKeep open for maintainer review. The branch addresses a current shared-session reply-loss path and has credible changed-path Telegram proof, but it intentionally changes scheduled heartbeat retry behavior from the existing one-second retry to a 60-second idle grace. Priority: P1 Review scores
Verification
How this fits togetherHeartbeat work and channel replies enter the same reply-operation and embedded-run lifecycle. This change gives a user-visible turn ownership of that lifecycle, then prevents the preempted background run from delivering stale output or consuming retained work. flowchart LR
A[Scheduled heartbeat] --> C[Shared reply operation]
B[Visible channel turn] --> C
C --> D{Heartbeat owns session?}
D -->|yes| E[Preempt and drain heartbeat]
E --> F[Deliver visible reply]
E --> G[Retain heartbeat work]
G --> H[Retry after idle grace]
Decision needed
Why: This is an intentional default scheduling-policy change with user-visible latency consequences; source inspection can establish the mechanics but cannot choose the desired product tradeoff. Before merge
Agent review detailsSecurityNone. PR surfaceSource +278, Tests +530. Total +808 across 37 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land one shared-session supersession path only after a maintainer records acceptance of the 60-second scheduled idle grace and its delayed-background-work tradeoff. Do we have a high-confidence way to reproduce the issue? No independent current-main run was executed in this read-only review; source shows visible turns only waiting on the shared owner, and the PR supplies a redacted before/after Telegram trace for that path. Is this the best way to solve the issue? Yes, with the retry-policy decision resolved: the branch repairs ownership at reply admission and embedded-run lifetime rather than adding a Telegram-specific workaround. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ad400d810b3b. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (8 earlier review cycles)
|
62e80fe to
97b4107
Compare
6583254 to
3452317
Compare
3452317 to
1caacff
Compare
1caacff to
034bfb7
Compare
|
Maintainer decision confirmed: accept the 60-second idle grace for scheduled busy/preempted heartbeat work. This prioritizes visible conversation continuity while retaining background work; fresh manual/immediate wakes continue to bypass the defer. |
|
Merged via squash.
|
…openclaw#123458) * fix(heartbeat): prioritize visible turns over active runs * fix(heartbeat): preserve embedded run ownership * fix(heartbeat): drain preempted run ownership * test(heartbeat): cover retained preemption work * fix(heartbeat): retain work across visible preemption * fix(heartbeat): fence finalizing supersession
Fixes #40611.
Problem
A Telegram DM arriving during an active default heartbeat could reach the model but never receive a visible reply. The default heartbeat and DM share one session, transcript, and delivery route.
Root cause
Reply admission lacked an explicit ownership handoff from background heartbeat work to a visible turn. The visible prompt could be steered into the heartbeat while that heartbeat still owned terminal delivery. A finalizing heartbeat was also treated as non-abortable, allowing its send to escape the handoff.
Fix
Proof
Before editing, the original owner regressions failed in three places: heartbeat finalized instead of reporting preemption, scheduled busy work retried after 1 second, and preempted work was lost (
3 failed, 79 passed).ClawSweeper later found the terminal-boundary variant. The added owner regression failed on old behavior with
status: ranand a sendable result; fixed behavior returns{ status: "skipped", reason: "preempted" }and performs no Telegram send.Exact local head
034bfb7462c3dea1e9b97f52f83b1e4618e086d7:pnpm lint: passed.pnpm tsgo: passed.pnpm check:test-types: passed.pnpm deadcode:dependencies: passed.git diff --check: passed.Covered boundaries: no partial send, no scratch write, retained event work, exact-handle replacement/drain, finalization-safe suppression, isolated-session non-preemption, fresh manual/immediate wake bypass, cadence/cooldown preservation, and direct-cron 120-second cap.
Before-fix live Telegram reproduction, redacted:
Exact-head CI run
31798091029: passed, 104 jobs, zero failures.Exact-head ClawSweeper final local review: PASS; patch correct, 0 findings, security cleared, no maintainer decision, 0 Rank-up moves.
Final Telegram changed-path proof (real QA user, fresh gateway, exact checkout; redacted):
Provider log: 5 requests, including the held heartbeat path and the visible follow-up. Gateway and mock teardown were clean; no pending webhook updates.
Base-drift rebuttal: rebased onto
508b35d9278c2d95638d69ea59a4d712f5bcfb3dimmediately before this proof; head remains mergeable and exact-head CI is green. Main advanced during proof. Fast-lane drift policy says BEHIND merges and only CONFLICTING rebases; no rebase churn.Production delta: +288/-76 (net +212). Tests/support: +725/-129 (net +596). Growth owns typed supersession, exact-handle lifecycle handoff, and retained retry policy; Distill found no smaller coherent owner-boundary expression.
Maintainer decision
Accepted by Ayaan in the authoring thread: scheduled busy/preempted heartbeat work uses the 60-second idle grace instead of the former 1-second retry. This intentionally prioritizes visible conversation continuity while retaining background work. Fresh manual/immediate wakes bypass deferred scheduled work.
Ready for maintainer review; no merge will be performed by this agent.