Skip to content

fix(heartbeat): isolated heartbeat runs leak bundle MCP child processes until Gateway restart - #143433

Merged
jalehman merged 5 commits into
openclaw:mainfrom
ylcn91:fix/heartbeat-mcp-runtime-retire
Sep 15, 2026
Merged

jalehman merged 5 commits into
openclaw:mainfrom
ylcn91:fix/heartbeat-mcp-runtime-retire

Conversation

@ylcn91

@ylcn91 ylcn91 commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Closes #143381

What Problem This Solves

Fixes an issue where operators running an agent heartbeat with isolatedSession: true and stdio MCP servers would accumulate one full set of MCP child processes per heartbeat run. The processes stayed resident until a Gateway restart, growing to hundreds of idle children and many gigabytes of RSS over a few hours, unless the operator discovered the opt-in mcp.sessionIdleTtlMs reaper.

Why This Change Was Made

Isolated heartbeats mint a fresh session ID for every run, so the bundle MCP runtime built for that run is never reused, yet nothing retired it. Isolated cron runs already retire their runtime through the existing one-shot cleanupBundleMcpOnRunEnd settlement step; this change carries that same flag from the heartbeat runner through the reply pipeline (embedded and CLI candidates) so isolated heartbeat runs retire their exact runtime at settlement. Shared (non-isolated) heartbeats are unchanged and keep the persistent main-session runtime. Active leases are preserved through the existing deferred-retirement path.

User Impact

Heartbeat runs with isolatedSession: true no longer leak stdio MCP child processes. Process count returns to baseline after each run without configuring an idle TTL or restarting the Gateway.

Evidence

Real Gateway proof (test/e2e/qa-lab/runtime/heartbeat-mcp-runtime-retire.product-proof.e2e.test.ts, opt-in with OPENCLAW_HEARTBEAT_MCP_RETIRE_PROOF=1): a built Gateway child (dist/index.js, 2026.9.3@f8a06baad7e) with agents.defaults.heartbeat = { isolatedSession: true, target: "none", lightContext: true }, a loopback mock Responses provider, and one stdio MCP server (mcp.servers.leakprobe, a tiny @modelcontextprotocol/sdk script with a unique marker in its path). Three heartbeats are forced through cron.run { mode: "force" } on the Gateway's heartbeat monitor job; each reaches status: "ok" (via cron.runs) and each run's model request advertises the probe tool, so the MCP server really was connected. MCP child processes are counted with pgrep -f <marker> before, during (peak), and after each run. The after-run and after-stop samples poll pgrep for the variant's expected state (isolated fixed: 0 children; shared: the first run's PID; main baseline: one child per run) with a 30 s bound instead of sampling once after a fixed delay, since run settlement is not a process-closure barrier; the deadline sample is recorded as-is so the assertions still judge the real state. Re-run at b5e33ef9f14 on the aa1bc7daefc build: isolated peaks 1/1/1 with 0 after every run, shared PID unchanged across all three runs, 0 after Gateway stop; retirement was observed within about 60 ms of cron.runs reporting ok.

MCP children (peak during run / after run) main, isolated (runner file at 9601bb22f39) this branch, isolated this branch, shared (isolatedSession: false)
after Gateway start 0 0 0
heartbeat 1 1 / 1 1 / 0 1 / 1
heartbeat 2 2 / 2 1 / 0 1 / 1
heartbeat 3 3 / 3 1 / 0 1 / 1
after Gateway stop 0 0 0

On main the three leaked children are the same three PIDs across every later stage (one new child per run, none reclaimed until the Gateway exits); with the fix each isolated run spawns one child and it is gone before the next run. The shared-session control on the fixed build keeps a single child with the same PID through all three runs and reaps it only at Gateway stop, so persistent-session MCP runtimes stay usable and are not retired by this change. The redacted Gateway log shows every isolated heartbeat dispatching under a fresh sessionId for the same agent:qa:main:heartbeat key, which is why the per-run runtime can never be reused:

message queued: sessionId=d5ced400-… sessionKey=agent:qa:main:heartbeat source=dispatch queueDepth=1 sessionState=idle
session state: sessionId=d5ced400-… sessionKey=agent:qa:main:heartbeat prev=processing new=idle reason="run_completed" queueDepth=0
message queued: sessionId=4fe95eb7-… sessionKey=agent:qa:main:heartbeat source=dispatch queueDepth=1 sessionState=idle

Recorded counts (PIDs are the fixture children on this machine):

# proof-main.json (2026.9.3@a293a8dcb0a, sessionMode=isolated)
before-gateway-start: 0
after-gateway-start: 0
during-heartbeat-1-peak: 1 pids=[908239]
after-heartbeat-1: 1 pids=[908239]
during-heartbeat-2-peak: 2 pids=[908239, 908284]
after-heartbeat-2: 2 pids=[908239, 908284]
during-heartbeat-3-peak: 3 pids=[908239, 908284, 908330]
after-heartbeat-3: 3 pids=[908239, 908284, 908330]
after-gateway-stop: 0
heartbeats: run 1: ok, run 2: ok, run 3: ok

# proof-fixed.json (2026.9.3@a293a8dcb0a, sessionMode=isolated)
before-gateway-start: 0
after-gateway-start: 0
during-heartbeat-1-peak: 1 pids=[877501]
after-heartbeat-1: 0
during-heartbeat-2-peak: 1 pids=[877557]
after-heartbeat-2: 0
during-heartbeat-3-peak: 1 pids=[877591]
after-heartbeat-3: 0
after-gateway-stop: 0
heartbeats: run 1: ok, run 2: ok, run 3: ok

# proof-shared.json (2026.9.3@a293a8dcb0a, sessionMode=shared)
before-gateway-start: 0
after-gateway-start: 0
during-heartbeat-1-peak: 1 pids=[879131]
after-heartbeat-1: 1 pids=[879131]
during-heartbeat-2-peak: 1 pids=[879131]
after-heartbeat-2: 1 pids=[879131]
during-heartbeat-3-peak: 1 pids=[879131]
after-heartbeat-3: 1 pids=[879131]
after-gateway-stop: 0
heartbeats: run 1: ok, run 2: ok, run 3: ok

Reproduce on a built checkout: OPENCLAW_HEARTBEAT_MCP_RETIRE_PROOF=1 OPENCLAW_E2E_SKIP_BUILD=1 OPENCLAW_HEARTBEAT_MCP_RETIRE_PROOF_SESSION=isolated node scripts/run-vitest.mjs run --config test/vitest/vitest.e2e.config.ts test/e2e/qa-lab/runtime/heartbeat-mcp-runtime-retire.product-proof.e2e.test.ts (set ..._SESSION=shared for the control; ..._VARIANT=main only labels a build made with the runner file at main).

Method notes: the heartbeat cadence is set to 24h so only the forced runs execute and every count maps to one known run; the fixture provider holds each model reply until the test has observed the fixture child, so a later zero means "retired", not "never spawned" and the sample cannot race a fast run; cron.runs confirms each run's status: "ok". The proof test is parameterized (..._VARIANT=fixed|main labels the build, ..._SESSION=isolated|shared), writes proof-<label>.json with per-stage PIDs and redacted Gateway log excerpts, and was run three times on this machine (Linux, Node 24.18) against dist builds of this branch and of this branch with the runner file at main. Successful bundle-MCP retirement emits no log line, so the process counts plus the advertised probe tool are the evidence.

Regression tests

  • src/infra/heartbeat-runner.model-override.test.ts ("retires the bundle MCP runtime only for isolated heartbeat runs") fails on main with expected undefined to deeply equal true and passes with the fix; the shared-heartbeat half proves the flag stays unset for persistent sessions.
  • src/auto-reply/reply/agent-runner-execution-lifecycle.test.ts covers forwarding through both the embedded and CLI run candidates.
  • Focused suites: 16/16 heartbeat runner cases and 33/33 lifecycle cases pass.

Checks: node scripts/check-changed.mjs passed on the fix (lint, formatting, core typecheck, core test typecheck shards, boundary and guard scripts); autoreview (Codex, P2, branch vs origin/main) scoped-clean on the fix. Two further autoreview rounds on the proof test found three P2s (Bearer redaction order, a peak-sample race against a fast run, and case-sensitive Bearer matching); all three are fixed and the three variants were rerun with the corrected test before the counts above were recorded. The proof test typechecks with zero diagnostics.

Isolated heartbeats mint a fresh session ID per run, so the bundle MCP
runtime created for that run is never reused, but nothing retired it.
Each heartbeat left its stdio MCP child processes alive until a gateway
restart or an opt-in idle TTL. Carry the existing one-shot
cleanupBundleMcpOnRunEnd flag through the reply pipeline so isolated
heartbeat runs retire their exact runtime at settlement, like isolated
cron runs already do. Shared heartbeats keep their persistent runtime.

Fixes openclaw#143381
@clawsweeper

clawsweeper Bot commented Sep 9, 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.

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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. labels Sep 9, 2026
@clawsweeper

clawsweeper Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 15, 2026, 4:16 PM ET / 20:16 UTC (Revision 7).

ClawSweeper review

What this changes

The PR retires MCP server processes after isolated heartbeats through existing run cleanup, preserves shared-session reuse, and adds regression and Gateway process-lifetime coverage.

Merge readiness

✅ Ready for maintainer review

The PR remains necessary: current main still lacks isolated-heartbeat retirement wiring. The earlier polling finding is resolved, retained process-lifetime proof remains applicable, and no blocking defect was found.

Priority: P1
Reviewed head: b5e33ef9f141b2934e925ac26659a86ad2784295

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A narrowly scoped lifecycle repair with convincing before/after process observations, a shared-session control, and resolved prior feedback.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Retained terminal traces exercise the built Gateway’s heartbeat dispatcher, real MCP client, and stdio child: fixed isolated runs return to zero children, while shared runs retain one PID. The model response is a fixture, but the changed process lifecycle is real; the unchanged production code preserves this evidence’s applicability.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): Retained terminal traces exercise the built Gateway’s heartbeat dispatcher, real MCP client, and stdio child: fixed isolated runs return to zero children, while shared runs retain one PID. The model response is a fixture, but the changed process lifecycle is real; the unchanged production code preserves this evidence’s applicability.
Evidence reviewed 8 items Current main still needs the wiring: Current main’s heartbeat dispatcher does not set cleanupBundleMcpOnRunEnd, and the reply pipeline has no occurrence of it; embedded settlement still requires the flag to retire the run’s runtime.
Latest supplied release also lacks heartbeat cleanup: The v2026.9.4 source omits the cleanup flag from heartbeat reply options. GitHub identifies this release as published on September 11, 2026; this PR is not an already-shipped fix.
Narrow lifecycle repair: The introduced production hunks enable cleanup only for prepared isolated heartbeats and forward it through both agent candidates. Existing embedded settlement retires original and accepted successor IDs with active-lease preservation; CLI settlement uses the immutable run session ID.
Findings None None.
Security None None.

How this fits together

Heartbeats run scheduled agent turns through OpenClaw’s reply pipeline. Those turns acquire session-scoped MCP tool servers; run settlement must retire servers belonging to disposable sessions while retaining persistent sessions.

flowchart TD
  A[Heartbeat wake] --> B{Isolated session?}
  B -->|Yes| C[Fresh session with cleanup enabled]
  B -->|No| D[Persistent shared session]
  C --> E[Embedded or CLI agent turn]
  D --> E
  E --> F[Run settlement]
  F --> G[Retire isolated MCP runtime]
  F --> H[Retain shared MCP runtime]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +7, Tests +604. Total +611 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 4 7 0 +7
Tests 3 604 0 +604
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 611 0 +611

Review metrics

Metric Value Why it matters
Production versus proof growth Production +7 lines; tests +604 lines Production growth only connects existing lifecycle behavior; most added code provides opt-in process-lifetime proof and regression coverage.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #143381
Summary: This PR is the explicit candidate fix for isolated-heartbeat runtime retention; broader zombie and process-tree reports remain distinct.

Members:

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

Technical review

Best possible solution:

Use the existing settlement lifecycle to retire disposable heartbeat runtimes while preserving persistent-session reuse and active leases.

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

Yes: current source shows fresh heartbeat sessions bypassing opt-in settlement cleanup, and retained Gateway traces demonstrate accumulation versus retirement. This read-only refresh did not execute a new current-main reproduction.

Is this the best way to solve the issue?

Yes: forwarding the existing cleanup flag repairs the lifecycle owner without introducing another reaper or changing shared-session defaults.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 41d443f12318.

Labels

Label justifications:

  • P1: Reports on official releases show repeated isolated heartbeats accumulating MCP processes and substantial memory pressure until restart.
  • 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 (terminal): Retained terminal traces exercise the built Gateway’s heartbeat dispatcher, real MCP client, and stdio child: fixed isolated runs return to zero children, while shared runs retain one PID. The model response is a fixture, but the changed process lifecycle is real; the unchanged production code preserves this evidence’s applicability.
  • proof: sufficient: Contributor real behavior proof is sufficient. Retained terminal traces exercise the built Gateway’s heartbeat dispatcher, real MCP client, and stdio child: fixed isolated runs return to zero children, while shared runs retain one PID. The model response is a fixture, but the changed process lifecycle is real; the unchanged production code preserves this evidence’s applicability.

Evidence

What I checked:

  • Current main still needs the wiring: Current main’s heartbeat dispatcher does not set cleanupBundleMcpOnRunEnd, and the reply pipeline has no occurrence of it; embedded settlement still requires the flag to retire the run’s runtime. (src/infra/heartbeat-runner-run.ts:113, 41d443f12318)
  • Latest supplied release also lacks heartbeat cleanup: The v2026.9.4 source omits the cleanup flag from heartbeat reply options. GitHub identifies this release as published on September 11, 2026; this PR is not an already-shipped fix. (src/infra/heartbeat-runner-run.ts:111, 3a9d69db306c)
  • Narrow lifecycle repair: The introduced production hunks enable cleanup only for prepared isolated heartbeats and forward it through both agent candidates. Existing embedded settlement retires original and accepted successor IDs with active-lease preservation; CLI settlement uses the immutable run session ID. (src/infra/heartbeat-runner-run.ts:101, b5e33ef9f141)
  • Fresh versus persistent session contract: Heartbeat documentation defines isolatedSession as a fresh session per run. Preparation calls resolveCronSession with forceNew: true, while the existing idle reaper is explicitly opt-in; that workaround does not replace settlement-owned cleanup. (src/infra/heartbeat-runner-execution.ts:480, b5e33ef9f141)
  • Retained real process-lifetime proof: The supplied PR body records a built Gateway on Linux with a real stdio MCP child and loopback model fixture, driven through cron.run and observed through cron.runs plus process counts. Three fixed isolated runs peak at one child and return to zero; shared runs retain one PID. The baseline restored the heartbeat runner to the merge-base version and accumulated one child per run. The September 10 follow-up reports isolated/shared reruns using the current harness against the unchanged production build. The complete 536-line harness was inspected, not executed. (test/e2e/qa-lab/runtime/heartbeat-mcp-runtime-retire.product-proof.e2e.test.ts:296, b5e33ef9f141)
  • Earlier review finding resolved: Current lines 274–281 poll observed process state until success or a bounded deadline, retaining the final sample for assertions. Inspection of the earlier reviewed file through GitHub confirmed the former fixed sleeps. The previous completed review covered this same head and reported no remaining findings. (test/e2e/qa-lab/runtime/heartbeat-mcp-runtime-retire.product-proof.e2e.test.ts:274, b5e33ef9f141)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • jalehman: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (6 earlier review cycles)
  • reviewed 2026-09-09T22:23:45.576Z sha f8a06ba :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-09T22:51:34.375Z sha f8a06ba :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-09T23:35:55.976Z sha a293a8d :: needs changes before merge. :: none
  • reviewed 2026-09-10T01:51:19.883Z sha aa1bc7d :: needs changes before merge. :: [P2] Synchronize post-run process samples with retirement
  • reviewed 2026-09-10T06:06:20.469Z sha b5e33ef :: needs maintainer review before merge. :: none
  • reviewed 2026-09-12T19:27:06.743Z sha b5e33ef :: needs maintainer review before merge. :: none

Opt-in qa-lab product proof: a built Gateway with one stdio MCP fixture
server and a forced isolated heartbeat. Counts the fixture child before,
during, and after each run so a post-run zero means retired rather than
never spawned; the main build leaks one child per run, the fixed build
returns to zero, and the shared-session mode keeps one reused child.
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed 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. labels Sep 9, 2026
…served

Review follow-up for the live proof: redact Bearer credentials before the
generic key/value pass so a token cannot survive the scheme word, and gate
each mock model reply on the test having observed the fixture child so the
peak sample cannot race a fast run.
@ylcn91
ylcn91 marked this pull request as ready for review September 9, 2026 23:55
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 9, 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-09-10T00:02:10.686244Z aa1bc7d Draft marked ready
ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aa1bc7daef

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@clawsweeper clawsweeper Bot added 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: 🐚 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 Sep 10, 2026
@ylcn91

ylcn91 commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

Revision 5 (b5e33ef9f14) addresses the remaining proof-harness finding; the PR body Evidence section is updated.

  • The after-run and after-stop samples no longer sleep a fixed 5 s and sample once. They poll pgrep for the variant's expected state with a 30 s bound: isolated fixed build waits for 0 children, the shared control waits for the first run's PID to still be the only child, and the main baseline waits for one child per run. The deadline sample is recorded as-is, so the existing per-stage assertions (retired / same shared PID / one leak per run / reaped at stop) still judge the real state instead of a timeout error.
  • Re-ran both lanes against the aa1bc7daefc build with the new harness: isolated peaks 1/1/1 with 0 after every run, shared PID unchanged through all three runs, 0 after Gateway stop. Retirement was observed within about 60 ms of cron.runs reporting ok, so the poll returns on the first or second sample.
  • tsgo test-root lane, oxlint, and oxfmt are clean on the file. The main baseline lane was not rebuilt for this revision; its expectation (one leaked child per run) is unchanged from the recorded proof-main.json.

@clawsweeper clawsweeper Bot added the rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. label Sep 10, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed 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. labels Sep 10, 2026
@jalehman jalehman self-assigned this Sep 10, 2026
@jalehman

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

Native merge verification requires a completed review less than 12 hours old; the existing review has expired. The PR head is unchanged at b5e33ef9f141b2934e925ac26659a86ad2784295. Renewed CI and Workflow Sanity have passed. Please refresh the review for this head; the retained real-behavior evidence remains applicable.

@clawsweeper

clawsweeper Bot commented Sep 12, 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 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 Sep 12, 2026
@jalehman

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

Please refresh the completed review for the unchanged head b5e33ef. The retained isolated/shared heartbeat behavior proof still applies; this request satisfies the native review-completion age gate, not a request to repeat runtime experiments or perform repair.

@clawsweeper

clawsweeper Bot commented Sep 15, 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:

@jalehman
jalehman merged commit 109972b into openclaw:main Sep 15, 2026
713 of 716 checks passed
@jalehman

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 16, 2026
…es until Gateway restart (openclaw#143433)

* fix(heartbeat): retire isolated heartbeat bundle MCP runtimes on run end

Isolated heartbeats mint a fresh session ID per run, so the bundle MCP
runtime created for that run is never reused, but nothing retired it.
Each heartbeat left its stdio MCP child processes alive until a gateway
restart or an opt-in idle TTL. Carry the existing one-shot
cleanupBundleMcpOnRunEnd flag through the reply pipeline so isolated
heartbeat runs retire their exact runtime at settlement, like isolated
cron runs already do. Shared heartbeats keep their persistent runtime.

Fixes openclaw#143381

* test(e2e): prove isolated heartbeat MCP retirement on a built Gateway

Opt-in qa-lab product proof: a built Gateway with one stdio MCP fixture
server and a forced isolated heartbeat. Counts the fixture child before,
during, and after each run so a post-run zero means retired rather than
never spawned; the main build leaks one child per run, the fixed build
returns to zero, and the shared-session mode keeps one reused child.

* test(e2e): hold the fixture reply until the heartbeat MCP child is observed

Review follow-up for the live proof: redact Bearer credentials before the
generic key/value pass so a token cannot survive the scheme word, and gate
each mock model reply on the test having observed the fixture child so the
peak sample cannot race a fast run.

* test(e2e): redact bearer credentials case-insensitively in the heartbeat proof

* test(e2e): poll for heartbeat MCP child retirement instead of a fixed settle delay
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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 runs never retire their bundle MCP runtime (ephemeral runtimes treated as persistent)

2 participants