Skip to content

fix: keep stale Stop messages from canceling replacement sessions - #152116

Merged
steipete merged 2 commits into
mainfrom
codex/guarded-stop-main
Sep 18, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/guarded-stop-main

Conversation

@steipete

@steipete steipete commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Related: #150153

What Problem This Solves

A stale Stop message can cancel a replacement session or its child work after the request's captured session guard has become invalid.

User Impact

Guarded Stop messages stay bound to their admitted session and transcript position. Rejected cancellation releases unaccepted claims, while cancellation already accepted still settles and preserves captured output.

Why This Change Was Made

Reuse the existing session guard at cancellation effect boundaries and after awaited descendant work. Retain the physical storage source selected during admission, and let the existing router preserve structured authorization errors. Ordinary run-specific abort behavior remains unchanged.

Evidence

Original handler regressions fail before the fix. Real isolated listening WebSocket Gateway cases reproduce stale-leaf cancellation and a session replacement during the awaited drain, then pass with the correction; controlled agent streams verify partial-output persistence and child settlement. No external provider traffic is claimed.

All 353 focused tests, the final three-case replay, full changed checks, and fresh independent P0–P2 review pass. Hosted CI exposed an ended-parent fixture that omitted the captured config required by the real session reader. The fixture now supplies its own context config and resets its mock between cases; all 80 affected and sibling cases, selected checks, and fresh review pass without a production fallback or changed assertions. The next CI run hit duplicate declarations in three unchanged SQLite tests; #152028 independently fixed those on main. The branch was restacked onto that fix with byte-identical patch content and unchanged review scope. All 196 cases in the nine selected Stop, persistence, SQLite, and requester-settlement suites pass on the refreshed base. Exact-head CI35395311933 passes for f5af7b222d8c.

This focused prerequisite adds 94 production lines; the aggregate production reduction target for the replacement series remains unmet.

@clawsweeper

clawsweeper Bot commented Sep 18, 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 18, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 18, 2026
@clawsweeper

clawsweeper Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 18, 2026, 5:15 PM ET / 21:15 UTC (Revision 4).

ClawSweeper review

What this changes

The PR rechecks session and transcript guards during typed Stop cancellation, preserves accepted cancellation and captured output, and adds regression coverage and documentation.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused fix: fetched main and the latest release still bypass transcript guards for typed Stop. No actionable introduced defect was found.

Priority: P2
Reviewed head: f5af7b222d8c001d0856884245b866909d94abe9

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with meaningful boundary coverage and no actionable findings; reported runtime validation was not rerun in this read-only review.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored PR is exempt from ordinary contributor proof. Its body reports listening-Gateway stale-leaf and replacement-during-drain runs; inspected scenarios exercise the changed cancellation owner, and no unresolved authority-chain proof requirement was identified.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored PR is exempt from ordinary contributor proof. Its body reports listening-Gateway stale-leaf and replacement-during-drain runs; inspected scenarios exercise the changed cancellation owner, and no unresolved authority-chain proof requirement was identified.
Evidence reviewed 9 items Still necessary on main: Fetched main handles typed Stop before normal admission and forwards only the existing caller assertion; it does not apply the expected transcript leaf check in this path.
Latest release comparison: The same Stop path in the supplied v2026.9.4 release commit lacks the transcript guard. No shipped replacement for this change was established.
Guard propagation and error preservation: The Stop path rereads the captured physical store, reuses the existing leaf/session validator, latches rejection, and preserves structured session-authorization errors for the router. Unguarded requests and steer compatibility remain supported.
Findings None None.
Security None None.

How this fits together

The Gateway receives Stop requests from chat clients and coordinates cancellation of active turns, queued work, and child agents. Session guards keep those effects attached to the conversation originally selected.

flowchart TD
  A[Typed Stop request] --> B[Session and transcript guards]
  B --> C{Target still current?}
  C -->|Yes| D[Cancel selected runs and children]
  D --> B
  C -->|No| E[Reject further cancellation]
  D --> F[Settle accepted work and preserve output]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +94, Tests +617, Docs +5. Total +716 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 5 143 49 +94
Tests 4 643 26 +617
Docs 1 5 0 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 791 75 +716

Review metrics

Metric Value Why it matters
Production versus test growth Production +94 net lines; tests +617 net lines Production growth is justified by cancellation-boundary revalidation and failure settlement; the broader series reduction target remains separate.

Technical review

Best possible solution:

Keep cancellation in the existing owner, revalidate before new effects, and settle accepted work only against its captured session incarnation.

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

Yes, from source: send typed /stop with a stale expected leaf to an active session; current main reaches cancellation before applying that guard. This review did not execute the scenario.

Is this the best way to solve the issue?

Yes. Reusing the existing guard and cancellation-control owner addresses the race while preserving accepted settlement and established unguarded behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This fixes a bounded stale-request cancellation race without evidence of a widespread outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The maintainer-authored PR is exempt from ordinary contributor proof. Its body reports listening-Gateway stale-leaf and replacement-during-drain runs; inspected scenarios exercise the changed cancellation owner, and no unresolved authority-chain proof requirement was identified.

Evidence

What I checked:

Likely related people:

  • Colin Johnson: Raw commit 5dd4c6e adds src/gateway/server-methods/chat-send-active-leaf.ts:28 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5dd4c6e3b087; files: src/gateway/server-methods/chat-send-active-leaf.ts)
  • steipete: 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 (3 earlier review cycles)
  • reviewed 2026-09-18T19:54:50.929Z sha 9f66e22 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-18T20:02:33.977Z sha 9f66e22 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-18T20:46:51.943Z sha 2efab94b2b9a9fd8b2a9aef0fcd71904c3940054 :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as ready for review September 18, 2026 19:56
@clawsweeper clawsweeper Bot added 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 18, 2026
@steipete
steipete force-pushed the codex/guarded-stop-main branch from 2efab94 to f5af7b2 Compare September 18, 2026 21:09
@steipete
steipete merged commit 130c584 into main Sep 18, 2026
219 checks passed
@steipete
steipete deleted the codex/guarded-stop-main branch September 18, 2026 21:35
vincentkoc added a commit that referenced this pull request Sep 18, 2026
…n-20260918-v4

* origin/main: (81 commits)
  fix: retire failed setup plugins without replaying facade initialization (#152026)
  fix(test): select Node for built runtime recovery fixtures (#152162)
  refactor(auth): reuse privately assembled choice groups (#152166)
  fix: preserve chat media delivery and session boundaries (#152079)
  fix: keep stale Stop messages from canceling replacement sessions (#152116)
  improve(plugins): reduce mutable argument handling overhead (#152154)
  fix(scripts): prevent host tooling drift from blocking PR workflows (#152078)
  improve: reduce model capability preparation work (#152128)
  fix: stop marking delivered scheduled reports as failed (#152165)
  fix: start background context maintenance after durable turns (#151936)
  fix(models): avoid ambient state reads during prepared selection (#152119)
  feat: recover abandoned Crabbox source staging (#152006)
  chore(ui): refresh control ui locales (#152098)
  fix(ui): keep cloud startup prompts and progress in chat (#152024)
  fix: report completed subprocess cleanup after cancellation (#152107)
  perf(reply): reuse normalized inbound text (#152110)
  fix(cron): paused future one-shots disappear after Run now (#152126)
  perf(sessions): reuse rows and skip discarded terminal labels (#152109)
  fix(ui): keep keyboard-focused automation controls clear of sticky actions (#152135)
  fix(ui): load remote images in compact activity previews (#152045)
  ...
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 19, 2026
…enclaw#152116)

* fix(gateway): guard typed Stop at cancellation boundaries

* test(gateway): retain config in ended-parent abort fixture
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 P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary 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.

1 participant