Skip to content

fix(skills): stop library list/read replies that land after Ctrl+C - #197281

Merged
obviyus merged 6 commits into
openclaw:mainfrom
wangmiao0668000666:fix/skills-library-abort
Nov 12, 2026
Merged

obviyus merged 6 commits into
openclaw:mainfrom
wangmiao0668000666:fix/skills-library-abort

Conversation

@wangmiao0668000666

@wangmiao0668000666 wangmiao0668000666 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

openclaw skills library list and openclaw skills library read wait on the Gateway
(skills.library.list / skills.library.read) and print the full reply even when the
command has been interrupted with Ctrl+C. When the Gateway reply lands during cleanup,
the CLI still shows the list or the skill contents after the user asked to stop.

The same shape was fixed today for openclaw gateway usage-cost and gateway stability
by #197019, and for nodes/models/devices/sessions-tail/status by the interrupt family
(#197110, #197174, #197185, #197038, #196976, #196655). These two skills-library read
commands were the remaining callers that did not pass the command abort signal.

Precedent: #197019 (same shape; this PR only changes the call site).

Why This Change Was Made

The read-only skills.library.list / skills.library.read calls in
src/cli/skills-library-cli.ts did not forward the CLI abort signal and did not check it
before printing. The shared execute helper now captures getAsyncWorkSignal() for
read-only commands, forwards it into the Gateway transport, and returns without printing
once the signal is aborted. Write commands (create/update/import/mutate/activate) keep
their receipts, matching the #197019 decision to leave write receipts intact.

No new validator, option, config surface, or persistence change. Non-interrupted reads
print exactly as before.

Production LOC is +30/-8 (net +22) in src/cli/skills-library-cli.ts.

Classification: behavior-completing

User Impact

Interrupting skills library list or skills library read no longer prints a result
after the reply lands during cleanup. Uninterrupted reads and all write commands behave
identically.

Evidence

Exact-head proof receipt

  • Product head SHA: bf83d0d0ed876ba8d2004ac527d955e47267137d
  • Current-main RED baseline: d3942b513282 (parent of HEAD; openclaw/openclaw main at verification time)
  • Canonical owner exercised: execute + callGatewayFromCliWithTransport in src/cli/skills-library-cli.ts
  • Decision surface: skills library list and skills library read read-only output
  • Recorder/readback boundary: defaultRuntime.writeJson / writeStdout call count
  • Acceptance RED: with the fix reverted, mocks.signal = AbortSignal.abort() still prints the reply (2 new Ctrl+C tests fail)
  • Acceptance GREEN: exact head skips printing when the signal is aborted (16/16 pass)

Discriminative regression (remote vitest, node v24.22.1)

src/cli/skills-library-cli.test.ts mocks getAsyncWorkSignal to return an aborted
signal and asserts the read-only commands make the Gateway call but do not print.

Run Result
BASE (fix reverted) prints no read reply that lands after Ctrl+C (list) and (read) FAIL (reply printed)
HEAD 16 passed (includes the two new Ctrl+C tests)
node_modules/.bin/vitest run --config test/vitest/vitest.cli.config.ts skills-library-cli.test.ts --maxWorkers=1

Verification

  • src/cli/skills-library-cli.test.ts — 16 passed on HEAD; the two new Ctrl+C tests red on BASE
  • git diff --check clean
  • Not tested: real Gateway round-trip with a real signed-in profile (needs credentials and a live Gateway); the discrimination is at the CLI transport boundary where the abort decision is made.

Scope and risk

  • Production LOC: +30/-8 (net +22), one file
  • Test LOC: +18 (one file)
  • Existing-solutions preflight: reuses getAsyncWorkSignal() and the existing extra.signal transport hook already used by health/usage-cost/stability (fix(cli): gateway usage-cost and stability print nothing after Ctrl+C #197019); no new abstraction
  • Config/default, protocol/schema, authorization, storage, migration, upgrade impact: none

Shipped real-behavior proof (PTTY synthetic Gateway)

ClawSweeper's "needs real behavior proof" gate requires shipped-CLI evidence of SIGINT
propagation and transport teardown. This proof uses a synthetic Gateway peer (Node.js
ws WebSocketServer, same recipe as Alix's #197110 proof) that completes the Gateway
connect handshake, advertises features.methods=["skills.library.list"], holds the
target method response for 60s, and emits a read-held event. A PTY collector
(sigint_collect.py) launches the shipped CLI binary (node dist/entry.js skills library list --json), waits for read-held, sends Ctrl+C, and records exit code,
time-to-exit, and stdout.

Discriminator: BASE (fix reverted) hangs ~2040ms after Ctrl+C then gets emergency
SIGKILL (exit -9) — the signal never reaches the transport. HEAD (with fix) exits 130 in
<200ms with stdout containing only ^C (no late rendering).

Variant Exit code SIGINT→exit Late rendering
BASE (fix reverted) -9 (SIGKILL) 2035.4 ms N/A (killed)
HEAD (with fix) 130 (SIGINT) 111.8 ms none — stdout = ^C only

Uninterrupted control: same command without Ctrl+C completes normally and prints the
full skills library JSON.

Method: synthetic peer on localhost:18999, shipped CLI from dist/entry.js,
--url ws://127.0.0.1:18999, PTY via pty.fork, Ctrl+C sent after read-held event.
The synthetic peer is structurally identical to the real Gateway handshake (challenge →
connect → features.methods → method response hold) and exercises the exact
callGatewayFromCliWithTransport code path that the fix modifies.

Skills library list and read wait on the Gateway and print the full reply
even when the command has been interrupted; a reply that lands during
cleanup is still shown. Pass the command abort signal into the read-only
Gateway call and skip printing once the signal is aborted, matching the
interrupt handling already used by gateway usage-cost and stability.
@clawsweeper

clawsweeper Bot commented Nov 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.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: S labels Nov 11, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 11, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 11, 2026
@clawsweeper

clawsweeper Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Forward command cancellation to skills-library list/read requests and suppress results or errors that settle after interruption.

Example: Press Ctrl+C during openclaw skills library list --json while the Gateway reply is delayed by one second.

  • Before: The full library JSON prints after the interrupt notice.
  • After: The command exits with code 130 without printing the delayed result.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused repair with discriminating product proof, a real-scope regression, preserved mutation behavior, and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Current-head collaborator output exercises the built CLI and real Gateway through a fault-injecting WebSocket proxy, proving delayed-result suppression and transport teardown for list/read under SIGINT/SIGTERM, with uninterrupted and mutation controls.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Library results can appear after Ctrl+C, and pending reads can delay command termination.
Reason: This restores established CLI cancellation behavior, and the collaborator explicitly supports the direction and verifies the current head.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current-main cancellation bug with sufficient current-head product proof and no actionable findings; hosted CI is still running.

Priority: P2
Reviewed head: a95cfd8b987c0405d3a8aaa2f93d7c3b70314c2e

Before merge

None.

Findings

None.

Agent review details

How this fits together

The skills-library CLI sends authenticated Gateway requests and renders their responses; the existing command work scope supplies cancellation to the transport and output boundary.

flowchart LR
  A[CLI command] --> B[Library execute helper]
  C[Command work scope] --> B
  B --> D[Gateway RPC transport]
  D --> E[Gateway library service]
  E --> B
  B --> F[Terminal output]
Loading

Technical review

Best possible solution:

Land the existing focused fix after the required current-head checks pass.

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

Current-main source exposes the missing signal and output guard, corroborated by the collaborator's before/after real-Gateway trace; no target code was executed during this review.

Is this the best way to solve the issue?

The smallest complete fix uses the existing executor, command work scope, and transport signal, with settlement guards covering both resolved results and rejected requests.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Library request execution and rendering changes intended behavior with a stated reason (75bcd26: Personal libraries provide owner-aware remote management and exact session pins; the original executor rendered settled responses without command cancellation.)
  • Existing CLI regression suite keeps the original intent (test(ui,cli,browser,cron): remove low-value tests (batch d071) #170246: The prior test audit removed redundant permutations while retaining distinct contracts; this change folds one cancellation regression into the retained suite without net test-line growth.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +23, Tests 0. Total +23 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 31 8 +23
Tests 1 11 11 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 42 19 +23

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label 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:

  • P2: Interrupted library reads can print unwanted results or linger during cleanup, with limited impact on an advanced CLI workflow.
  • 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.

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 (4 earlier review cycles)
  • reviewed 2026-11-11T16:40:53.807Z sha 3bb9bbe :: needs real behavior proof before merge. :: [P2] Suppress aborted request rejections before failure rendering
  • reviewed 2026-11-12T03:04:55.555Z sha bdae086 :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-12T03:35:56.221Z sha bdae086 :: needs maintainer review before merge. :: none
  • reviewed 2026-11-12T03:47:35.171Z sha bdae086 :: needs maintainer review before merge. :: none

Reviewed November 11, 2026, 11:49 PM ET / November 12, 2026, 04:49 UTC (Revision 5).

wangmiao0668000666 and others added 2 commits November 12, 2026 01:05
…y reads

Catching the cancellation rejection keeps an interrupted list/read from
rendering failure output after Ctrl+C; the pending call rejects with
"gateway request aborted" before the output guard would suppress it.

Co-Authored-By: nebulacoder-v8.0 <[email protected]>
@clawsweeper clawsweeper Bot removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Nov 11, 2026
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 12, 2026
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

Proof for head bdae086.

Method: synthetic Gateway peer (Node.js ws WebSocketServer, same recipe as Alix's #197110 proof) completes the connect handshake, advertises features.methods=["skills.library.list"], holds the target method response for 60s, and emits a read-held event. A PTY collector launches the shipped CLI binary (node dist/entry.js skills library list --json), waits for read-held, sends Ctrl+C, and records exit code / time-to-exit / stdout.

Discriminator:

  • BASE (fix reverted): Ctrl+C leaves the command hanging ~2040ms until the emergency SIGKILL fires (exit -9). The signal never reaches the transport.
  • HEAD (with fix): Ctrl+C exits 130 in ~112ms with stdout = ^C only (no late rendering).

Uninterrupted control: same command without Ctrl+C completes normally and prints the full skills library JSON.

@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 12, 2026
@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 clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 12, 2026
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 12, 2026
@obviyus

obviyus commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus

obviyus commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

Thanks @wangmiao0668000666 for this fix. I merged main, removed the test-line allocation file, and folded the regression into the existing session-projection test (test lines net 0). It uses a real AsyncWorkScope that closes while skills library read is in flight, and fails on main. The production change is yours, with one comment shortened.

Proof on head a95cfd8 (main 3978ab104ee6). Built CLI in a real PTY in a secretless node:24.22.1 container, against a real built Gateway behind a WebSocket proxy. The proxy either delays the skills.library.list / skills.library.read reply by 1 s (so it lands after Ctrl+C) or withholds it. Two runs each; run 2 matched run 1.

Case main this PR
list --json, Ctrl+C, reply lands 1 s later exit 130 after 0.65-0.76 s, the full list JSON prints after the interrupt notice exit 130 after 0.03-0.04 s, nothing after the notice
read <id> --json, Ctrl+C, reply lands 1 s later exit 130 after 0.63-0.91 s, the full skill JSON prints exit 130 after 0.03-0.04 s, nothing printed
list --json, Ctrl+C, reply withheld force-killed 2.02-2.05 s later exit 130 after 0.03-0.04 s
read <id> --json, SIGTERM, reply withheld force-killed 2.05-2.16 s later exit 143 after 0.04-0.08 s
plain list / read, Ctrl+C spinner shows Canceled, exit 0 same

Controls: uninterrupted list and read, plain and --json, are byte-identical on both builds once generated ids and timestamps are normalized. skills library create (a mutation, not given the signal) succeeds on both. No CLI processes were left over.

Excerpt (run 1):

[main-1] list-json-ctrl-c-late-reply: output after ctrl-c: '^CCommand interrupted by SIGINT. Waiting for cleanup before exiting.\n{\n  "multipleProfiles": false,\n  "defaultTarget": "personal",\n  "canManageWorkspace": false,\n  "
[main-1] read-json-ctrl-c-late-reply: output after ctrl-c: '^CCommand interrupted by SIGINT. Waiting for cleanup before exiting.\n{\n  "entry": {\n    "skillId": "f455735f-af7b-4b98-89b0-b0ffca52b3e5",\n    "slug": "checklist",\n 
[main-1] list-json-ctrl-c-held: exit=-9 2.02s after ctrl-c
[main-1] read-json-sigterm-held: exit=-9 2.16s after sigterm
[cand-1] list-json-ctrl-c-late-reply: output after ctrl-c: '^CCommand interrupted by SIGINT. Waiting for cleanup before exiting.'
[cand-1] read-json-ctrl-c-late-reply: output after ctrl-c: '^CCommand interrupted by SIGINT. Waiting for cleanup before exiting.'
[cand-1] list-json-ctrl-c-held: exit=130 0.03s after ctrl-c
[cand-1] read-json-sigterm-held: exit=143 0.04s after sigterm

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. 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. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 12, 2026
@obviyus
obviyus merged commit dbef153 into openclaw:main Nov 12, 2026
112 checks passed
@obviyus

obviyus commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

Landed in dbef153. Thanks @wangmiao0668000666.

@wangmiao0668000666
wangmiao0668000666 deleted the fix/skills-library-abort branch November 12, 2026 06:19
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 13, 2026
…penclaw#197281)

fix(skills): stop skills library list and read promptly on Ctrl+C

openclaw skills library list and read did not pass the command's abort signal to their Gateway reads, so after Ctrl+C or SIGTERM they kept waiting and printed the list or the skill contents when the reply arrived during cleanup, or waited until the launcher force-killed them about 2 seconds later. Both reads now receive the existing abort signal and print nothing once interrupted. Mutating subcommands are unchanged. No text changes.

Evidence: the built CLI in a real PTY against a real built Gateway behind a WebSocket proxy that delays or withholds the reply, two runs each. On main, list --json and read --json printed the full JSON after the interrupt notice when the reply arrived 1 s after Ctrl+C, and were force-killed about 2 s later when it never arrived; with this change they exit 130 within 0.03-0.04 s with nothing printed, and SIGTERM exits 143. Plain list and read, where the spinner already cancels, uninterrupted output and skills library create behave the same on both. The session-projection regression fails on main, at net 0 test lines. Details: openclaw#197281 (comment).

Thanks @wangmiao0668000666.

Co-authored-by: Ayaan Zaidi <[email protected]>
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

Thanks for merging this! Appreciate the review and the help landing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S 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.

2 participants