Skip to content

fix: avoid extra heartbeat messages after visible child execs - #147432

Merged
obviyus merged 5 commits into
openclaw:mainfrom
Tosko4:fix/visible-subagent-exec-notifications
Oct 2, 2026
Merged

obviyus merged 5 commits into
openclaw:mainfrom
Tosko4:fix/visible-subagent-exec-notifications

Conversation

@Tosko4

@Tosko4 Tosko4 commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Closes #147326

What problem this solves

A visible child uses a dashboard session key. Its background exec completion therefore bypassed the hidden-subagent key guard and could send a second heartbeat notification to the parent's chat after the child's result announcement.

Fix

Retains Tosko4's persisted-envelope classification (spawnedBy / spawnDepth) through exec settlement. Results remain available to process polling, and ordinary background commands still notify. Classification uses the existing read-only session worker only when background notifications are possible; execution authority is rechecked after the await.

The review follow-up makes this optional identity lookup fail open for notification routing, not command execution: a rejected lookup falls back to the previous key-based behavior, clears the cached promise, and permits the next command to retry classification. A transient worker failure cannot prevent the command from starting or poison the tool instance.

No config, schema, migration, permission, or heartbeat schedule change. Thanks to @Tosko4 for the report and original fix. No overlap with Pash/Sarah changes.

Evidence

Candidate: f27ff343d9618a4f696287e68ebaa7267a312da3. Integrated main at fc17c21ad7d4039bcee593552eb83b86b1ea2cb2 only to resolve actual conflicts, preserving contributor commits.

  • Telegram Test Server, built Gateway, real user/bot transport: the parent calls sessions_spawn with visible: true, the dashboard child starts real sleep 20; exit 1 in the background and returns its launch result, and the parent announces it. The process remains unpolled and finishes after the child announcement. The model choreography is deterministic; spawn, persistence, subprocess, heartbeat scheduling, and Telegram delivery are real.
    • Base: child announcement at 6.093 s, then an extra process heartbeat at 25.041 s.
    • Candidate: child announcement at 5.978 s, no process heartbeat during the 75-second recording.
    • Both runs also show the same pre-completion “I'm continuing this work…” status; the temporary “Working” message is deleted. The comparison concerns the extra completion notification, not those existing status messages.
    • Direct non-child control on the candidate: background launch at 4.139 s, process heartbeat at 24.279 s.
  • Failure-injection regression through real exec/process tools: rejects on the pre-fix contributor implementation before the command starts; passes after. The first command starts and notifies despite the failed worker; a second command on the same tool instance sees recovered persisted child identity and suppresses the wake. This detects cached failure and cached fallback regressions.
    • With the candidate's exec-only session lookup fault-injected to reject: the real command still starts, the child announcement arrives at 6.055 s, and notification falls back to a process heartbeat at 24.711 s. The injected lookup rejection is recorded independently; no model or transport response manufactures the failure.
  • Focused tests: 12/12 across background follow-up and visible-child notification tests; 34/34 across exec runtime and source authority. The main-source visible-child regression fails in both visible-child cases while all four ordinary/hidden/navigation controls pass. P1 case: 44 ms; two-file notification run: 15.60 s Vitest / 29.86 s wrapper. Adjacent runtime/authority run: 10.83 s / 12.51 s.
  • Both isolated full builds passed: base 448.78 s, candidate 357.92 s.
  • Real-provider live gate: the exact built candidate used gpt-5-mini through a forward-only proxy and delivered P147326_LIVE_OK to the leased Telegram Test Server DM at 7.003 s. One request reached OpenAI and returned HTTP 200; one auxiliary request for a different model was rejected locally without forwarding. The proxy enforced a six-attempt cap. No synthetic provider response was used for this gate. Lease, key file, Gateway, and live container were removed after each run.

Known local baseline failures

bash-tools.exec-host-gateway.test.ts has the same 3 failed / 37 passed on the candidate and the reverted notification-production baseline:

  1. Mixed allowlist authorization resolves a denied result instead of the expected revoked-trust rejection.
  2. Shell-wrapper approval decisions omit allow-always.
  3. Durable exact-command trust unexpectedly enters the approval route.

These are allowlist planning/trust cases. This PR only relocates an unchanged notification-output import in that gateway owner; the classification catch is outside processGatewayAllowlist. Candidate and baseline timings are 33.11 s and 33.35 s respectively. These are local baseline-equivalence results, not a claim that hosted CI is green.

@clawsweeper

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

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M labels Sep 13, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 2, 2026, 10:05 AM ET / 14:05 UTC (Revision 6).

ClawSweeper review

What this changes

The PR identifies visible child sessions before launching background commands, suppresses their extra completion heartbeats, and preserves command execution when the optional identity lookup fails.

Merge readiness

✅ Ready for maintainer review

This remains a useful, distinct fix that current main and the latest release do not implement. The prior lookup-failure finding and runtime-proof gap are resolved; no actionable introduced defect remains.

Priority: P2
Reviewed head: f27ff343d9618a4f696287e68ebaa7267a312da3

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with relevant real-transport comparisons, recovery controls, and no remaining actionable findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The captured exact-head evidence exercises visible spawning, persisted identity, real background execution, heartbeat scheduling, and Telegram Test Server delivery: the base emits an extra completion heartbeat while the candidate does not, and ordinary-session and injected-lookup-failure controls still notify. Polling and same-instance recovery have supplemental regression coverage. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured exact-head evidence exercises visible spawning, persisted identity, real background execution, heartbeat scheduling, and Telegram Test Server delivery: the base emits an extra completion heartbeat while the candidate does not, and ordinary-session and injected-lookup-failure controls still notify. Polling and same-instance recovery have supplemental regression coverage. No stored-data contract changes.
Evidence reviewed 10 items Pinned introduced change: Reviewed the verified merge-base-to-head delta. The supplied test merge is stale and was not used to infer removal of current-main behavior. Repository origin identifies openclaw/openclaw, and the checkout remained clean.
Prior availability finding resolved: The optional lookup now catches rejection, clears its cached promise, and returns the existing key-based classification. The caller skips this lookup when notifications or background continuation are disabled and rechecks source authority after awaiting it.
Notification ownership and polling preserved: Completion events and their removal receipts are retained before the new child guard suppresses only the heartbeat request. Existing terminal-poll acknowledgement and manual-cancellation conditions remain intact. The worker return API supplies descriptive data, not retained execution authority; existing final-spawn authorization checks remain in place.
Findings None None.
Security None None.

How this fits together

OpenClaw’s exec tool launches commands and retains background results for process polling. Its completion notifications can also request a heartbeat turn, while child sessions already report through their separate announcement flow.

flowchart TD
  A[Agent command] --> B[Exec preparation]
  C[Saved child session identity] --> B
  B --> D[Background process]
  D --> E[Retained completion result]
  E --> F[Process polling]
  E --> G{Child session?}
  G -->|Yes| H[Existing child announcement flow]
  G -->|No| I[Completion heartbeat]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +60, Tests +245. Total +305 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 5 102 42 +60
Tests 4 247 2 +245
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 349 44 +305

Review metrics

Metric Value Why it matters
Production versus regression growth production +60 net lines; tests +244; test routing +1 Production growth retains worker-resolved child identity across process settlement, with regression coverage for notification ownership and lookup recovery.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #147326
Summary: This PR is the candidate fix for the paired visible-child ownership issue; related acknowledgement, cancellation, and cron-routing work addresses distinct triggers.

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 persisted child classifier to keep child completions with polling and announcements while retaining ordinary-session notifications and resilient command startup.

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

Yes: a visible dashboard child can start an unpolled background command that exits after its announcement; current main’s key-only guard still requests the extra wake. Source establishes the path, and the PR records a real Telegram base/candidate comparison; this review did not execute it.

Is this the best way to solve the issue?

Yes: extending the existing child-ownership classification at exec startup is narrower than disabling notifications broadly or changing heartbeat scheduling, and the failure fallback preserves existing execution behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The captured exact-head evidence exercises visible spawning, persisted identity, real background execution, heartbeat scheduling, and Telegram Test Server delivery: the base emits an extra completion heartbeat while the candidate does not, and ordinary-session and injected-lookup-failure controls still notify. Polling and same-instance recovery have supplemental regression coverage. No stored-data contract changes.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured exact-head evidence exercises visible spawning, persisted identity, real background execution, heartbeat scheduling, and Telegram Test Server delivery: the base emits an extra completion heartbeat while the candidate does not, and ordinary-session and injected-lookup-failure controls still notify. Polling and same-instance recovery have supplemental regression coverage. No stored-data contract changes.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 availability: Current PR review selected no merge-risk labels.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This repairs unwanted completion turns and chat notifications for visible children without changing general command execution or heartbeat cadence.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured exact-head evidence exercises visible spawning, persisted identity, real background execution, heartbeat scheduling, and Telegram Test Server delivery: the base emits an extra completion heartbeat while the candidate does not, and ordinary-session and injected-lookup-failure controls still notify. Polling and same-instance recovery have supplemental regression coverage. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured exact-head evidence exercises visible spawning, persisted identity, real background execution, heartbeat scheduling, and Telegram Test Server delivery: the base emits an extra completion heartbeat while the candidate does not, and ordinary-session and injected-lookup-failure controls still notify. Polling and same-instance recovery have supplemental regression coverage. No stored-data contract changes.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. The fix removes an observable extra Telegram completion notification, and the recorded Test Server comparison exercises that behavior.

Evidence

What I checked:

  • Pinned introduced change: Reviewed the verified merge-base-to-head delta. The supplied test merge is stale and was not used to infer removal of current-main behavior. Repository origin identifies openclaw/openclaw, and the checkout remained clean. (f27ff343d961)
  • Prior availability finding resolved: The optional lookup now catches rejection, clears its cached promise, and returns the existing key-based classification. The caller skips this lookup when notifications or background continuation are disabled and rechecks source authority after awaiting it. (src/agents/bash-tools.exec-request-preparation.ts:228, f27ff343d961)
  • Notification ownership and polling preserved: Completion events and their removal receipts are retained before the new child guard suppresses only the heartbeat request. Existing terminal-poll acknowledgement and manual-cancellation conditions remain intact. The worker return API supplies descriptive data, not retained execution authority; existing final-spawn authorization checks remain in place. (src/agents/bash-tools.exec-runtime.ts:306, f27ff343d961)
  • Current main still needs the fix: Fetched main still suppresses background completion wakes only for keys recognized by isSubagentSessionKey; it does not carry persisted dashboard-child identity into this decision. (src/agents/bash-tools.exec-runtime.ts, a1903fca5bdb)
  • Latest release still has the ownership gap: The latest supplied release, v2026.9.7, also uses the key-only wake guard. No merged fixing PR connected to this visible-child behavior is established. (src/agents/bash-tools.exec-runtime.ts, c074824a27c9)
  • Recorded real behavior proof: The captured PR body identifies exact candidate f27ff34 and reports a built Gateway with real Telegram Test Server user/bot transport: visible-child announcement followed by an extra heartbeat at 25.041 seconds on base, versus no completion heartbeat during 75 seconds on the candidate. The ordinary-session control still notified at 24.279 seconds. Injected lookup rejection still allowed command launch and the prior notification fallback at 24.711 seconds. These observations exercise the changed exec owner; the separate real-provider marker is supplemental. Assessment uses the supplied snapshot with sourceRevision 050637c391ac04303e8d36333e4c066f2dc941b53fb984ee0340f4cb4f836e9d, without claiming a reviewer rerun or inspection of an unavailable recording. (f27ff343d961)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • VACInc: 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 (5 earlier review cycles)
  • reviewed 2026-09-13T21:27:43.868Z sha ec5c9a3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-13T21:46:44.778Z sha ec5c9a3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-24T01:55:12.733Z sha ec5c9a3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-28T08:36:48.163Z sha e45651a :: needs real behavior proof before merge. :: [P2] Skip the session-worker read when exit notification cannot occur
  • reviewed 2026-09-28T10:35:40.289Z sha 8b025b7 :: needs real behavior proof before merge. :: [P1] Keep dashboard exec running when the notification lookup fails

@VACInc

VACInc commented Sep 21, 2026

Copy link
Copy Markdown
Member

Related but not superseded: #153795 (23462b4) suppresses completion events for explicitly canceled background commands, except cleanup failures. It does not implement the persisted visible-child ownership guard proposed here, and ordinary non-canceled child completions are unaffected. This PR and #147326 remain separate from the landed cancellation fix.

@Tosko4

Tosko4 commented Sep 28, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 28, 2026
Tosko4 and others added 3 commits September 28, 2026 12:26
# Conflicts:
#	src/agents/bash-tools.exec-host-gateway.test.ts
#	src/agents/bash-tools.exec-run.ts
#	test/vitest/vitest.database-worker-core-paths.mjs
@obviyus

obviyus commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper review

Updated head f27ff34 preserves the contributor commits, resolves the main conflicts, and fixes the rejecting/cached session-worker lookup. The PR body now records real Telegram base/candidate proof, the direct-background and lookup-failure controls, and the exact-head gpt-5-mini live gate. Please review this head.

@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 2, 2026
@clawsweeper clawsweeper Bot added the status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. label Oct 2, 2026
@obviyus

obviyus commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

Maintainer override on head f27ff343d9618a4f696287e68ebaa7267a312da3. ClawSweeper's exact-head review (revision 6) is ready.

Red CI (run 37016491922) comes from main:

  • The jobs: checks-node-compact-small-6 (pr-wrapper-source-closure.test.ts) and checks-node-compact-small-7 (eager-import-closure.test.ts). They check the PR wrapper inventory against runtime imports.
  • Where they fail: CI tested the synthetic merge onto main fa95e3c78e70. Running both files on that exact main commit reproduces all three failures and the same five missing inventory entries.
  • The cause: main's fix(sessions): retain Doctor repair for July provider aliases #163171 (f1be74485a89), which added new supported-session-store imports. This exec-notification diff isn't involved.
  • This PR: both files pass 20/20 on this head and on its merge base fc17c21ad7d4.

Proof: the real Telegram Test Server.

  • main: a visible child's background exec produced its announcement (6.1 s) plus an extra heartbeat message (25.0 s).
  • This head: only the announcement (6.0 s), with no extra heartbeat over 75 s.
  • Controls: a direct background exec still notifies.
  • Review fix: with the session-worker lookup failing, the exec still starts and notification falls back. The failure is no longer cached.
  • Live check on this head: a real gpt-5-mini turn through Telegram.

@obviyus
obviyus merged commit 93cdd44 into openclaw:main Oct 2, 2026
155 of 162 checks passed
@obviyus

obviyus commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

CI failure attribution

The two tooling failures are inherited from the newer main used by CI, not caused by this PR's notification imports.

Same command in secretless Docker, Node 24.16.0, unchanged frozen-lockfile dependencies:

node scripts/run-vitest.mjs test/scripts/pr-wrapper-source-closure.test.ts test/scripts/eager-import-closure.test.ts
Source Result Vitest / wrapper wall
PR head f27ff343d9618a4f696287e68ebaa7267a312da3 20 passed 35.90s / 36.95s
Merge base fc17c21ad7d4039bcee593552eb83b86b1ea2cb2 20 passed 35.77s / 36.55s
CI's main parent fa95e3c78e701de57203ea8830e5ca6a1a1e5805 3 failed, 17 passed 37.15s / 37.95s

The small-6 checkout log identifies the tested source as 0a24cc1326c938d0c3c2aa83cd565caaa509fc46, merging this PR into fa95e3c78e701de57203ea8830e5ca6a1a1e5805.

On that exact main parent, the relative-ESM wrapper test fails for sqlite-readonly-location.worker.ts; the eager closure test fails for both inventory closure and extracted package-export resolution, matching small-7.

The identical missing entries are:

src/config/sessions/supported-session-store.ts
src/plugin-sdk/channel-route.ts
src/utils/delivery-context.shared.ts
src/utils/message-channel-constants.ts
src/utils/message-channel-core.ts

Main commit f1be74485a89e8bf36055cf7cffd6ff2439da50d (#163171) added the supported-session-store runtime imports in session-entry normalization after this PR's merge base. This PR changes neither those normalizers nor the wrapper inventory, and the failures reproduce without any PR changes. No inventory edit, CI rerun, or repush performed.

CI run completed with these two failing tooling jobs and their aggregate openclaw/ci-gate; 0 cancelled jobs in the CI run. Earlier cancelled administrative workflows are not selected test cancellations.

@obviyus

obviyus commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

Landed as 93cdd44. Thanks @Tosko4, for both the report and the fix!

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 3, 2026
…aw#147432)

* fix: avoid extra heartbeat messages after visible child execs

* fix(agents): skip child session lookup when exec cannot notify

* fix(agents): fall back when exec child identity lookup fails

---------

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

Labels

agents Agent runtime and tooling P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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]: visible subagent exec completions trigger extra heartbeat notifications

3 participants