Skip to content

fix: preserve interrupted worker replies - #170223

Merged
steipete merged 5 commits into
mainfrom
fix/worker-interrupted-replies
Oct 12, 2026
Merged

steipete merged 5 commits into
mainfrom
fix/worker-interrupted-replies

Conversation

@steipete

@steipete steipete commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

A native worker killed during streaming could leave visible assistant text out of canonical history. A separate abort diagnostic guard hid concrete failures behind a generic worker error.

Prepare failed native turns in the existing failure owner: call the guarded partial-transcript writer while its exact claim remains current, then inspect any pending workspace result. Persist only the uncommitted display tail, avoiding duplication of prior committed messages. A failed save emits a warning and cleanup still proceeds. Retain sanitized diagnostics alongside the existing aborted outcome. Ignore an empty synthetic aborted snapshot so it cannot erase text already streamed and checked.

Net production LOC: +29, six production files. No new lifecycle state, protocol, retry, or durable storage. Automatic replay of an interrupted side-effecting tool remains outside this fix.

Evidence

  • Baseline live loss reproduced twice each in repository and empty workspaces.
  • Regression baseline: both partial-save cases fail at the missing persistence boundary, 46.896 s.
  • pnpm test src/gateway/worker-environments/worker-turn-launcher-failure-recovery.test.ts --maxWorkers=1: final regression 14 passed, 67.89 s. This includes the pending-workspace recovery branch that bypassed the original failure callback.
  • pnpm test src/gateway/server-chat-state.projection.test.ts --maxWorkers=1: 37 passed, 23.444 s.
  • pnpm test src/worker/embedded-agent-live.runtime.test.ts --maxWorkers=1: corrected combined candidate 14 passed, 38.27 s; baseline has one expected empty-abort failure and 13 passes, 29.83 s. Earlier diagnostic baseline fails four assertions.
  • pnpm test src/worker/worker.runtime.test.ts --maxWorkers=1 -t "keeps desktop images": 2 passed, 68 skipped, 44.886 s wall; cancellation still asserts both inference and cleanup errors.
  • Corrected identity projection: 13/13 worker failure regressions plus the startup boundary passed together in 155.76 s (worker shard 115.98 s).
  • Final mechanical failure-owner extraction passes type-aware lint and formatting; launcher stays within its existing 700-line cap. A local regression rerun was stopped after 623.84 s with zero assertions/results (240.038 s rebuilding a cold worker cache); this is uncompleted evidence, not a pass. Exact-head PR CI passed every test, static check, and required gate (run 38315444496, 742 s wall).
  • Focused lint, formatting, and whitespace checks pass. Independent review found no actionable P0/P1 issues. The final reviewed candidate moves the save before pending-workspace recovery and uses the placement identity. The independently reviewed three-file follow-up matches the committed source hashes. The live source union before the behavior-preserving failure-owner extraction passed after two actual node SIGKILL incidents: Git2 + empty2 preserved exactly 4,415 / 5,862 / 5,025 / 5,714 visible bytes once in canonical history. All four immediate next turns completed without manual placement repair. The interrupted original turn still reports a clear failure; automatic replay is outside this fix.

Release-note context: interrupted native-worker streams retain already-received assistant text in history, and interrupted worker errors retain their sanitized cause.

@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: M labels Oct 12, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 12, 2026
@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

Preserves received native-worker reply text before failure recovery and retains sanitized interruption diagnostics.

Example: A native worker disappears after streaming “Checked partial reply.” while the Gateway remains running.

  • Before: The displayed text can disappear from canonical history.
  • After: The Gateway attempts to save the uncommitted text once before releasing the turn.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused repair and regression coverage are useful, but the introduced lint failure blocks CI and the reported native replay has no inspectable current artifact.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor-proof gate; the body reports rebuilt native-worker SIGKILL replays in repository and empty workspaces with text preserved once and successful follow-ups, while directly inspectable proof remains regression code and historical offline-recovery screenshots.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A worker interruption can erase already-visible assistant text from history and hide its concrete failure cause.
Reason: The maintainer-authored direction repairs demonstrated reply loss through existing owners without adding configuration, protocol, or lifecycle state.

Merge readiness

⛔ Needs changes before merge - 1 item remains

This PR repairs a current-main reply-loss path, but its final change introduces a lint failure that blocks CI.

Priority: P1
Reviewed head: a1b3ff71e21aa617b19db10856afa9782a74df08

Before merge

  • Restore the launcher's enforced line budget (P2) - This new block increases the launcher from 700 to 716 counted lines, exceeding the configured 700-line maximum. Exact-head check-lint-core-1 reports this file and fails, which also fails the required CI gate. Move the best-effort save operation into the existing failure owner or otherwise reduce the launcher, keeping its awaited invocation before findPendingWorkerWorkspaceResult so pending-result recovery still preserves the partial.

Findings

  • [P2] Restore the launcher's enforced line budget — src/gateway/worker-environments/worker-turn-launcher.ts:639-642

Tests

  • Missing end-to-end proof: The body reports completion of the requested native interruption replay, but no current replay trace or media was supplied; inspected screenshots demonstrate historical offline continuation.
Agent review details

How this fits together

Native workers stream assistant text and commit messages to the Gateway; the launcher settles failed turns, preserves transcript state, and coordinates workspace recovery and placement cleanup.

flowchart LR
  A[Native worker] --> B[Gateway live buffer]
  A --> C[Canonical transcript]
  B --> D[Turn failure handling]
  D --> E[Existing partial writer]
  E --> C
  D --> F[Workspace recovery and cleanup]
Loading

Technical review

Best possible solution:

Keep the existing persistence and failure owners, preserve the save-before-recovery ordering, and resolve the introduced launcher lint failure.

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

Current-main source exposes both the missing failure-save boundary and aborted-diagnostic suppression, consistent with the reported baseline reproductions; no target code was executed during this review.

Is this the best way to solve the issue?

Reusing the guarded writer with the unsaved display tail repairs the owning boundary without replaying interrupted work, and placing it before pending-result recovery covers both failure paths.

Full review comments:

  • [P2] Restore the launcher's enforced line budget — src/gateway/worker-environments/worker-turn-launcher.ts:639-642
    This new block increases the launcher from 700 to 716 counted lines, exceeding the configured 700-line maximum. Exact-head check-lint-core-1 reports this file and fails, which also fails the required CI gate. Move the best-effort save operation into the existing failure owner or otherwise reduce the launcher, keeping its awaited invocation before findPendingWorkerWorkspaceResult so pending-result recovery still preserves the partial.
    Confidence: 1

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Partial transcript persistence keeps the original intent (bbbd705: Explicit offline-device abandonment preserves the held assistant partial before closing the source placement.)
  • Committed text versus unsaved display tail keeps the original intent (af210e1: Producer occurrence identity separates saved messages from unsaved live text while retaining complete delivery text.)
  • Aborted terminal diagnostics changes intended behavior with a stated reason (49a8b1c: Terminal merging preserves cancellation when cleanup subsequently fails; this PR explains retaining the sanitized cause while keeping the aborted outcome.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/gateway/worker-environments/worker-turn-launcher.ts src/gateway/worker-environments/worker-turn-failure.ts src/gateway/worker-environments/worker-turn-launcher.types.ts
  • pnpm test src/gateway/worker-environments/worker-turn-launcher-failure-recovery.test.ts --maxWorkers=1
  • pnpm check:import-cycles
  • git diff --check

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit bbbd705 adds src/gateway/server-runtime-state-prepare.ts:208 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: bbbd70542b44; files: src/gateway/server-runtime-state-prepare.ts)
  • Vincent Koc: Raw commit 485c2cc adds src/worker/embedded-agent-live.runtime.ts:225 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 485c2cc53751; files: src/worker/embedded-agent-live.runtime.ts)

PR surface

Source +28, Tests +110, Docs 0. Total +138 across 11 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 6 38 10 +28
Tests 4 200 90 +110
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 239 101 +138

Labels

Label changes:

  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P1: An interrupted native-worker turn can lose assistant text the user already saw from canonical history.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-12T20:51:44.125Z sha 4d14835 :: needs changes before merge. :: [P1] Pass complete session identity to the partial transcript writer | [P2] Update the worker integration expectation for aborted diagnostics
  • reviewed 2026-10-12T21:02:56.471Z sha 6a71483 :: needs changes before merge. :: [P2] Update the worker integration expectation for aborted diagnostics
  • reviewed 2026-10-12T21:35:23.604Z sha a37ce3b :: needs maintainer review before merge. :: none

Reviewed October 12, 2026, 6:12 PM ET / 22:12 UTC (Revision 4).

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Oct 12, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 12, 2026
@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 12, 2026
@steipete
steipete merged commit ea3ffb7 into main Oct 12, 2026
134 of 135 checks passed
@steipete
steipete deleted the fix/worker-interrupted-replies branch October 12, 2026 22:29
RomneyDa pushed a commit that referenced this pull request Oct 13, 2026
A native worker killed during streaming could leave already-visible
assistant text out of canonical history, and an abort diagnostic guard hid
the concrete worker failure behind a generic error. Failed handed-off native
turns now save the uncommitted display tail through the existing guarded
partial-transcript writer while their exact claim is still current, keep the
sanitized promptError alongside the aborted outcome, and ignore an empty
synthetic aborted final that would erase streamed text.

Backport adaptation: the branch keeps the launcher options type inline in
worker-turn-launcher.ts (main later moved it to worker-turn-launcher.types.ts),
so persistAbandonedPartial is added to that inline type and the single
findPendingWorkerWorkspaceResult call site switches to
prepareWorkerTurnFailure. The cosmetic `terminal:` spread rewrite in the
launcher is left out. In embedded-agent-live.runtime.test.ts only the new
empty-final regression is taken; a neighboring main-only reasoning test
pulled in by the conflict hunk is dropped. The branch still carries the
stop/aborted-without-cleanup-failure rows of the deferred-terminal table
(main removed them in test-only #169218), so their error assertion stays
conditional: those rows have no prompt error to retain.

Extracted-from: ea3ffb7
Co-authored-by: Peter Steinberger <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
## What Problem This Solves

A native worker killed during streaming could leave visible assistant text out of canonical history. A separate abort diagnostic guard hid concrete failures behind a generic worker error.

Prepare failed native turns in the existing failure owner: call the guarded partial-transcript writer while its exact claim remains current, then inspect any pending workspace result. Persist only the uncommitted display tail, avoiding duplication of prior committed messages. A failed save emits a warning and cleanup still proceeds. Retain sanitized diagnostics alongside the existing aborted outcome. Ignore an empty synthetic aborted snapshot so it cannot erase text already streamed and checked.

Net production LOC: +29, six production files. No new lifecycle state, protocol, retry, or durable storage. Automatic replay of an interrupted side-effecting tool remains outside this fix.

## Evidence

- Baseline live loss reproduced twice each in repository and empty workspaces.
- Regression baseline: both partial-save cases fail at the missing persistence boundary, 46.896 s.
- `pnpm test src/gateway/worker-environments/worker-turn-launcher-failure-recovery.test.ts --maxWorkers=1`: final regression 14 passed, 67.89 s. This includes the pending-workspace recovery branch that bypassed the original failure callback.
- `pnpm test src/gateway/server-chat-state.projection.test.ts --maxWorkers=1`: 37 passed, 23.444 s.
- `pnpm test src/worker/embedded-agent-live.runtime.test.ts --maxWorkers=1`: corrected combined candidate 14 passed, 38.27 s; baseline has one expected empty-abort failure and 13 passes, 29.83 s. Earlier diagnostic baseline fails four assertions.
- `pnpm test src/worker/worker.runtime.test.ts --maxWorkers=1 -t "keeps desktop images"`: 2 passed, 68 skipped, 44.886 s wall; cancellation still asserts both inference and cleanup errors.
- Corrected identity projection: 13/13 worker failure regressions plus the startup boundary passed together in 155.76 s (worker shard 115.98 s).
- Final mechanical failure-owner extraction passes type-aware lint and formatting; launcher stays within its existing 700-line cap. A local regression rerun was stopped after 623.84 s with zero assertions/results (240.038 s rebuilding a cold worker cache); this is uncompleted evidence, not a pass. Exact-head PR CI passed every test, static check, and required gate (run 38315444496, 742 s wall).
- Focused lint, formatting, and whitespace checks pass. Independent review found no actionable P0/P1 issues. The final reviewed candidate moves the save before pending-workspace recovery and uses the placement identity. The independently reviewed three-file follow-up matches the committed source hashes. Final rebuilt cross-machine replay passed after two actual node SIGKILL incidents: Git2 + empty2 preserved exactly 4,415 / 5,862 / 5,025 / 5,714 visible bytes once in canonical history. All four immediate next turns completed without manual placement repair. The interrupted original turn still reports a clear failure; automatic replay is outside this fix.

Release-note context: interrupted native-worker streams retain already-received assistant text in history, and interrupted worker errors retain their sanitized cause.
RomneyDa added a commit that referenced this pull request Oct 13, 2026
…er the #170223 backport

The #170223 backport (d5d64b4) took main's cancelled-terminal assertion that the finishing payload carries both the retained cancellation reason and 'fixture desktop cleanup failed'. Main's table only has computerCleanupFailure: true rows at that point, but this branch still carries the cleanup-failure: false rows, so the (false, cancelled) row failed deterministically (FRV run 38333371459, job 115088208610). The cancellation reason assertion stays unconditional; the desktop cleanup error is asserted only when cleanup fails and asserted absent otherwise.
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 P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant