Skip to content

fix: stop paid ambient heartbeat retries during channel outages - #173003

Merged
steipete merged 4 commits into
mainfrom
fix/heartbeat-channel-not-ready-backoff
Oct 15, 2026
Merged

steipete merged 4 commits into
mainfrom
fix/heartbeat-channel-not-ready-backoff

Conversation

@steipete

@steipete steipete commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #172988

What Problem This Solves

Fixes repeated paid ambient heartbeat turns every minute when the delivery channel stays disconnected.

User Impact

Ambient heartbeat polls with no required payload, scheduled task, or queued event check channel readiness before invoking the model. Unavailable-channel checks back off from one minute to the heartbeat interval, and the next retry runs normally after recovery.

Cron-carried tasks, queued event payloads (including events found on scheduled polls), and manual/triggered turns still execute their prompts during an outage. Only their final delivery is gated by readiness, and their existing one-minute delivery retry remains unchanged. Ready targets and heartbeats without a channel target retain their behavior.

Why This Change Was Made

The readiness adapter previously ran only after the model reply, while the wake queue retained channel-not-ready with a fixed 60-second delay. A single execution-owned ambient-poll classification now controls the pre-model readiness check and eligibility for wake-owned exponential backoff. The existing final delivery check remains authoritative for required work and for channels that disconnect during a model turn.

Coordinator product decision, as corrected in review: the cost-saving preflight and exponential backoff apply only to ambient polls without required work. A shared broadcast containing any required work keeps ordinary delivery retries; an ambient-only broadcast uses the shortest participating cadence. No configuration, schema, dependency, or public SDK changes.

Retry facts: preflight events/tasks define the current turn's owned payload; late arrivals retain their queue/wake ownership. Each retry resolves current config, session, delivery identity/account and paths through existing owners and retains the existing lifetime/store fences. The scheduled interval remains authoritative for its persisted occurrence; otherwise the current resolved interval supplies the cap. The per-attempt cap is disabled by any required participant. Preflight readiness never authorizes a later send: delivery checks it again.

ClawSweeper findings on 3e28aefe079d addressed:

  • P1, preserve required work: tasks and queued events bypass the pre-model readiness gate and exponential backoff. Regressions assert their actual payload reaches the model before final delivery is blocked, including an event carried by a scheduled poll; manual turns and ordinary required-work retry timing are covered too.
  • P3, stale retry description: both the defaults and delivery sections now distinguish a mid-turn delivery failure, later readiness-only ambient retries, and required-work delivery retries.

Production LOC exception: +85/-36 (net +49), funding the readiness preflight and wake-owned retry state while reusing the existing execution classification. Tests +183/-5; docs +2/-1. No unrelated code was removed to meet a LOC target.

Evidence

PR CI is the test gate under the maintainer proof policy. Exact-head CI run 38719948315 passed on 06772af215abc16d672ee3340e4373a0e0d58ea4: 43 successful jobs, no failures or reruns. Status was read live with OCTOPOOL_FRESH=1. This covers the selected Node test suites (including the required-payload and ambient regressions), production/test types, lint, docs, package boundaries, browser E2E, and baseline ratchets. The earlier green run on 3e28aefe079d is prior-head evidence only.

Regression coverage:

  • skips the model when WhatsApp is not linked and checks readiness before the model and recovers: %s: ambient polls make zero model calls while unavailable; recovery and no-target behavior are preserved.
  • executes $kind work from $source before gating unavailable delivery: cron-carried tasks, queued events, scheduled polls with queued events, and manual turns execute their prompts before the final readiness check.
  • backs off channel readiness to the heartbeat interval and resets after recovery: fake-timer ambient backoff, coalescing, transition logs, and reset.
  • keeps the one-minute delivery retry for required %s work: fake-timer task/event retries retain the existing timing.
  • Existing tests retain final-delivery coverage for channels that disconnect during a model turn.

Changed-file core-config oxlint, oxfmt --check, and git diff --check passed. Deslop completed. Fresh Codex P0–P2 branch autoreview: scoped-clean, no accepted/actionable findings. Review executed no project code or tests.

Local tests, test wall-time measurement, typechecks, production negative controls, and live Gateway/Crabbox/Testbox proof were intentionally skipped per maintainer policy. PR CI supplies the test proof. No leases or Gateways were created.

ClawSweeper’s published needs-changes comment still references 3e28aefe079d; the P1/P3 corrections above are in the new head. No inline review finding targets the new head at handoff.

@clawsweeper

clawsweeper Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 15, 2026 09:44
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T10:27:17.364629Z 06772af New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: S labels Oct 15, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 15, 2026
@clawsweeper

clawsweeper Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR skips model execution for unavailable-channel ambient heartbeat polls and backs off their readiness retries while preserving required work.

Example: A heartbeat runs every 2 hours with WhatsApp disconnected and no queued events or tasks.

  • Before: Unavailable delivery can trigger another paid model turn every 60 seconds.
  • After: Readiness checks skip the model and back off from 1 minute toward the 2-hour cadence.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A useful, focused correction with successful exact-head CI and both earlier findings resolved; confidence rests on source and in-process coverage rather than shipped-entry-point evidence.
Proof confidence 🦐 gold shrimp (3/6) The maintainer-authored PR is outside the ordinary contributor proof gate; verified exact-head CI supports the runner and wake-queue regressions, and no live outage or recovery proof is claimed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A disconnected heartbeat destination can cause repeated paid model turns every minute for hours.
Reason: The maintainer-authored direction targets demonstrated spend, limits the change to ambient polls, and preserves required task and event processing.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-directed fix addresses a current paid-retry defect, resolves both earlier findings, and introduces no new actionable defect identified in this review.

Priority: P1
Reviewed head: 06772af215abc16d672ee3340e4373a0e0d58ea4

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No shipped Gateway outage-and-recovery trace or base-failing regression run is supplied; the added coverage exercises production owners with mocked model and transport boundaries.
Agent review details

How this fits together

The heartbeat runner resolves scheduled or triggered work and its destination, invokes ordinary reply execution, and returns an outcome to the shared wake queue, which owns retries.

flowchart TD
  A[Scheduled or triggered wake] --> B[Shared wake queue]
  B --> C[Resolve payload and destination]
  C --> D[Ambient readiness check]
  D --> E[Model execution]
  E --> F[Final delivery readiness]
  F --> G[Channel delivery]
  D --> B
  F --> B
Loading

Technical review

Best possible solution:

Keep ambient outage retries model-free within the existing wake owner while preserving required payload execution and final delivery checks.

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

Current-main execution, dispatch, wake retention, and scheduler bookkeeping establish the repeated paid-turn path; this read-only review executed no target code.

Is this the best way to solve the issue?

The fix addresses model invocation before unavailable delivery, reuses the existing readiness adapter and retry owner, and preserves the required-work distinction corrected after the earlier review.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 1fa52a027662.

Provenance checked

  • Readiness delivery retry policy changes intended behavior with a stated reason (fix(cron): close restart-recovery identity gaps and stop silent heartbeat alert drops #131219: Record blocked alerts and retry without silently consuming the heartbeat cadence slot.)
  • Shared wake scheduling and retry ownership keeps the original intent (96f4a52: Unify wake coalescing, backoff, cancellation, and settlement under one process-owned queue.)
  • Pre-execution scheduled-poll settlement keeps the original intent (5599536: Settle untouched busy polls while retaining tasks, queued events, and admitted work.)
  • Required-work execution without a deliverable route keeps the original intent (ba9e72c: Skip routeless ambient model burn while allowing triggered payloads, queued events, and scheduled tasks to execute.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +49, Tests +178, Docs +1. Total +228 across 7 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 85 36 +49
Tests 3 183 5 +178
Docs 1 2 1 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 270 42 +228

Review metrics

Metric Value Why it matters
Production versus test LOC Production +85/-36; tests +183/-5. Production growth adds the readiness preflight and retry state in existing owners; tests cover payload preservation, outage recovery, coalescing, and retry timing.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove merge-risk: 🚨 compatibility: Current PR review selected no merge-risk labels.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: The current outage path can repeatedly invoke paid models outside the configured heartbeat cadence, with prolonged unattended spending reported.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-15T10:13:26.045Z sha 3e28aef :: needs changes before merge. :: [P1] Preserve required work when delivery readiness fails | [P3] Update the existing delivery retry description

Reviewed October 15, 2026, 7:08 AM ET / 11:08 UTC (Revision 2).

@steipete steipete changed the title fix: stop paid heartbeat retries while delivery channels are unavailable fix: stop paid ambient heartbeat retries during channel outages Oct 15, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 15, 2026
@steipete
steipete merged commit 3cef8a4 into main Oct 15, 2026
147 of 150 checks passed
@steipete
steipete deleted the fix/heartbeat-channel-not-ready-backoff branch October 15, 2026 11:14
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 16, 2026
…claw#173003)

* fix: skip heartbeat model turns while delivery channels are unavailable

* fix: preserve required heartbeat work during channel outages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Heartbeat retries channel-not-ready every 60 s with no cap, re-running the full model turn each time

1 participant