Skip to content

fix(heartbeat): monitor wakes honor configured session - #127153

Merged
steipete merged 1 commit into
mainfrom
maint/heartbeat-session-routing-replacement-116373
Aug 21, 2026
Merged

steipete merged 1 commit into
mainfrom
maint/heartbeat-session-routing-replacement-116373

Conversation

@steipete

@steipete steipete commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Closes #116205.
Related: #116373.

Additional instructions

MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.

What Problem This Solves

Fixes an issue where users configuring agents.*.heartbeat.session would still have recurring monitor and migrated heartbeat-task runs execute in the agent's main session. That selected the wrong pending-event queue, transcript, session identity, and delivery route.

Why This Change Was Made

The Gateway cron adapter now omits only the synthetic session key for sessionless source: "interval" wakes, allowing the heartbeat runner to apply the configured session. Explicit user sessions, ordinary cron-event queue ownership, monitor scheduling metadata, and runHeartbeatOnce remain unchanged.

This is a workflow-only same-repository maintainer replacement for external-source PR #116373. The accepted external head cannot satisfy the strict Clownfish external landing transaction. The production and test patch is exactly equivalent to accepted head 46626554072f948759ab44635b718819d1e6af77, rebased as one canonical child of current main; no behavior or proof was changed for the replacement.

Original contribution and commit authorship: @sloptop-the-terrible in #116373. Original report: @QQSHI13 in #116205.

User Impact

Recurring heartbeat monitor/task runs honor the configured non-main heartbeat session. Explicit user-targeted wakes still use their requested session, while normal cron events continue to consume the same main/session queue where their event was enqueued.

Evidence

Native review artifacts are complete and validated. OPENCLAW_TESTBOX=1 scripts/pr prepare-run and scripts/pr merge-run remain the only landing path and must pass before merge.

Sessionless interval heartbeat monitor and task wakes now defer to the
configured heartbeat session, while explicit user sessions and ordinary cron
event queue ownership remain unchanged.

Maintainer replacement for #116373 because the external fork cannot satisfy
the strict Clownfish landing transaction. The replacement preserves the
accepted patch exactly on current main.

Fixes #116205.
Thanks @sloptop-the-terrible for the original patch and @QQSHI13 for the report.
@clawsweeper

clawsweeper Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: L maintainer Maintainer-authored PR labels Aug 21, 2026
@steipete steipete self-assigned this Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 21, 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 exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 21, 2026
@clawsweeper

clawsweeper Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 21, 2026, 8:04 AM ET / 12:04 UTC.

ClawSweeper review

What this changes

The PR changes Gateway cron wake routing so monitor and migrated heartbeat-task wakes without a caller session use the configured heartbeat session.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open for maintainer review: current main still forces keyless interval wakes into the agent’s main session, and this PR restores configured heartbeat-session routing at the producer boundary.

Priority: P1
Reviewed head: 6c211938c2555a2ffc71de625d3d5374ce1ca427
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) The patch is a focused owner-boundary repair with direct Gateway proof and no correctness findings.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The PR body provides linked secretless real-Gateway E2E evidence on the stated patch-equivalent source head, and the added E2E exercises the same queue-to-delivery path.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The PR body provides linked secretless real-Gateway E2E evidence on the stated patch-equivalent source head, and the added E2E exercises the same queue-to-delivery path.
Evidence reviewed 7 items Current-main failure path: Current main resolves an agent-only interval wake and forwards the resulting main-session key to the heartbeat queue.
Keyless interval producers: Both monitor and migrated heartbeat-task paths emit interval wakes with an agent ID but no session key.
Forced-session contract: A valid forced session is selected before heartbeat.session, making the synthetic main key change queue and delivery selection.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs test/e2e/qa-lab/runtime/gateway-heartbeat-session-routing.e2e.test.ts

Result: FAIL (partial) — step 2 expect_output Gateway heartbeat session routing: expected terminal output was not visible within 30 seconds: "Gateway heartbeat session routing"

node scripts/run-vitest.mjs test/e2e/qa-lab/runtime/gateway-heartbeat-session-routing.e2e.test.ts
runner@runnervm76f27:/tmp/clawsweeper-live-proof-127153-iw7hgi/target$ node scripts/run-vitest.mjs test/e2e/qa-lab/runtime/gateway-heartbeat-session-routing.e2e
.test.ts
[test] starting test/vitest/vitest.e2e.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-127153-iw7hgi/target

node scripts/run-vitest.mjs test/e2e/qa-lab/runtime/gateway-heartbeat-session-routing.e2e.test.ts
[openclaw] Building TypeScript (dist is stale: missing_private_qa_dist - private QA dist entry missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
  - tsdown:deps (44%)
  - rolldown-plugin-dts:generate (23%)
  - rolldown-plugin-dts:fake-js (22%)
See https://rolldown.rs/reference/InputOptions.checks#plugintimings for more details.

[tsdown-build] invocation 1/11 finished in 4.6s
[tsdown-build] invocation 2/11 finished in 20.6s






























Assertions:

  • FAIL expect_output: Gateway heartbeat session routing

How this fits together

Gateway cron executes scheduled monitor and heartbeat-task jobs by placing heartbeat wakes onto the shared runner queue. The selected session controls pending events, transcripts, and delivery routing.

flowchart LR
  A[Heartbeat monitor or task] --> B[Sessionless interval wake]
  B --> C[Gateway cron adapter]
  C --> D{Caller provided a session?}
  D -- No --> E[Configured heartbeat session]
  D -- Yes --> F[Explicit caller session]
  E --> G[Queue transcript and delivery]
  F --> G
Loading

Decision needed

Question Recommendation
After exact-head CI completes, should this maintainer-owned PR land the intended routing correction for existing heartbeat.session configurations? Validate and land: Accept the owner-boundary repair once required checks confirm configured, explicit, and ordinary cron-event paths.

Why: The change intentionally alters persisted-session execution and delivery behavior for existing configurations, and the PR has a protected maintainer label.

Before merge

  • Resolve merge risk (P1) - Existing heartbeat.session configurations will intentionally change recurring queue, transcript, and delivery selection away from synthetic main; exact-head CI should confirm the upgrade behavior before landing.
  • Complete next step (P2) - A protected maintainer-owned routing change needs exact-head CI completion and merge judgment, not an automated repair.
Agent review details

Security

None.

PR surface

Source +3, Tests +694. Total +697 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 4 1 +3
Tests 2 694 0 +694
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 698 1 +697

Review metrics

Metric Value Why it matters
Production versus regression coverage production +4/-1 (net +3); tests +694/-0 The small owner-boundary change is paired with unit and full Gateway coverage of queue, transcript, and delivery routing.

Merge-risk options

Maintainer options:

  1. Validate the current head, then land (recommended)
    Complete exact-head CI and preserve proof that configured, explicit, and ordinary cron-event routes remain distinct.
  2. Pause for routing-policy review
    Do not merge if maintainers want main-session behavior to remain the compatibility default despite heartbeat.session.

Technical review

Best possible solution:

Keep the conditional adapter routing and land it once exact-head validation confirms configured-session execution while explicit and ordinary cron-event paths remain unchanged.

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

Yes—current main’s keyless interval producer, synthesized main key, and forced-session precedence establish the failure path; the added regression would fail on that pre-fix route.

Is this the best way to solve the issue?

Yes—the adapter is the narrowest owner boundary because it converts a keyless interval request into an unintended forced main session; changing the runner would weaken legitimate explicit callers.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides linked secretless real-Gateway E2E evidence on the stated patch-equivalent source head, and the added E2E exercises the same queue-to-delivery path.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P1: Configured heartbeat sessions currently select the wrong session state and delivery route for recurring runs.
  • merge-risk: 🚨 session-state: Merging changes which existing heartbeat.session configurations consume queues and write transcripts.
  • merge-risk: 🚨 message-delivery: The selected session determines the outbound route used by recurring heartbeat replies.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The PR body provides linked secretless real-Gateway E2E evidence on the stated patch-equivalent source head, and the added E2E exercises the same queue-to-delivery path.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides linked secretless real-Gateway E2E evidence on the stated patch-equivalent source head, and the added E2E exercises the same queue-to-delivery path.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the durable heartbeat-monitor refactor and is the strongest recurring contributor in the affected Gateway/cron history. (role: heartbeat-monitor feature owner and recent Gateway contributor; confidence: high; commits: 95b86a3b2b32, 72c8bf9946ee; files: src/cron/heartbeat-monitor.ts, src/gateway/server-cron.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 (2 earlier review cycles)
  • reviewed 2026-08-21T10:39:24.662Z sha 6c21193 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-21T11:21:23.442Z sha 6c21193 :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as ready for review August 21, 2026 11:59
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 21, 2026
@steipete
steipete merged commit 02bba8e into main Aug 21, 2026
498 of 500 checks passed
@steipete
steipete deleted the maint/heartbeat-session-routing-replacement-116373 branch August 21, 2026 12:11

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 22, 2026
…127153)

Sessionless interval heartbeat monitor and task wakes now defer to the
configured heartbeat session, while explicit user sessions and ordinary cron
event queue ownership remain unchanged.

Maintainer replacement for openclaw#116373 because the external fork cannot satisfy
the strict Clownfish landing transaction. The replacement preserves the
accepted patch exactly on current main.

Fixes openclaw#116205.
Thanks @sloptop-the-terrible for the original patch and @QQSHI13 for the report.

Co-authored-by: sloptop-the-terrible <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR 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. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: L 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.

heartbeat: agents.*.heartbeat.session is ignored because cron monitor passes forcedSessionKey=main

2 participants