Skip to content

fix(worker): stop preparing disabled live previews - #146896

Merged
vincentkoc merged 1 commit into
mainfrom
perf/worker-preview-preparation-20260913
Sep 13, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
perf/worker-preview-preparation-20260913

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes an issue where cloud workers keep scanning assistant snapshots and redacting tool diagnostics after live preview delivery has stopped, spending work on previews that will never reach the user.

Why This Change Was Made

Stop preview preparation at the worker event subscriber once the live client declines an enqueue. Keep the existing enqueue guard for an event that disables delivery partway through processing. Terminal events still record the final outcome and are emitted only after the authoritative transcript flush; cancellation and cleanup-failure precedence stay unchanged.

User Impact

Cloud workers avoid unnecessary preview work after a preview queue degrades. Final results and errors retain their durable delivery path. No configuration change is required.

Evidence

  • Regression against the original runtime: one declined enqueue was followed by three unused tool-payload reads and eight assistant-content reads. The repaired runtime performs zero of either, with the same single enqueue attempt.
  • All eight focused tests pass, including tool-media redaction, deferred success/error/cancellation, cleanup failure after success, and cleanup failure after cancellation. A clean Linux source-bound run also passed these eight tests plus four worker integration cases at 4d4fb99d477e58155b2930118127337590e27be1.
  • Targeted formatting and git diff --check pass. Production change: five added lines (three-line admission guard and its ownership comment); tests: +132/-14.
  • On a clean Linux Testbox, all eight live-runtime tests and four worker integration tests pass: full remote inference/live-event/transcript flow, authoritative terminal delivery after preview loss, repeated no-progress resync, and unacknowledged failed-turn terminal handling. The exact source commit and both changed-file hashes were verified before and after the run.
  • Independent source review and the required P2 autoreview are clear. This establishes eliminated work at the subscriber boundary, not an end-to-end Team latency improvement. Hosted checks remain pending.

@vincentkoc vincentkoc self-assigned this Sep 13, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review September 13, 2026 09:08
@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 size: S maintainer Maintainer-authored PR labels Sep 13, 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 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 5:43 AM ET / 09:43 UTC.

ClawSweeper review

What this changes

Stops cloud workers from preparing assistant and tool previews after preview delivery is disabled, while preserving final outcome delivery.

Merge readiness

✅ Ready for maintainer review

Keep open: the optimization remains absent from current main and the latest release. The patch preserves terminal delivery, and no actionable correctness or security findings were identified.

Priority: P2
Reviewed head: 425af239d3678a7855fba178fdbc51e7128dbbab

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused fix with meaningful regression coverage and preserved completion semantics; no blocking patch findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate. Its reported Linux regression and worker integration runs address preview shutdown and terminal ordering; no independent live trace or end-to-end latency result is claimed here.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate. Its reported Linux regression and worker integration runs address preview shutdown and terminal ordering; no independent live trace or end-to-end latency result is claimed here.
Evidence reviewed 9 items Introduced production change: The pinned base-to-head diff adds only the subscriber guard and its ownership comment. agent_end remains admitted after previews are disabled; the existing enqueue guard remains intact.
Current-main necessity: Current main still reads assistant snapshots and redacts tool payloads before the enqueue-level guard discards their events. Its complete runtime source lacks the proposed early return.
Latest-release comparison: The supplied latest release, v2026.9.4, contains runtime blob 89e7e5525fd60ecc8770c967096e7dbad11227ef, identical to the inspected main version without this optimization.
Findings None None.
Security None None.

How this fits together

Cloud workers send progress previews and authoritative transcripts back to the Gateway. This event subscriber prepares previews and records the final outcome, which is delivered after transcript settlement.

flowchart TD
  A[Agent session events] --> B{Final outcome event?}
  B -->|No| C{Previews enabled?}
  C -->|Yes| D[Prepare and enqueue preview]
  C -->|No| E[Skip preview work]
  D -->|Enqueue declined| E
  B -->|Yes| F[Record final outcome]
  F --> G[Wait for transcript settlement]
  G --> H[Deliver terminal event]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +5, Tests +118. Total +123 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 5 0 +5
Tests 1 132 14 +118
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 137 14 +123

Review metrics

None.

Technical review

Best possible solution:

Keep preview preparation behind the existing delivery state while retaining independent terminal collection and transcript-before-terminal ordering.

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

Yes, from source: decline one preview enqueue, then send assistant or tool events; current main still prepares their discarded payloads. Tests were inspected but not executed during this read-only review.

Is this the best way to solve the issue?

Yes. The subscriber guard uses the existing permanent preview-disable state and leaves the authoritative completion path intact, without adding another owner or configuration option.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This is a bounded worker performance fix for wasted processing after preview delivery degrades, without demonstrated urgent user-facing failure.
  • 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 MEMBER-authored PR is exempt from the external-contributor proof gate. Its reported Linux regression and worker integration runs address preview shutdown and terminal ordering; no independent live trace or end-to-end latency result is claimed here.

Label justifications:

  • P2: This is a bounded worker performance fix for wasted processing after preview delivery degrades, without demonstrated urgent user-facing failure.
  • 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 MEMBER-authored PR is exempt from the external-contributor proof gate. Its reported Linux regression and worker integration runs address preview shutdown and terminal ordering; no independent live trace or end-to-end latency result is claimed here.

Evidence

What I checked:

  • Introduced production change: The pinned base-to-head diff adds only the subscriber guard and its ownership comment. agent_end remains admitted after previews are disabled; the existing enqueue guard remains intact. (src/worker/embedded-agent-live.runtime.ts:223, 425af239d367)
  • Current-main necessity: Current main still reads assistant snapshots and redacts tool payloads before the enqueue-level guard discards their events. Its complete runtime source lacks the proposed early return. (src/worker/embedded-agent-live.runtime.ts:222, 4de88fde4de2)
  • Latest-release comparison: The supplied latest release, v2026.9.4, contains runtime blob 89e7e5525fd60ecc8770c967096e7dbad11227ef, identical to the inspected main version without this optimization. (src/worker/embedded-agent-live.runtime.ts, 3a9d69db306c)
  • Preview shutdown contract: The live client permanently rejects further previews after degradation, disposal, or terminal connection state. Terminal delivery has a separate completion-bearing path, so the subscriber does not need subsequent preview bookkeeping. (src/worker/worker-rpc-live-event-client.ts:55, 425af239d367)
  • Production caller and durability ordering: The embedded turn subscribes this runtime to session events, records run and computer-cleanup failures separately, and calls emitTerminal only after successful transcript settlement. None of those paths changes. (src/worker/embedded-agent.runtime.ts:376, 425af239d367)
  • Regression coverage and reported validation: The complete changed tests check zero payload/content reads after a declined enqueue and five terminal outcome combinations, including cleanup failure after cancellation. The captured PR body reports eight focused and four integration cases passing on Linux, including a source-bound run at 4d4fb99d477e58155b2930118127337590e27be1; these are contributor-reported results, not executions performed during this read-only review. The reviewed diff passes git diff --check. (src/worker/embedded-agent-live.runtime.test.ts:48, 425af239d367)

Likely related people:

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

@vincentkoc
vincentkoc merged commit 485c2cc into main Sep 13, 2026
247 of 257 checks passed
@vincentkoc
vincentkoc deleted the perf/worker-preview-preparation-20260913 branch September 13, 2026 10:35
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 13, 2026
* refs/heads/temp/pr-146883: (159 commits)
  fix: retain route ownership while discovering conversations (#146927)
  refactor: reuse plugin fixture shell runner (#146920)
  fix(worker): stop preparing disabled live previews (#146896)
  fix(runtime): support Bun across tooling suite (#146807)
  chore(i18n): refresh native locales (#146924)
  perf(secrets): limit expiry metadata to transient credentials (#146882)
  fix(ui): preserve queued refreshes during session discovery (#146535)
  test(ui): wait for quiet scrolling and close named file tabs (#146836)
  fix(ui): prevent Usage hour filters from freezing during DST (#146919)
  test(ui): share browser page cleanup across layout fixtures (#146805)
  ci: balance complete PR runtime test groups (#146916)
  improve(infra): reduce scheduling work for session notice bursts (#146818)
  improve: prepare Gateway skill commands asynchronously (#146812)
  improve(agents): skip unused assistant delivery parsing (#146858)
  improve(ui): reuse date formatters across timestamp lists (#146789)
  fix(tests): isolate installer and Docker shell snippets (#146897)
  test(heartbeat): share explicit channel configuration fixtures (#146853)
  fix: retain conversation reply claims through write admission (#146866)
  perf(sessions): bound history reads and stabilize cursor paging (#146770)
  fix(ui): let slow dashboard downloads finish before recovery (#146881)
  ...
vincentkoc added a commit that referenced this pull request Sep 13, 2026
* refs/heads/temp/pr-146833: (43 commits)
  fix(memory): preserve newer indexes and disclose automatic rebuild costs (#146908)
  fix: retain route ownership while discovering conversations (#146927)
  refactor: reuse plugin fixture shell runner (#146920)
  fix(worker): stop preparing disabled live previews (#146896)
  fix(runtime): support Bun across tooling suite (#146807)
  chore(i18n): refresh native locales (#146924)
  perf(secrets): limit expiry metadata to transient credentials (#146882)
  fix(ui): preserve queued refreshes during session discovery (#146535)
  test(ui): wait for quiet scrolling and close named file tabs (#146836)
  fix(ui): prevent Usage hour filters from freezing during DST (#146919)
  test(ui): share browser page cleanup across layout fixtures (#146805)
  ci: balance complete PR runtime test groups (#146916)
  improve(infra): reduce scheduling work for session notice bursts (#146818)
  improve: prepare Gateway skill commands asynchronously (#146812)
  improve(agents): skip unused assistant delivery parsing (#146858)
  improve(ui): reuse date formatters across timestamp lists (#146789)
  fix(tests): isolate installer and Docker shell snippets (#146897)
  test(heartbeat): share explicit channel configuration fixtures (#146853)
  fix: retain conversation reply claims through write admission (#146866)
  perf(sessions): bound history reads and stabilize cursor paging (#146770)
  ...
vincentkoc added a commit that referenced this pull request Sep 13, 2026
* temp/pr-146802: (51 commits)
  improve: reduce worktree filesystem stalls and archive syncs (#146906)
  fix(ui): avoid extra chat rail work while replies stream (#146883)
  improve(ui): speed up populated Usage timelines (#146947)
  test(gateway): retain auth recovery failure diagnostics (#146925)
  fix(tests): create private temporary home directories (#146931)
  fix(backup): preserve discovery under concurrent state writes (#146912)
  fix: keep queued deliveries in their original state directory (#146917)
  fix(discord): settle voice waveform work before releasing input (#146885)
  fix(memory): preserve newer indexes and disclose automatic rebuild costs (#146908)
  fix: retain route ownership while discovering conversations (#146927)
  refactor: reuse plugin fixture shell runner (#146920)
  fix(worker): stop preparing disabled live previews (#146896)
  fix(runtime): support Bun across tooling suite (#146807)
  chore(i18n): refresh native locales (#146924)
  perf(secrets): limit expiry metadata to transient credentials (#146882)
  fix(ui): preserve queued refreshes during session discovery (#146535)
  test(ui): wait for quiet scrolling and close named file tabs (#146836)
  fix(ui): prevent Usage hour filters from freezing during DST (#146919)
  test(ui): share browser page cleanup across layout fixtures (#146805)
  ci: balance complete PR runtime test groups (#146916)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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: S 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