Skip to content

fix: prevent helper completions from restarting stopped work - #156124

Merged
shakkernerd merged 1 commit into
mainfrom
fix/stop-completion-retry
Sep 23, 2026
Merged

shakkernerd merged 1 commit into
mainfrom
fix/stop-completion-retry

Conversation

@shakkernerd

@shakkernerd shakkernerd commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Closes #156090

What Problem This Solves

Stop could cancel a helper-completion turn and still be followed by a fresh automatic retry. The completed child's pending continuation survived cancellation, so delivery treated the closed run authority as a retryable failure. A completion still waiting for admission could also start after session-wide Stop.

Stop now retires the selected work's pending completion continuation, including when the helper has already finished. Captured results and successful execution outcomes remain available, and a new human message works normally.

How It Works

The existing cancellation walker now visits completed children with pending requester wakes. Exact-run selection recognizes the completion batch's original or retry identity through the same identity builder used for admission. The pending-agent chat.abort branch uses the same accepted-cancellation boundary while preserving its expected-payload comparison before awaited descendant work.

The lifecycle owner persists the existing suppression marker and wake removal under current ownership checks. Committed cancellation releases only the matching continuation and timer. A definitely refused write restores the previous wake and any retained delivery result or replay budget before scheduling resumes. Declined or failed parent cancellation preserves completed descendants' still-owned wakes.

This adds no schema, serialized field, configuration, public protocol, goal-state change, or persistent session ban. Genuine transient delivery failures still retry. The stopping documentation covers the completed-child case.

Verification

All results below cover 60142c7d551cdae94673926a5d0dd0a8cbf6549e.

  • Before the fix, pending, session-wide, and exact-run Stop regressions failed locally and on Blacksmith Testbox while transient retry and the eight original controls passed. The registered pending-agent RPC case and the two rollback regressions also failed before their respective corrections.
  • 406 tests across 22 files pass on Testbox, including 19 cancellation cases, four two-member SQLite rollback cases, requester-wake delivery/ownership, cancellation recovery/concurrency, and registered chat.abort/sessions.abort authority and persistence paths. Replacement/rearmed owners, unrelated turns, mixed public/private completion identity, and retained child results remain covered.
  • The real Control UI and built Gateway pass the same restored-helper scenario. After acknowledged /stop, automatic model requests are 1 before the fix and 0 afterward across the stored retry deadline. No human chat.send occurred before that measurement. A subsequent real human request receives its rendered reply; the old wake is absent from SQLite and the helper result survives. The isolated provider supplies synthetic responses; Gateway admission, persistence, scheduling, WebSocket traffic, and UI are real.
  • CI passed, including production/test types, lint, guards, documentation, and selected test shards. Independent P0–P2 review and autoreview are clear. ClawSweeper rated this exact head Platinum with no code findings; its early-validation hold is addressed by this completed evidence.

Test costs use pnpm test <file> --maxWorkers=1 on the retained Testbox. Command wall time includes compiler and runner preparation. CI figures sum reported case durations and exclude module/import/worker overhead; they are not per-file wall times.

Test file Cases Command wall CI reported case time
subagent-announce.requester-settle-cancel.test.ts 19 34.520 s 10.217 s
subagent-completion-admission.cancel-rollback.test.ts 4 24.264 s 0.406 s

The corresponding shared CI test steps took 425 seconds and 455 seconds, including other files. The other 20 affected files passed in 115.209 seconds of Testbox command wall time. The real browser scenario took 63.0 seconds, or 90.6 seconds including its Vitest setup.

Visual evidence

Open preview

Before After
After Stop, an automatic helper-completion retry is running and Stop has reappeared. After Stop, the session remains idle past the pending helper-completion retry deadline.

Exact-head /stop, no automatic restart, and successful new human input

[email protected]

Visual verification

  • Baseline: 0ad150c
  • Exact head: 60142c7d551cdae94673926a5d0dd0a8cbf6549e
  • Scenario: Restore a completed helper with an automatic retry pending, send /stop through the real Control UI, wait past its stored deadline, and then send a new explicit human message.
  • Runtime/build: OpenClaw source build 60142c7; qaRuntime + ui:build; Node 24.19.0; Chromium 153.0.8010.12; runtime 9962a2cd82af; UI index ed22bbe9c12f
  • Automatic model requests after Stop: Baseline 1; fixed 0
  • Human sends before deadline measurement: 0 in both captures
  • Fixed session after deadline: hasActiveRun=false; no retry run identity
  • Later explicit human input: chat.send accepted; one model request; reply rendered
  • Helper result: Original successful outcome and captured result retained
  • Cancelled continuation: Old pending wake absent from SQLite
  • Real Control UI WebSocket traffic reached the registered sessions.abort handler.
  • Actual Gateway restoration, persistence, retry scheduling, and model dispatch were exercised.
  • Both captures use the same synthetic fixture, route, viewport, theme, and framing.
  • The fixed run passed all assertions and stopped its fixture Gateway and provider.
  • Screenshots were inspected at original resolution; the full recording sequence and its trigger/final transitions were inspected. No sensitive visible content was found.

The baseline recording shows the acknowledged Stop followed by the unwanted automatic retry.

@clawsweeper

clawsweeper Bot commented Sep 23, 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: L maintainer Maintainer-authored PR labels Sep 23, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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 23, 2026
@clawsweeper

clawsweeper Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 22, 2026, 11:26 PM ET / September 23, 2026, 03:26 UTC (Revision 2).

ClawSweeper review

What this changes

Stop now cancels pending helper-completion continuations, including retries from finished helpers, while retaining their results and restoring continuation state when persistence refuses cancellation.

Merge readiness

✅ Ready for maintainer review

This remains a useful fix with no blocking findings. The completed validation evidence resolves the previous review’s explicit hold.

Priority: P1
Reviewed head: 60142c7d551cdae94673926a5d0dd0a8cbf6549e

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused owner-level repair with meaningful rollback coverage, successful exact-head CI, and directly relevant before/after runtime evidence.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The supplied exact-head runtime observations exercise restored helper retries through the real Control UI, registered abort handler, Gateway scheduler, and SQLite owner: no automatic request follows Stop, results survive, and later human input succeeds. Inspected screenshots corroborate the visible states; video decoding was unavailable. No stored-data format or schema contract changes.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The supplied exact-head runtime observations exercise restored helper retries through the real Control UI, registered abort handler, Gateway scheduler, and SQLite owner: no automatic request follows Stop, results survive, and later human input succeeds. Inspected screenshots corroborate the visible states; video decoding was unavailable. No stored-data format or schema contract changes.
Evidence reviewed 9 items Introduced change and merge ownership: Reviewed the pinned merge-base-to-head delta. The verified test merge records f4a5f85 followed by the exact PR head as parents, and its result contains the same scoped changes rather than unrelated base-branch drift.
Fix remains necessary on fetched main: The cancellation walker, lifecycle wake owner, and pending-agent abort handler are unchanged between the reported failing baseline and fetched main. Main therefore retains the completed-child skip and pending-agent cancellation gaps. No tag contains the proposed head; no shipped-fix closure is established.
Cancellation persistence and rollback: The lifecycle owner fences delivery before awaiting the existing SQLite worker writer, checks current ownership before commit, releases matching continuation resources after commit, and restores the wake plus retained settlement information only for a definitely uncommitted write. Existing serialized fields and schemas are unchanged.
Findings None None.
Security None None.

How this fits together

Completed helpers leave durable continuations that can wake their parent conversation. Gateway Stop requests pass through cancellation ownership checks before the lifecycle owner retires those continuations and their retry timers.

flowchart TD
  A[User presses Stop] --> B[Gateway authorization]
  B --> C[Select owned helper batch]
  D[Completed helper and pending retry] --> C
  C --> E[Lifecycle cancellation]
  E --> F{Persistence outcome}
  F -->|Committed| G[Retire retry and retain result]
  F -->|Refused| H[Restore continuation]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +239, Tests +511, Docs +6. Total +756 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 10 285 46 +239
Tests 2 511 0 +511
Docs 1 6 0 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 802 46 +756

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +239 net lines; tests +511 net lines Production growth is justified by shared retry identity and ownership-preserving cancellation rollback, with focused regression coverage.
Observed automatic restart 1 request before; 0 after Stop The supplied real-Gateway observation spans the persisted retry deadline before any new human message.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #156090
Summary: This PR is the explicit implementation candidate for the still-open completed-helper Stop report.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep continuation cancellation with the existing lifecycle owner so accepted Stop prevents automatic restart without discarding results or blocking later human input.

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

Yes: the supplied reproduction and current-main source identify a completed helper whose surviving wake retries after accepted Stop; this review verified the mechanism without executing it.

Is this the best way to solve the issue?

Yes: extending the existing cancellation walker and lifecycle persistence owner is a focused repair, and sharing admission identity avoids a competing retry-matching implementation.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The supplied exact-head runtime observations exercise restored helper retries through the real Control UI, registered abort handler, Gateway scheduler, and SQLite owner: no automatic request follows Stop, results survive, and later human input succeeds. Inspected screenshots corroborate the visible states; video decoding was unavailable. No stored-data format or schema contract changes.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P1: The fix addresses automatic agent work restarting after the user has successfully requested Stop.
  • 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. Sufficient (live_output): The supplied exact-head runtime observations exercise restored helper retries through the real Control UI, registered abort handler, Gateway scheduler, and SQLite owner: no automatic request follows Stop, results survive, and later human input succeeds. Inspected screenshots corroborate the visible states; video decoding was unavailable. No stored-data format or schema contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied exact-head runtime observations exercise restored helper retries through the real Control UI, registered abort handler, Gateway scheduler, and SQLite owner: no automatic request follows Stop, results survive, and later human input succeeds. Inspected screenshots corroborate the visible states; video decoding was unavailable. No stored-data format or schema contract changes.

Evidence

What I checked:

  • Introduced change and merge ownership: Reviewed the pinned merge-base-to-head delta. The verified test merge records f4a5f85 followed by the exact PR head as parents, and its result contains the same scoped changes rather than unrelated base-branch drift. (7c5eddb2ea4e)
  • Fix remains necessary on fetched main: The cancellation walker, lifecycle wake owner, and pending-agent abort handler are unchanged between the reported failing baseline and fetched main. Main therefore retains the completed-child skip and pending-agent cancellation gaps. No tag contains the proposed head; no shipped-fix closure is established. (src/agents/subagents/registry/subagent-control-kill.ts, 6cbf27b004fb)
  • Cancellation persistence and rollback: The lifecycle owner fences delivery before awaiting the existing SQLite worker writer, checks current ownership before commit, releases matching continuation resources after commit, and restores the wake plus retained settlement information only for a definitely uncommitted write. Existing serialized fields and schemas are unchanged. (src/agents/subagents/registry/subagent-registry-lifecycle-wake.ts:216, 60142c7d551c)
  • Authority and replacement safeguards: Pending-agent cancellation retains requester authorization and expected-payload comparison before accepting Stop. Descendant selection remains constrained to controlled runs, and the worker persistence owner checks authority at transaction and commit admission. Existing currentness and cascade tests cover revoked callers, foreign work, and replacement registrations. (src/gateway/server-methods/chat-abort-handler.ts:325, 60142c7d551c)
  • Focused regression coverage: The added cancellation cases exercise pending admission, exact-run and mixed private retries, the registered pending-agent RPC, declined cancellation, unrelated turns, transient failures, and worker persistence. Four SQLite rollback cases preserve known delivery or replay budgets while protecting replacement and rearmed owners. Tests use fake timers; no tests were executed during this read-only review. (src/agents/subagents/completion/subagent-completion-admission.cancel-rollback.test.ts:63, 60142c7d551c)
  • After-fix production-path evidence: The supplied body snapshot, sourceRevision 3ee46846a58825febe0c0540a948db6b6e8a0acb6c8cf228d79398199f0e8d8e, records a real built Gateway and Control UI restoring a pending helper retry: automatic model requests after Stop fall from 1 to 0 across the stored deadline, subsequent human input succeeds, SQLite loses the cancelled wake, and the helper result survives. The provider responses are synthetic. Both downloaded before/after screenshots were inspected. Video preparation failed with 'ffprobe failed: spawnSync ffprobe ENOENT'; the web fallback returned Cache miss, so the recording itself was not inspected. (60142c7d551c)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; 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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-23T03:01:43.239Z sha 60142c7 :: needs changes before merge. :: none

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 23, 2026
@shakkernerd shakkernerd self-assigned this Sep 23, 2026
@shakkernerd
shakkernerd merged commit 1841ec8 into main Sep 23, 2026
223 checks passed
@shakkernerd
shakkernerd deleted the fix/stop-completion-retry branch September 23, 2026 04:02
@shakkernerd

Copy link
Copy Markdown
Contributor Author

Fixed: Stop now retires pending helper-completion retries without discarding captured results or blocking new human input.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 23, 2026
…w#156124)

Stop retires pending helper-completion retries for cancelled work while preserving completed results and later human input.

Closes openclaw#156090.
@roboclaw-bot roboclaw-bot mentioned this pull request Sep 24, 2026
2 of 8 tasks
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 maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: L 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.

[Bug]: Stop can restart a completed helper continuation

1 participant