Repository navigation
fix: preserve interrupted worker replies - #170223
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
|
Codex review: needs changes before merge. What this changesPreserves 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete 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 Before merge
Findings
Tests
Agent review detailsHow this fits togetherNative 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]
Technical reviewBest 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:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e3735bccb4c5. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +28, Tests +110, Docs 0. Total +138 across 11 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)
Reviewed October 12, 2026, 6:12 PM ET / 22:12 UTC (Revision 4). |
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]>
## 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.
…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.
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
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.Release-note context: interrupted native-worker streams retain already-received assistant text in history, and interrupted worker errors retain their sanitized cause.