Skip to content

fix: retire stopped command continuations - #166775

Merged
shakkernerd merged 2 commits into
mainfrom
fix/stop-command-continuations
Oct 8, 2026
Merged

shakkernerd merged 2 commits into
mainfrom
fix/stop-command-continuations

Conversation

@shakkernerd

@shakkernerd shakkernerd commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

An ordinary command can finish after its model turn and queue a completion turn. Stopping the request must also retire that continuation. The completion event currently loses the command's request owner, so removing the retained process output can leave Stop unable to find the queued work. A completion that has already started can also retain an event eligible for another wake.

This change uses the request-owned command cancellation landed in #166753 and follows that ownership through the completion queue, reply execution, and delivery.

User Impact

Stop retires the selected ordinary command's queued or running continuation, prevents its late final reply, and rejects another completion occurrence from the stopped owner. This remains effective when the process output record has already expired. Other queued events keep their order and remain available, and a later human instruction receives a fresh request owner.

Deliberate background: true services, retained command output, completed model receipts, and managed-worker behavior retain their existing contracts. No configuration or migration is required. An obsolete exact run ID does not gain cancellation authority after all of that request's active and queued custody has retired.

Why This Change Was Made

The exec completion producer now attaches its existing process-local request owner to the queued occurrence. Queue copies preserve that metadata, and heartbeat dispatch passes only its selected event owners into reply execution. The same cancellation signal then protects admission, execution, and final delivery. The metadata does not enter JSON or persistent storage.

Ordinary system events sharing a command continuation are temporarily retained until its outcome is known. The actual prompt-admission owner records which occurrences were admitted: normal and error exits keep their prior consumption behavior, while cancellation before a send preserves those unrelated events and later arrivals. Confirmed and unresolved sends retain the existing delivery owner; Stop cannot make the same result eligible for another generated reply. An unbound heartbeat retains the original request's actor and hidden/side-turn protections; a genuinely actor-bound current turn retains its own authority.

Live request ancestry also records continuation run IDs for same-controller descendant selection. Native child termination and routed destination-controller adaptation remain separate work; a run-ID list alone does not establish authority over another controller's children.

Evidence

The original producer regression fails before the fix when a completed command's output record has expired. Focused proof covers 85 cases across event/delivery custody, Gateway cascade/error handling, publication and wake-handler replacement. The 18-case delivery file passes in 93.26 seconds with one worker; the six-case full-reply file passes in 55.24 seconds, including worker preparation. Restoring the prior settlement behavior fails the sent/uncertain-delivery cases while no-send controls pass.

A confirmed or unresolved send never obtains a second send owner. Native recovery without a reconciler settles the unknown send without blindly replaying it. Cancellation before publication or dispatch leaves unrelated events available. The actual channel abort entry additionally passes denied/stale-target controls, retires a completed command after its process record is gone, preserves generic-event order, and admits a later human reply with a fresh owner.

At 9945186, all 53 static groups, 33 type graphs, package-boundary checks, the full private-QA build, 3,961 Node tests, 78 UI tests, and browser-extension checks passed; one Node test was skipped. The sole failing Node case was the existing direct-RPC Stop followed by a wake: its exact baseline reproduced the same stale command-source claim, independently repaired in #166968. The final prepared composition now passes that unchanged case in CI: one test passed in 15.32 seconds at merge tree a62c681, combining published 71e3277 with target c531ab2. These historical results retain their tested source identities.

Independent engineering review and the required P0 review qualify the final correction. The two contribution commits replay unchanged to 71e3277; review of the relevant target changes preserves the existing proof. Current-head hosted checks and ClawSweeper remain final landing gates. The five failed type lanes all report the same undefined resetProgressState in the unchanged Discord draft-preview owner. Each matching lane reproduced that diagnostic on exact target c531ab2 in scheduled CI; the aggregate gate reflects those failures. All 47 other executed PR jobs passed. The source file, relevant compiler inputs and dependencies match the target, so these are independently evidenced baseline failures.

The real Gateway/browser comparison below passes: Stop acknowledges cancellation in both variants, but only the fixed variant removes the selected completion. A later human instruction completes. The separate uncanceled control delivers exactly once, preserves that final after reload, and accepts the next instruction; it ran on the explicitly identified macOS composition. Only the loopback model response is scripted.

Visual evidence

Open preview

Before After
Stop interrupts the reply but leaves one command completion queued Stop interrupts the reply and removes the selected command completion

Command completion, Stop, then a new instruction

after-stop.mp4

Visual verification

  • Baseline: 9e006fd2d225926405e71c4c3fc246fc1c4a2a9f
  • Exact head: 71e32777fbc1e6e376957db380289203561d2a47
  • Scenario: An ordinary yielding command exits and starts its completion reply. Click Stop, then send a new instruction. The evidence-only cue shows the selected completion occurrence remaining before the fix and removed afterward.
  • Runtime/build: Captured source 99451865413a4db6482d44db59ded215be25dc4f. Linux, Node 24.19.0; candidate tree bc0e79327af5b75afbfd2013924846a339f8f7e5; native carrier d5e660e8f910043b4340850afaceb82ef13e0183; private-QA generation e5f1f2b8ecf6e73fdb2045ef9a214fdc95c0f781284ae27dad403da704a0eef2. Contribution replayed unchanged to 71e3277; runtime captures retain their original tested identity.
  • Selected completion after Stop: Before: 1; after: 0
  • Selected completion after new instruction: Before: 1; after: 0
  • Later human instruction: Completes in both variants
  • Separate uncanceled control: One visible final before and after reload; queue empty; later human instruction completes
  • Real Gateway, command process, queue, browser Stop and later human instruction; only the loopback Responses provider is scripted.
  • Actual sessions.abort succeeds in both Stop variants. Read-only Inspector observation identifies the selected event.
  • All Gateway, provider and Inspector cleanup assertions passed.
  • All full-resolution captures and complete recordings inspected; synthetic fixture content only.
  • Focused video trims the first 9 seconds of startup; original 19.76-second recording retained.
  • Uncanceled control separately passed on macOS at 2137b3a13982e8edf4996aeae51058cbc7bec717, tree 90deacd6075cbbc6a454664461ec5a473a4af903, generation 8d1472e3bc677b3cb038af359c9e6d99b6d54a87017955aef18d099cd64ac4e4.

@clawsweeper

clawsweeper Bot commented Oct 7, 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 docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: XL labels Oct 7, 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 Oct 7, 2026
@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 8, 2026, 1:56 AM ET / 05:56 UTC (Revision 8).

ClawSweeper review

What this changes

The branch carries command request ownership through completion events so Stop retires queued or running follow-ups while preserving unrelated work and existing delivery custody.

Example: Click Stop while an ordinary command’s completion reply is running.

  • Before: Stop acknowledges cancellation, but the selected completion remains queued with a count of 1.
  • After: The selected completion count becomes 0, and a later human instruction completes.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A useful owner-level repair with shipped-entry-point proof, preserved production identity, and no remaining actionable finding.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): The real Gateway/browser comparison exercises command completion, sessions.abort, queue retirement, and a later human instruction: the selected count changes from 1 to 0 after Stop. The recorded uncanceled control delivers once and survives reload. All 11 changed production blobs match the historical capture revision. Supporting owner-boundary cases cover denied actors and delivery races; video and CI-log inspection limits are recorded separately. Cancellation metadata remains process-local and introduces no stored-data contract.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Stop can leave a finished command’s follow-up eligible to run or reply after the user has canceled its request.
Reason: The change completes the established request-Stop contract at the continuation boundary. The contributor’s prior merged work establishes relevant area ownership, and the repair adds no configuration or permanent public surface.

Merge readiness

✅ Ready for maintainer review

This PR remains necessary and has convincing behavior proof. The previous delivery-custody concern is corrected, the wake failure is independently resolved, and this review found no actionable introduced defect.

Priority: P2
Reviewed head: 71e32777fbc1e6e376957db380289203561d2a47

Before merge

None.

Findings

None.

Provenance

  • src/auto-reply/reply/agent-runner-execution.ts request wrapper: original intent not found (unknown: Path history identifies recent reply-runtime consolidation, but deeper content history encountered missing promisor objects and HTTP 403; original introduction of the unwrapped execution boundary remains unknown.)
  • src/infra/system-events.ts canceled-event filtering: original intent not found (unknown: Read the queue implementation, supplied base-line provenance, and follow-history. Content-history search encountered unavailable promisor objects, so the original introduction of unconditional queue retention remains unverified.)
Agent review details

How this fits together

Commands that finish after their initial model turn enqueue completion events, which the background wake runner turns into follow-up replies. This change connects those events and replies to the original request’s cancellation owner.

flowchart TD
  A[Ordinary command finishes] --> B[Completion event with request owner]
  B --> C[Background wake selects events]
  C --> D[Follow-up execution]
  E[User presses Stop] --> F[Cancel selected request owner]
  F --> B
  F --> D
  D --> G[Reply delivery and settlement]
  G --> H[Preserve unrelated work and delivery custody]
Loading

Technical review

Best possible solution:

Extend the existing request and delivery owners through completion settlement, preserving independent services, unrelated events, and irreversible send outcomes.

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

Yes: current-main completion production drops request ownership, leaving queued work undiscoverable after process-record eviction; the supplied Gateway comparison demonstrates the corresponding before-and-after behavior.

Is this the best way to solve the issue?

Yes: the patch extends existing ownership and settlement boundaries instead of introducing another cancellation or retry manager.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • src/agents/bash-process-control.ts and src/infra/exec-request-context.ts keeps the original intent (109bd47: Retain ordinary commands under their selected Gateway request, join physical cleanup, and preserve uncertainty after output eviction.)
  • src/agents/bash-tools.exec-runtime.ts completion production keeps the original intent (f0b38ed: Conversation-started command completions continue in their originating conversation while periodic heartbeat settings retain their existing scope.)
  • src/infra/heartbeat-dispatch.ts delivery settlement keeps the original intent (630e969: Preserve original-route retries only before delivery custody exists; queued and ambiguous sends remain with recovery rather than being regenerated.)
  • src/infra/heartbeat-runner-run.ts and reply system-event admission keeps the original intent (630e969: Select captured completion work before model admission and settle generic events only from the admitted queue.)
  • src/gateway/server-methods/chat-abort-runtime.ts descendant selection keeps the original intent (109bd47: Capture selected request commands before awaited cancellation and preserve existing actor and session-generation checks.)

Testing

Proof path: shipped entry point. Added test files: 7.

Security

None.

Evidence

What I checked:

Likely related people:

  • Shakker: Raw commit 109bd47 adds src/agents/bash-process-control.ts:85 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 109bd4791099; files: src/agents/bash-process-control.ts)
  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

PR surface

Source +192, Tests +1111, Docs +1, Other -1. Total +1303 across 20 files.

View PR surface stats
Area Files Added Removed Net
Source 11 254 62 +192
Tests 7 1153 42 +1111
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 20 1408 105 +1303

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove merge-risk: 🚨 message-delivery: Current PR review selected no merge-risk labels.

Label justifications:

  • P2: This repairs a bounded Stop and completion-follow-up lifecycle defect without changing configuration or public contracts.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

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 need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (7 earlier review cycles)
  • reviewed 2026-10-07T22:25:53.517Z sha 17f964a :: needs maintainer review before merge. :: none
  • reviewed 2026-10-07T22:31:57.619Z sha 17f964a :: needs maintainer review before merge. :: none
  • reviewed 2026-10-08T00:50:49.371Z sha 5323982 :: blocked before merge. :: [P2] Keep surviving completions under unresolved delivery custody
  • reviewed 2026-10-08T01:20:37.587Z sha 5323982 :: blocked before merge. :: [P2] Keep surviving completions under unresolved delivery custody
  • reviewed 2026-10-08T02:01:35.097Z sha 5323982 :: blocked before merge. :: [P2] Keep surviving completions under unresolved delivery custody
  • reviewed 2026-10-08T02:30:43.029Z sha 82b4f282b066caefc9aa56d5aeb632f8d58c4612 :: blocked before merge. :: none
  • reviewed 2026-10-08T03:08:45.056Z sha 99451865413a4db6482d44db59ded215be25dc4f :: blocked before merge. :: none

@shakkernerd
shakkernerd force-pushed the fix/stop-command-continuations branch from 17f964a to 5323982 Compare October 8, 2026 00:40
@clawsweeper clawsweeper Bot added merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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 Oct 8, 2026
Base automatically changed from fix/stop-owned-exec to main October 8, 2026 01:54
@openclaw-barnacle openclaw-barnacle Bot added the app: web-ui App: web-ui label Oct 8, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 8, 2026
@shakkernerd
shakkernerd force-pushed the fix/stop-command-continuations branch from 82b4f28 to 9945186 Compare October 8, 2026 02:52
@openclaw-barnacle openclaw-barnacle Bot removed the app: web-ui App: web-ui label Oct 8, 2026
@shakkernerd
shakkernerd force-pushed the fix/stop-command-continuations branch from 9945186 to 71e3277 Compare October 8, 2026 05:38
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Oct 8, 2026
@clawsweeper clawsweeper Bot added proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Oct 8, 2026
@shakkernerd shakkernerd self-assigned this Oct 8, 2026
@shakkernerd
shakkernerd merged commit 594335a into main Oct 8, 2026
146 of 153 checks passed
@shakkernerd
shakkernerd deleted the fix/stop-command-continuations branch October 8, 2026 06:04
@shakkernerd

Copy link
Copy Markdown
Contributor Author

Fixed: Stop now retires ordinary command continuations while preserving unrelated events and later instructions.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 9, 2026
Retire queued and running ordinary command continuations when their request is stopped, preserving unrelated events and existing delivery custody.
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 13, 2026
Conflicts: system-events (openclaw#166775 exec-request owners now wrap both the append
event and our keyed replaceSystemEventEntry replacement), session-system-events
(onEventsAdmitted carried onto prepareFormattedSystemEvents, fed the consumed
set as upstream does), config baseline (regenerated).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Jhynq2GVpzuVQQieebEubg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XL 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