Skip to content

fix(agents): cancel queued CLI work promptly - #169303

Merged
steipete merged 1 commit into
mainfrom
codex/cli-queued-cancel-20261011
Oct 11, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/cli-queued-cancel-20261011

Conversation

@steipete

@steipete steipete commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Cancelling CLI-backed work queued behind another turn now rejects promptly, while that earlier turn remains active.

User Impact

Cancelled work leaves the session queue immediately and never executes. Existing ordering and active-turn settlement stay intact; no configuration or migration is required.

Why This Change Was Made

The CLI admission owner checked cancellation at execution time but did not pass the caller's signal to the existing queue, so an aborted queued turn waited for its predecessor. Forward that signal instead of adding another cancellation mechanism.

Evidence

The strengthened existing queued-cancellation regression failed on the original code with one queued entry remaining after abort. After the one-line production repair, it verifies activeCount=1, queuedCount=0 and rejection before releasing the predecessor.

Focused admission, caller-scope and queue cancellation proof: 39/39 tests passed in 148.579 seconds wall time. The changed owner file took 27.70 seconds; the cancellation case took 7 milliseconds. Production delta: +1 line. Deslop retained only the necessary signal forwarding. Fresh independent Codex review through P2: scoped-clean. Hosted CI passed on this head, and the completed ClawSweeper review found no actionable defect. Exact-head CI run 38167004129 passed the source, production/test type, lint, guard and ratchet jobs and the enforced CI gate. The local changed check passed guards, ratchets, production types and twelve test type graphs, then was intentionally interrupted (exit 130, 1564.712 seconds wall) once the equivalent hosted gates completed; the full local command is not claimed as passed.

Related work

@changeroa previously identified the same queued-cancellation defect in #160804. This narrow prerequisite was independently reproduced and keeps the fix at the existing queue owner. That contributor PR also adds a distinct cron setup-watchdog lane-wait contract and remains relevant after this fix. Credit: Victor Jaepyo Jo.

@clawsweeper

clawsweeper Bot commented Oct 11, 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.

@steipete
steipete marked this pull request as ready for review October 11, 2026 19:12
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels Oct 11, 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: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 11, 2026
@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR forwards the caller’s abort signal to the existing session queue so cancelled CLI turns reject promptly.

Example: A turn for agent:main:fenced is queued behind an active turn and its caller cancels it.

  • Before: The cancelled turn remains queued and rejects only after the active turn releases the lane.
  • After: The queued turn is removed and rejects while the earlier turn remains active.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch appears correct and has meaningful owner-boundary regression coverage; current-head evidence stops short of a shipped-entry-point demonstration.
Proof confidence 🦐 gold shrimp (3/6) The ordinary contributor-proof gate does not apply to this maintainer-authored PR; support consists of the strengthened admission regression and CI, while the inspected historical continuity screenshot does not exercise this change.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Cancelling a queued CLI turn does not promptly settle it while an earlier session turn remains busy.
Reason: The maintainer-authored direction restores expected cancellation through the existing owner with a narrowly scoped production change.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR fixes a cancellation defect still present on current main, and no actionable patch defect was found.

Priority: P2
Reviewed head: 1fbadf8c54716faa41551383436fa23361432749

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No current-head shipped-entry-point trace demonstrates queued cancellation while its predecessor remains active.
Agent review details

How this fits together

CLI run entry points pass session identity and cancellation into placement admission, which serializes turns through the shared command queue before acquiring placement ownership.

flowchart TD
A[CLI run caller] --> B[Session placement admission]
B --> C[Shared session queue]
D[Caller abort signal] --> C
C --> E[Placement owner]
E --> F[CLI execution and settlement]
Loading

Technical review

Best possible solution:

Use the shared queue’s existing cancellation contract while preserving active-turn ownership and settlement.

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

Current-main source shows cancellation is checked only when the queued task runs; the contributor reports a failing-before and passing-after regression, which was inspected but not executed during this read-only review.

Is this the best way to solve the issue?

Signal forwarding repairs the missing connection at the shared admission owner and reuses established queue cleanup instead of adding competing cancellation machinery.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • CLI session-lane admission keeps the original intent (8b0cc70: Serialize direct CLI turns before placement claims, retain queued context, and reject cancelled or stale work before execution.)
  • CLI continuation and exact-owner settlement keeps the original intent (c103dbc: Settle native continuation before releasing same-session admission while preventing late owners from publishing stale state.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 8b0cc70 adds src/agents/session-placement-admission.ts:141 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 8b0cc701a028; files: src/agents/session-placement-admission.ts)
  • Dallin Romney: Raw commit c18456c adds src/agents/session-placement-admission.ts:322 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: c18456cce92e; files: src/agents/session-placement-admission.ts)

PR surface

Source +1, Tests +11. Total +12 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 1 0 +1
Tests 1 13 2 +11
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 14 2 +12

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Cancelled queued CLI turns can remain pending behind a long-running predecessor; this is a focused runtime correctness repair.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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 execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-11T19:17:33.270Z sha 1fbadf8 :: needs maintainer review before merge. :: none

Reviewed October 11, 2026, 3:29 PM ET / 19:29 UTC (Revision 2).

@steipete
steipete merged commit 9607478 into main Oct 11, 2026
209 of 210 checks passed
@steipete
steipete deleted the codex/cli-queued-cancel-20261011 branch October 11, 2026 19:40
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

RomneyDa pushed a commit that referenced this pull request Oct 12, 2026
Cancelling CLI work while it waits behind an active session turn previously left the caller blocked until the predecessor finished. Forward the caller's abort signal to the existing command queue so cancellation promptly removes and rejects the queued turn without executing it.

Strengthen the existing regression to await rejection before releasing the predecessor. The regression fails before the fix; all 39 focused owner, caller-scope and queue cancellation tests pass afterward.

Victor Jaepyo Jo (@changeroa) previously identified the same cancellation defect in #160804, which also contains distinct cron watchdog work. This narrow fix was independently reproduced.

Co-authored-by: Victor Jaepyo Jo <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
(cherry picked from commit 9607478)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 12, 2026
Cancelling CLI work while it waits behind an active session turn previously left the caller blocked until the predecessor finished. Forward the caller's abort signal to the existing command queue so cancellation promptly removes and rejects the queued turn without executing it.

Strengthen the existing regression to await rejection before releasing the predecessor. The regression fails before the fix; all 39 focused owner, caller-scope and queue cancellation tests pass afterward.

Victor Jaepyo Jo (@changeroa) previously identified the same cancellation defect in openclaw#160804, which also contains distinct cron watchdog work. This narrow fix was independently reproduced.

Co-authored-by: Victor Jaepyo Jo <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS 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