Repository navigation
fix: worker reply corrections repeat stale live text - #131869
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 28, 2026, 12:39 PM ET / 16:39 UTC. ClawSweeper reviewWhat this changesThe PR gives worker live assistant snapshots a stable message identity so Gateway chat replaces corrected, shortened, and empty previews without replaying earlier text. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep open: current main still matches the PR base on the affected production owners, while this branch supplies the missing per-message replacement scope. It is maintainer-authored and carries a maintainer label; exact-head checks and parent review remain. Priority: P2 Review scores
Verification
How this fits togetherWorker runtime streams assistant previews to the Gateway over the worker live-event service. Gateway chat projection turns them into visible updates while transcript persistence remains a separate durable path. flowchart LR
A[Worker assistant events] --> B[Worker live-event client]
B --> C[Gateway live-event receiver]
C --> D[Gateway chat projector]
D --> E[Active assistant scope]
E --> F[Visible chat update]
C --> G[Durable transcript path]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +111, Tests +344, Docs +2. Total +457 across 16 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the scoped Gateway projection after exact-head validation confirms the composed worker-to-Gateway replacement cases and parent review accepts the bounded active-message state. Do we have a high-confidence way to reproduce the issue? Yes, in source: the old cumulative merge appends a non-prefix worker snapshot delta, and the added composed test exercises the correction and empty-replacement order. This read-only review did not execute the suite. Is this the best way to solve the issue? Yes. The existing worker protocol already carries item identity, and holding the completed prefix beside the active identity at the Gateway projector avoids a competing worker-specific merge path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 6ee9b5ed7ca4. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
Land-ready at CI 33190487790 passed on attempt 1, including required gate 98917967212 and repaired Code Mode shard 98914790463. The unmodified native hosted-gate verifier accepts that exact-head CI plus Workflow Sanity 33186279701 from the earlier same-PR head Proof commands: node scripts/run-vitest.mjs src/gateway/worker-environments/live-chat.test.ts
node scripts/run-vitest.mjs src/agents/code-mode.bridge.host-denial.test.ts src/agents/code-mode.bridge.lifecycle.test.ts src/agents/code-mode.bridge.test.ts
node scripts/check-changed.mjs
node scripts/check-changed.mjs -- src/agents/code-mode.bridge.host-denial.test.ts src/agents/code-mode.bridge.lifecycle.test.ts src/agents/code-mode.test-support.ts
node scripts/verify-pr-hosted-gates.mjs --repo openclaw/openclaw --sha e0399babb4881eabb242a00c39baaa01879dd2bd --pr 131869 --output .artifacts/pr-131869-hosted-gates.jsonThe 17 composed snapshot cases pass within 461 owner/sibling tests; the unchanged production is also covered by current-head CI. The canonical test-only continuation repair from #131866 ( ClawSweeper's three pre-merge moves are addressed: parent accepted the canonical message-scope/prefix/phase ownership and justified +53 production LOC; direct main inspection at No live provider, remote Gateway, browser/Control UI, or visual proof was run because the operator explicitly excluded those flows and media uploads. Composed local socket/service tests are not represented as live or visual proof. No uncommitted tooling investigation is included. Proceeding with normal |
|
Merged via squash.
|
* fix: worker reply corrections repeat stale live text * test(code-mode): await terminal subscribed bridge outcomes
Closes #131867
What Problem This Solves
Fixes an issue where users watching worker-turn replies would see stale text or repeated fragments when an authoritative assistant snapshot corrected, shortened, or bounded an earlier preview. Empty final snapshots could also leave a discarded draft visible.
Why This Change Was Made
Worker snapshots are per assistant message, while Gateway live chat is cumulative across the run. The producer now supplies stable message identity through the existing
itemIdfield, and the Gateway replaces only that message's contribution while retaining the bounded completed prefix. Simply forwardingreplaceor adding text-overlap deduplication would erase pre-tool text or legitimate repeated messages.The producer reconciles late/mixed commentary before deriving both snapshots and deltas. Empty clears reach the chat broadcast. Native Codex provisional replacement and local TUI unkeyed merging retain their existing contracts; transcript persistence, worker authority, and workspace reconciliation still own their existing boundaries. No protocol, configuration, SQLite schema, dependency, or public SDK surface is added.
Removed duplicate completion-only emission and unused broadcast-length state. Test-only socket fixtures now use short paths and listen for the WebSocket server's forwarded bind errors, avoiding macOS path-limit setup hangs. The chat adapter is isolated in a test-support module without adding a production test seam or lint suppression.
Source provenance: worker runtime foundation,
6cd11338588e3dc520b9b38d34312948c84f1608, 2026-07-13; code author and merger @steipete. Stable-release regression status is not established.User Impact
Corrected, shortened, empty, and bounded worker previews update the current message without replaying earlier text. Intentional pre-tool prose and distinct identical messages remain visible. Late commentary is excluded from answer text, and a later workspace-reconciliation failure still reports an error rather than premature success.
The source documentation for Cloud workers explains the snapshot and durability boundaries. AI-assisted with Codex.
Evidence
Before tool\nRevised, receivedBefore tool\nDraft with stale suffixRevised; an empty final retained the draft. Two additional producer-delta tests failed before their corresponding refinements.createAgentEventHandler, with synthetic provider/session input. The final suite contains 17 regressions covering repeated legitimate messages, repeated completion, late/mixed phases, Unicode byte bounds, capped-prefix retirement, missing previews, out-of-order requests, and ACK replay.59e44c27146889e1c6dcd397423dbeeacdccd705(production bytes unchanged by the test repair) across owner and sibling runs, including worker runtime/fault injection, Gateway event merging, cleanup, launcher terminal results, and native Codex. This includes all 17 composed projection cases, 72 worker tests, 367 Gateway tests (including the current-main reload fixture), and 22 Codex projector tests. The earlier selected local TUI run passed 7 cases.node scripts/check-changed.mjspassed, including production/core-test types, scoped lint, formatting, dependency/architecture guards, dead exports, and import cycles. Fresh branch-mode Codex autoreview of the complete new head against pinned main, plus precommit review of the canonical fixture repair, reported no actionable P0 findings.d65d31593926f26bc6dd030240bc009be87ef75d, includingevent_mapping.rs:362-418, item-scoped deltas and authoritative completion; inspectedwsbind-error forwarding directly.Current head:
e0399babb4881eabb242a00c39baaa01879dd2bd(snapshot commit plus canonical test repair), original rebase base:11a491beccfd4f52a9b0e8e605e61457265a943c. The only rebase conflict retained main’s stronger reload fixture unchanged, so that file is absent from this PR.Validation retry: an initial broad run and an isolated maintenance case timed out during module import on a heavily loaded host. Temporary diagnostic checkpoints localized the delay to import and then passed; they were removed. The original focused command subsequently passed on unchanged committed bytes, with no timeout, assertion, mock, or runtime changes. The changed gate also passed.
CI fixture repair: the first hosted attempt and an additional local diagnostic exposed a real test contract defect: the host-denial fixture treated the first 1.5-second Code Mode slice as terminal. Reused the isolated canonical test commit from #131866,
e76dd81421492eb7de46dcce402efa9bd988f3af, without its macOS workflow change. Terminal assertions now resume the original run through the existing bounded public-wait helper; they never replay the command. The deterministic host-repair case exhausts the unchanged budget after real command completion and verifies one wait, one hook, one spawn, and exact output. Raw parked, late-settlement, cancellation and approval assertions remain. Grouped host-denial/lifecycle/bridge verification passed 82 tests on the committed repair bytes; scoped core-test types, lint, formatting, architecture and export gates passed. Fresh precommit Codex autoreview reported no actionable findings. No Code Mode production behavior or execution budget changed.Hosted CI: current head
e0399babb4881eabb242a00c39baaa01879dd2bdpassed CI 33190487790 on attempt 1, including required gate job 98917967212 and the repaired Code Mode shard 98914790463. The unmodified native hosted-gate verifier passed with this exact-head CI and Workflow Sanity 33186279701 from the earlier same-PR head through its supported recent-cohort rule; both committed heads have identical workflow/native tooling. Current Workflow Sanity retry 33190487776 remains pending/stalled; it is not claimed as passed. Parent reviewed and approved the current committed patch. Earlier snapshot head59e44c27146889e1c6dcd397423dbeeacdccd705passed run 33186321002 on attempt 2, but retry-green was not treated as resolving the fixture defect. The fixture defect was repaired before the current first-attempt green run.ClawSweeper disposition: no introduced functional or security finding. The +53 production lines establish active-message/prefix ownership inside the canonical projector; the existing unkeyed branch protects current Codex/TUI callers, not an alternate worker replacement path. Direct inspection of main at
c17d442a6e2121bf2f4edb5d6c1397d6e45cf84cfound the four production owners and worker fixture unchanged from the tested base, resolving the reviewer's unavailable-blob gap. The later Codex-contract rank-up is also verified directly at the pinned upstream revision:turn.rs:2554-2580derives deltas from active item identity;bespoke_event_handling.rs:979-1033relays canonical completion;README:1587-1636specifies item lifecycle and authoritative completion. The existing unkeyed Codex/TUI path remains unchanged. Its storage detector is a false positive: no durable schema, migration, retention, or storage semantics change. The latest review at 2026-08-28 16:39 UTC has no actionable findings. Its three pre-merge moves are addressed: parent accepted the canonical scope/LOC justification, direct current-main evidence is recorded, and exact-head required CI is green. No repair dispatch is needed. Live/visual proof remains intentionally unavailable under the scope below.Primary reproduction:
node scripts/run-vitest.mjs src/gateway/worker-environments/live-chat.test.ts.Rebased focused verification:
Proof limits: No live provider, live cloud machine, browser/Control UI, or operator Gateway flow was run. Browser/remote Gateway control and media uploads were explicitly outside the authorized scope; the proof above is deterministic local socket/service behavior, not live authenticated or visual proof. The separate persisted/live overlap issue and its earlier malformed-fragment recording are not attributed to this defect without raw payload evidence.