Skip to content

fix: deliver watcher results while other sessions are busy - #152287

Merged
steipete merged 1 commit into
mainfrom
codex/watcher-failure-wake
Sep 19, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/watcher-failure-wake

Conversation

@steipete

@steipete steipete commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes background watcher results remaining unread when unrelated sessions or automations keep a shared agent busy. A failed CI watcher could exit after the agent's final reply without the agent receiving its error.

User Impact

Successful and failed background commands can resume their originating idle session. An active destination session, pending delivery, and recovery still retain their ordering protections. Existing credential expiry and permission checks remain in force.

Why This Change Was Made

Pure targeted exec completions no longer use the broad busy checks intended for ambient heartbeat work. Scheduled work coalesced with a completion keeps its existing guards.

Evidence

  • Reproduced six unrelated-work deferrals before the fix. The expanded regression matrix also preserves all three same-session busy controls.
  • All 87 focused tests passed, covering completion emission, routing, chat publication, stale events, recovery, and busy-session behavior.
  • Live isolated Gateway and real OpenAI model: both cases passed in 68.89 seconds. A background watcher exited with code 7 after its foreground turn ended; the model reported its fresh output marker and exit code in the original dashboard session while another session for the same agent remained blocked. Normal background completion and main-session monitor routing also passed.
  • Full build and changed-file repository checks passed. The final live fixture also passed focused typechecking and lint.
  • Independent review completed with no accepted actionable findings.
  • Exact-head CI run 35408121071 passed, including the required openclaw/ci-gate. ClawSweeper also found no actionable defects.

Resume targeted background command completions without waiting for unrelated sessions or automation work. Preserve the destination session ordering and recovery guards, scheduled heartbeat policy, and credential expiry. Prove failed watcher notification with a real model while a sibling session remains active.
@clawsweeper

clawsweeper Bot commented Sep 19, 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 September 19, 2026 00:05
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: L maintainer Maintainer-authored PR labels Sep 19, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 19, 2026
@clawsweeper

clawsweeper Bot commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 18, 2026, 8:11 PM ET / September 19, 2026, 00:11 UTC.

ClawSweeper review

What this changes

Allows background command results to resume their idle originating session while unrelated sessions or automations are busy, with regression coverage and documentation.

Merge readiness

✅ Ready for maintainer review

The fix remains necessary: current main and the latest release still defer targeted completions behind unrelated work. No actionable introduced defect was found; destination-session ordering and scheduled-work guards remain intact.

Priority: P2
Reviewed head: 43000e45a216ca031c0c4a019662d239356c64cc

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused admission fix with meaningful regression coverage and reported live validation; no blocking defect was found.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied repository state identifies maintainer authorship, so ordinary contributor proof is exempt. The body nevertheless reports the relevant live Gateway/model result, and the inspected fixture exercises completion admission while a sibling remains blocked; no authority change introduces an additional proof gate.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied repository state identifies maintainer authorship, so ordinary contributor proof is exempt. The body nevertheless reports the relevant live Gateway/model result, and the inspected fixture exercises completion admission while a sibling remains blocked; no authority change introduces an additional proof gate.
Evidence reviewed 7 items Verified introduced production change: The pinned merge-base-to-head diff adds a narrowly classified completion exception to three broad busy checks. It does not alter session selection, delivery authorization, persistence, dependencies, or plugin APIs.
Current-main necessity: Fetched main still unconditionally checks the main and automation queues, and applies the same-agent active-run check to event wakes. The proposed exception is absent.
Latest-release comparison: The v2026.9.4 source also contains the broad busy guards without this completion exception. GitHub content inspection supplied the release source after the local historical blob was unavailable.
Findings None None.
Security None None.

How this fits together

Background commands enqueue completion events for their originating conversation. The Gateway’s heartbeat runner admits these follow-up turns and sends their results through the existing reply and delivery pipeline.

flowchart TD
  A[Background command exits] --> B[Originating session event queue]
  B --> C{Completion without scheduled work?}
  C -->|Yes| D[Check destination session and recovery]
  C -->|No| E[Also check shared busy guards]
  E --> D
  D -->|Busy| F[Retain event and retry]
  D -->|Idle| G[Run follow-up and deliver result]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +9, Tests +176, Docs +2. Total +187 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 1 12 3 +9
Tests 2 363 187 +176
Docs 2 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 377 190 +187

Review metrics

Metric Value Why it matters
Busy-condition coverage 7 unrelated-work cases; 3 destination-session guards The regression matrix distinguishes newly permitted completion turns from work that must remain deferred.

Technical review

Best possible solution:

Keep completion admission with the existing heartbeat runner, bypass unrelated load checks, and preserve destination-session ordering and scheduled-work policy.

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

Yes, source establishes the path: enqueue a targeted command completion while unrelated main, automation, or same-agent work is active; current main defers it. The PR reports a matching live reproduction, but this review did not execute tests.

Is this the best way to solve the issue?

Yes. The exception repairs the existing admission owner without adding another delivery path, and retains exact-session and coalesced-schedule protections.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: Repairs delayed background-command follow-ups in busy multi-session setups without changing public configuration or APIs.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied repository state identifies maintainer authorship, so ordinary contributor proof is exempt. The body nevertheless reports the relevant live Gateway/model result, and the inspected fixture exercises completion admission while a sibling remains blocked; no authority change introduces an additional proof gate.

Label justifications:

  • P2: Repairs delayed background-command follow-ups in busy multi-session setups without changing public configuration or APIs.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied repository state identifies maintainer authorship, so ordinary contributor proof is exempt. The body nevertheless reports the relevant live Gateway/model result, and the inspected fixture exercises completion admission while a sibling remains blocked; no authority change introduces an additional proof gate.

Evidence

What I checked:

  • Verified introduced production change: The pinned merge-base-to-head diff adds a narrowly classified completion exception to three broad busy checks. It does not alter session selection, delivery authorization, persistence, dependencies, or plugin APIs. (src/infra/heartbeat-runner-execution.ts:193, 43000e45a216)
  • Current-main necessity: Fetched main still unconditionally checks the main and automation queues, and applies the same-agent active-run check to event wakes. The proposed exception is absent. (src/infra/heartbeat-runner-execution.ts:192, c9584688c461)
  • Latest-release comparison: The v2026.9.4 source also contains the broad busy guards without this completion exception. GitHub content inspection supplied the release source after the local historical blob was unavailable. (src/infra/heartbeat-runner-execution.ts, 3a9d69db306c)
  • Ordering and coalescing remain protected: Recovery and pending-final-delivery checks remain before admission, followed by exact-session reply, embedded-run, and queue checks. Preflight and wake coalescing preserve scheduled cadence and task metadata, preventing the new exception from bypassing scheduled-work guards. (src/infra/heartbeat-runner-execution.ts:247, 43000e45a216)
  • Behavioral regression coverage: The added matrix covers seven unrelated-work conditions and three destination-session busy conditions, checking both prompt delivery and event retention or consumption. The live fixture uses actual Gateway chat requests, a real model, and gated child processes to verify a code-7 completion before releasing the sibling session. (src/infra/heartbeat-runner.live.test.ts:79, 43000e45a216)
  • Captured validation report and runtime boundary: The supplied PR body reports six pre-fix deferrals, 87 passing focused tests, and two live Gateway/OpenAI cases passing in 68.89 seconds, including the original-session failure marker and exit code while a sibling remained blocked. The fixture explicitly selects the OpenClaw runtime; no Codex dependency contract is implicated. These reported runs were not independently executed during this read-only review. (src/infra/heartbeat-runner.live.test.ts:97, 43000e45a216)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • steipete: 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.

@steipete
steipete merged commit 29fa603 into main Sep 19, 2026
288 checks passed
@steipete
steipete deleted the codex/watcher-failure-wake branch September 19, 2026 00:34
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 19, 2026
* commit 'ca69b4d25dfcd488acc6ba1d878e4b4252f40cd2': (325 commits)
  perf(gateway): streamline config reload comparison (#152279)
  fix(xai): reject invalid UTF-8 OAuth responses (#111737)
  fix(release): accept waived advisory performance evidence for stable publication (#152290)
  fix: deliver watcher results while other sessions are busy (#152287)
  perf(media): reuse attachment filename classification (#152274)
  refactor(build): reuse forwarded option scanning (#152293)
  chore(diagnostics-otel): revert unapproved duration-bucket merge (#152292)
  fix: stop chat media reads after access changes (#152219)
  fix(test): use Gateway WebSocket transport in network fixtures (#152143)
  improve: retain quota refresh evidence from successful CI runs (#152173)
  improve(gateway): reduce memory used by session selection (#152260)
  perf(agents): use keyed subagent capability lookups (#152263)
  refactor(matrix): centralize media metadata assembly (#149128)
  chore(ui): refresh control ui locales (#152276)
  feat: open Crabbox apps beside the conversation (#152094)
  refactor: simplify worker and model fallback handling (#152268)
  perf(codex): reconcile session catalogs incrementally (#152257)
  fix(ui): keep submitted prompts visible across session startup (#152241)
  perf(sessions): move automatic maintenance database work to workers (#148630)
  fix: preserve reply metadata through outbound preparation (#152231)
  ...
vincentkoc added a commit that referenced this pull request Sep 19, 2026
* commit '912b21b98581c0be3baad87fe3686b64d69fffeb': (191 commits)
  perf(process): reduce allocation while processing command output (#152261)
  fix(ui): collapse duplicate previews when a page opens in multiple tabs (#152281)
  fix(test): run local Gateway tests behind protected exec egress (#152318)
  fix(node-host): avoid blocking configuration reads (#151411)
  fix(qa-lab): prevent Evidence Archive filters from overflowing (#152123)
  test: stabilize Docker scheduler signal fixtures on macOS (#152301)
  fix(ui): close stuck submenus when moving between menu rows (#152317)
  fix(ui): preserve question drafts and pending submissions (#152096)
  fix(release): recognize 7.34 fs-safe contract (#152326)
  chore: retire CLAUDE.md files
  fix(ui): release queued input after completed chat runs (#152299)
  improve(tooling): reduce commit formatting resource use (#152297)
  feat: show mentioned sessions in Involving me (#152083)
  perf(tasks): reuse prepared audit summaries (#152294)
  fix(daemon): preserve LaunchAgent rollback bytes and modes (#152195)
  fix: stop chat layout changes from loading extra history (#151726)
  perf(gateway): streamline config reload comparison (#152279)
  fix(xai): reject invalid UTF-8 OAuth responses (#111737)
  fix(release): accept waived advisory performance evidence for stable publication (#152290)
  fix: deliver watcher results while other sessions are busy (#152287)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 19, 2026
…152287)

Resume targeted background command completions without waiting for unrelated sessions or automation work. Preserve the destination session ordering and recovery guards, scheduled heartbeat policy, and credential expiry. Prove failed watcher notification with a real model while a sibling session remains active.
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 maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary 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.

1 participant