Skip to content

fix(cli): gateway usage-cost and stability print nothing after Ctrl+C - #197019

Merged
obviyus merged 4 commits into
mainfrom
fix/usage-cost-sigint
Nov 11, 2026
Merged

obviyus merged 4 commits into
mainfrom
fix/usage-cost-sigint

Conversation

@obviyus

@obviyus obviyus commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #197005. Thanks @GoldArowana for the report.

Problem

If you press Ctrl+C while openclaw gateway usage-cost --json is waiting on the Gateway, and the reply lands during cleanup, the CLI still prints the full JSON result. gateway stability behaves the same way. (gateway call does too, but it can run write methods, so its receipt is left as is here.) gateway health already handles this: it passes the command's abort signal and prints nothing once it has been aborted.

Fix

usage-cost and stability now use the same pattern as health. They pass the abort signal to the Gateway call and return without printing if the command was aborted. The shared helper is in src/cli/gateway-cli/register.ts. No new text.

Proof

Built CLI and built Gateway on node 24.22.1 in a secretless Docker container, run in a real PTY. A small WS proxy in front of the real Gateway holds the real usage.cost / diagnostics.stability reply for 1.5 s. Ctrl+C goes through the terminal once the request is pending. I ran main twice and the candidate twice.

Run main candidate
usage-cost --json, Ctrl+C full JSON printed stdout empty
call usage.cost --json, Ctrl+C full JSON printed unchanged (left out on purpose)
stability --json, Ctrl+C full JSON printed stdout empty
usage-cost (text), Ctrl+C summary printed banner only
usage-cost --json, no Ctrl+C JSON identical JSON (ignoring updatedAt)
usage-cost (text), no Ctrl+C summary same summary
health --json / health OK unchanged

Every interrupted run printed the existing "Command interrupted by SIGINT" line on stderr. In this setup, both main and the candidate exited 0 after Ctrl+C, not the 130 the issue reports. This PR does not touch exit codes.

Regression: src/cli/gateway-cli.coverage.test.ts sends a reply after Ctrl+C. It fails on main and passes here. Focused tests: src/cli/gateway-cli.coverage.test.ts and src/cli/gateway-cli/register.option-collisions.test.ts pass (45 tests). oxfmt and oxlint are clean.

@obviyus

obviyus commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator Author
[main-run1/usage-json-sigint] Ctrl+C sent at 1.10s (request pending)
[main-run1/usage-json-sigint] exit=0 rawstatus=0 elapsed=2.62s stdout_bytes=9782
[main-run1/usage-json-sigint] stderr: 'Command interrupted by SIGINT. Waiting for cleanup before exiting.\n'
[main-run1/usage-json-plain] exit=0 rawstatus=0 elapsed=2.35s stdout_bytes=9782
[main-run1/usage-json-plain] stderr: ''
[main-run1/usage-text-plain] exit=0 rawstatus=0 elapsed=2.39s stdout_bytes=181
[main-run1/usage-text-plain] stdout: '\r\nOpenClaw 2026.11.3 (unknown)\r\nRuns on a Raspberry Pi. Dreams of a rack in Iceland.\r\n\r\nUsage cost (30 days)\r\nTotal: $0.00
[main-run1/usage-text-plain] stderr: ''
[main-run1/usage-text-sigint] Ctrl+C sent at 0.99s (request pending)
[main-run1/usage-text-sigint] exit=0 rawstatus=0 elapsed=2.22s stdout_bytes=267
[main-run1/usage-text-sigint] stdout: "\r\nOpenClaw 2026.11.3 (unknown)\r\nI'll butter your workflow like a lobster roll: messy, delicious, effective.\r\n\r\nUsage cost (
[main-run1/usage-text-sigint] stderr: 'Command interrupted by SIGINT. Waiting for cleanup before exiting.\n'
[main-run1/call-json-sigint] Ctrl+C sent at 1.01s (request pending)
[main-run1/call-json-sigint] exit=0 rawstatus=0 elapsed=2.37s stdout_bytes=9782
[main-run1/call-json-sigint] stderr: 'Command interrupted by SIGINT. Waiting for cleanup before exiting.\n'
[main-run1/stability-json-sigint] Ctrl+C sent at 1.11s (request pending)
[main-run1/stability-json-sigint] exit=0 rawstatus=0 elapsed=2.16s stdout_bytes=5604
[main-run1/stability-json-sigint] stderr: 'Command interrupted by SIGINT. Waiting for cleanup before exiting.\n'
[main-run1/health-json] exit=0 rawstatus=0 elapsed=0.90s stdout_bytes=1962
[main-run1/health-json] stderr: ''
[main-run1/health-text] exit=0 rawstatus=0 elapsed=0.82s stdout_bytes=114
[main-run1/health-text] stdout: "\r\nOpenClaw 2026.11.3 (unknown)\r\nRan git blame like you asked. It's you. It's always you.\r\n\r\nGateway Health\r\nOK (1ms)\r\n"
[main-run1/health-text] stderr: ''
[main-run2/usage-json-sigint] Ctrl+C sent at 1.86s (request pending)
[main-run2/usage-json-sigint] exit=0 rawstatus=0 elapsed=3.56s stdout_bytes=9782
[main-run2/usage-json-sigint] stderr: 'Command interrupted by SIGINT. Waiting for cleanup before exiting.\n'
[main-run2/usage-json-plain] exit=0 rawstatus=0 elapsed=2.24s stdout_bytes=9782
[main-run2/usage-json-plain] stderr: ''
[main-run2/usage-text-plain] exit=0 rawstatus=0 elapsed=2.61s stdout_bytes=183
[main-run2/usage-text-plain] stdout: '\r\nOpenClaw 2026.11.3 (unknown)\r\n47 tabs open and not one of them is the documentation.\r\n\r\nUsage cost (30 days)\r\nTotal: $0.
[main-run2/usage-text-plain] stderr: ''
[main-run2/usage-text-sigint] Ctrl+C sent at 1.00s (request pending)
[main-run2/usage-text-sigint] exit=0 rawstatus=0 elapsed=2.40s stdout_bytes=267
[main-run2/usage-text-sigint] stdout: '\r\nOpenClaw 2026.11.3 (unknown)\r\nWelcome to the command line: where dreams compile and confidence segfaults.\r\n\r\nUsage cost (
[main-run2/usage-text-sigint] stderr: 'Command interrupted by SIGINT. Waiting for cleanup before exiting.\n'
[main-run2/call-json-sigint] Ctrl+C sent at 1.37s (request pending)
[main-run2/call-json-sigint] exit=0 rawstatus=0 elapsed=2.65s stdout_bytes=9782
[main-run2/call-json-sigint] stderr: 'Command interrupted by SIGINT. Waiting for cleanup before exiting.\n'
[main-run2/stability-json-sigint] Ctrl+C sent at 1.46s (request pending)
[main-run2/stability-json-sigint] exit=0 rawstatus=0 elapsed=2.58s stdout_bytes=5602
[main-run2/stability-json-sigint] stderr: 'Command interrupted by SIGINT. Waiting for cleanup before exiting.\n'
[main-run2/health-json] exit=0 rawstatus=0 elapsed=0.98s stdout_bytes=1972
[main-run2/health-json] stderr: ''
[main-run2/health-text] exit=0 rawstatus=0 elapsed=0.80s stdout_bytes=103
[main-run2/health-text] stdout: '\r\nOpenClaw 2026.11.3 (unknown)\r\nTechnically a daemon, spiritually a familiar.\r\n\r\nGateway Health\r\nOK (1ms)\r\n'
[main-run2/health-text] stderr: ''
[cand-run1/usage-json-sigint] Ctrl+C sent at 0.99s (request pending)
[cand-run1/usage-json-sigint] exit=0 rawstatus=0 elapsed=1.02s stdout_bytes=0
[cand-run1/usage-json-sigint] stdout: ''
[cand-run1/usage-json-sigint] stderr: 'Command interrupted by SIGINT. Waiting for cleanup before exiting.\n'
[cand-run1/usage-json-plain] exit=0 rawstatus=0 elapsed=2.24s stdout_bytes=9782
[cand-run1/usage-json-plain] stderr: ''
[cand-run1/usage-text-plain] exit=0 rawstatus=0 elapsed=2.21s stdout_bytes=192
[cand-run1/usage-text-plain] stdout: "\r\nOpenClaw 2026.11.3 (unknown)\r\nSomewhere between 'hello world' and 'oh god what have I built.'\r\n\r\nUsage cost (30 days)\r\nT
[cand-run1/usage-text-plain] stderr: ''
[cand-run1/usage-text-sigint] Ctrl+C sent at 1.02s (request pending)
[cand-run1/usage-text-sigint] exit=0 rawstatus=0 elapsed=1.05s stdout_bytes=167
[cand-run1/usage-text-sigint] stdout: '\r\nOpenClaw 2026.11.3 (unknown)\r\nThe only open-source project where the mascot could eat the competition.\r\n\r\n\x1b[0m\x1b[?25
[cand-run1/usage-text-sigint] stderr: 'Command interrupted by SIGINT. Waiting for cleanup before exiting.\n'
[cand-run1/call-json-sigint] Ctrl+C sent at 0.87s (request pending)
[cand-run1/call-json-sigint] exit=0 rawstatus=0 elapsed=0.91s stdout_bytes=0
[cand-run1/call-json-sigint] stdout: ''
[cand-run1/call-json-sigint] stderr: 'Command interrupted by SIGINT. Waiting for cleanup before exiting.\n'
[cand-run1/stability-json-sigint] Ctrl+C sent at 1.02s (request pending)
[cand-run1/stability-json-sigint] exit=0 rawstatus=0 elapsed=1.05s stdout_bytes=0
[cand-run1/stability-json-sigint] stdout: ''
[cand-run1/stability-json-sigint] stderr: 'Command interrupted by SIGINT. Waiting for cleanup before exiting.\n'
[cand-run1/health-json] exit=0 rawstatus=0 elapsed=0.79s stdout_bytes=1972
[cand-run1/health-json] stderr: ''
[cand-run1/health-text] exit=0 rawstatus=0 elapsed=0.81s stdout_bytes=130
[cand-run1/health-text] stdout: '\r\nOpenClaw 2026.11.3 (unknown)\r\nRunning on your hardware, reading your logs, judging nothing (mostly).\r\n\r\nGateway Health\r\nOK (1
[cand-run1/health-text] stderr: ''
[cand-run2/usage-json-sigint] Ctrl+C sent at 1.07s (request pending)
[cand-run2/usage-json-sigint] exit=0 rawstatus=0 elapsed=1.11s stdout_bytes=0
[cand-run2/usage-json-sigint] stdout: ''
[cand-run2/usage-json-sigint] stderr: 'Command interrupted by SIGINT. Waiting for cleanup before exiting.\n'
[cand-run2/usage-json-plain] exit=0 rawstatus=0 elapsed=2.17s stdout_bytes=9782
[cand-run2/usage-json-plain] stderr: ''
[cand-run2/usage-text-plain] exit=0 rawstatus=0 elapsed=2.27s stdout_bytes=173
[cand-run2/usage-text-plain] stdout: "\r\nOpenClaw 2026.11.3 (unknown)\r\nYour mom texts me now. We're good, actually.\r\n\r\nUsage cost (30 days)\r\nTotal: $0.0000 · 0 
[cand-run2/usage-text-plain] stderr: ''
[cand-run2/usage-text-sigint] Ctrl+C sent at 1.28s (request pending)
[cand-run2/usage-text-sigint] exit=0 rawstatus=0 elapsed=1.33s stdout_bytes=168
[cand-run2/usage-text-sigint] stdout: '\r\nOpenClaw 2026.11.3 (unknown)\r\nReading the error message remains undefeated. You should try it sometime.\r\n\r\n\x1b[0m\x1b[?2
[cand-run2/usage-text-sigint] stderr: 'Command interrupted by SIGINT. Waiting for cleanup before exiting.\n'
[cand-run2/call-json-sigint] Ctrl+C sent at 1.23s (request pending)
[cand-run2/call-json-sigint] exit=0 rawstatus=0 elapsed=1.28s stdout_bytes=0
[cand-run2/call-json-sigint] stdout: ''
[cand-run2/call-json-sigint] stderr: 'Command interrupted by SIGINT. Waiting for cleanup before exiting.\n'
[cand-run2/stability-json-sigint] Ctrl+C sent at 1.01s (request pending)
[cand-run2/stability-json-sigint] exit=0 rawstatus=0 elapsed=1.08s stdout_bytes=0
[cand-run2/stability-json-sigint] stdout: ''
[cand-run2/stability-json-sigint] stderr: 'Command interrupted by SIGINT. Waiting for cleanup before exiting.\n'
[cand-run2/health-json] exit=0 rawstatus=0 elapsed=0.77s stdout_bytes=1966
[cand-run2/health-json] stderr: ''
[cand-run2/health-text] exit=0 rawstatus=0 elapsed=0.93s stdout_bytes=134
[cand-run2/health-text] stdout: '\r\nOpenClaw 2026.11.3 (unknown)\r\nReachable via WhatsApp, Telegram, Signal, iMessage, and sheer force of will.\r\n\r\nGateway Health\r\
[cand-run2/health-text] stderr: ''

proxy (main-run1):
2026-11-11T03:56:22.845Z proxy listening 18790 -> 18789
2026-11-11T03:56:24.626Z proxy usage.cost request id=2:b0e30cdc-cb7e-4d2a-bc7c-fe5cbb70ac5a
2026-11-11T03:56:24.969Z proxy real usage.cost response received; holding 1500ms
2026-11-11T03:56:26.488Z proxy held usage.cost response delivered
2026-11-11T03:56:26.490Z proxy client closed
2026-11-11T03:56:30.287Z proxy usage.cost request id=2:6a0f69b5-93ac-4200-bc04-273c3dbaff21
2026-11-11T03:56:30.288Z proxy real usage.cost response received; holding 1500ms
2026-11-11T03:56:31.875Z proxy held usage.cost response delivered
proxy (cand-run1):
2026-11-11T04:02:48.246Z proxy listening 18790 -> 18789
2026-11-11T04:02:49.957Z proxy usage.cost request id=2:f0610f46-48a0-40c8-9166-59aeed2ddffe
2026-11-11T04:02:50.250Z proxy real usage.cost response received; holding 1500ms
2026-11-11T04:02:50.301Z proxy client closed
2026-11-11T04:02:51.762Z proxy client gone before held response was delivered
2026-11-11T04:02:54.011Z proxy usage.cost request id=2:a9571d91-8473-4e49-b6d6-84a09fae3c22
2026-11-11T04:02:54.012Z proxy real usage.cost response received; holding 1500ms
2026-11-11T04:02:55.662Z proxy held usage.cost response delivered

@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.

@obviyus

obviyus commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@openclaw-barnacle openclaw-barnacle Bot added the cli CLI command changes label Nov 11, 2026
@clawsweeper

clawsweeper Bot commented Nov 11, 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. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 clawsweeper:intake:bug 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

This PR cancels interrupted usage-cost and live stability reads and suppresses their late results.

Example: Press Ctrl+C while openclaw gateway usage-cost --json awaits a delayed usage.cost response.

  • Before: The interrupted command prints the completed JSON result.
  • After: The pending connection closes and no result JSON is printed.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused repair with production-entry-point cancellation proof, committed regression coverage, and the previous receipt regression removed.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): Built CLI and Gateway runs in a secretless Docker PTY exercise delayed real usage.cost and diagnostics.stability responses through a WebSocket proxy; SIGINT closes the connection and suppresses result JSON, while uninterrupted controls retain their output. Later diagnostic production code is unchanged by the generic-call restoration. Independent reporter evidence also covers cancellation during connection cleanup and genuine RPC errors.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Cancelled diagnostic reads can still print successful results after Ctrl+C.
Reason: The maintainer-authored repair follows the existing dedicated health-read contract without changing options, normal output, exit-code handling, or mutation receipts.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current cancellation bug and resolves the prior mutation-receipt finding; no actionable code findings remain.

Priority: P2
Reviewed head: 4a51bb46ee9af73aa9b49fdda3ac95e01cb5f7ed

Before merge

None.

Findings

None.

Agent review details

How this fits together

Gateway CLI actions translate command options into WebSocket RPC requests and render their responses; invocation cleanup supplies the cancellation signal.

flowchart LR
  A[CLI command] --> B[Diagnostic read action]
  C[Invocation cancellation] --> B
  B --> D[Gateway RPC transport]
  D --> E[Gateway read handler]
  E --> F[Response rendering]
  C --> F
Loading

Technical review

Best possible solution:

Use the existing invocation signal for dedicated diagnostic reads while retaining generic Gateway write receipts.

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

Current-main source confirms the missing signal and unconditional output, supported by the contributor's real CLI/Gateway traces and GoldArowana's independent signal-ordering reproduction; this review executed no target code.

Is this the best way to solve the issue?

The focused helper reuses existing cancellation and transport owners, checks both rejected and successfully settled requests, and avoids changing write-capable generic calls.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Gateway RPC actions and output changes intended behavior with a stated reason (fd3914e: The CLI consolidation preserved command output, errors, defaults, and lifecycle boundaries; the PR explains its narrow correction to interrupted diagnostic output.)
  • Shared result presentation keeps the original intent (4bf68b9: Equivalent output paths were consolidated without intended behavior changes; this PR retains that renderer and uninterrupted result shapes.)
  • Dedicated read cancellation keeps the original intent (401a1de: Health reads were made interruptible while generic Gateway actions and mutation receipts retained their existing behavior.)
  • CLI regression coverage keeps the original intent (4963191: Earlier test cleanup removed low-value setup and assertions; this PR replaces route-echo coverage with observable cancellation-output assertions.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 0e17e55 adds src/cli/gateway-cli/register.ts:202 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 0e17e55be902; files: src/cli/gateway-cli/register.ts)
  • Alix-007: Raw commit 401a1de adds src/cli/gateway-cli/register.ts:353 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 401a1de38b9a; files: src/cli/gateway-cli/register.ts)
  • Gustavo Madeira Santana: Raw commit 28818f9 adds src/cli/gateway-cli.coverage.test.ts:199 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 28818f914074; files: src/cli/gateway-cli.coverage.test.ts)

PR surface

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

View PR surface stats
Area Files Added Removed Net
Source 1 30 5 +25
Tests 1 14 16 -2
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 44 21 +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.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove merge-risk: 🚨 compatibility: Current PR review selected no merge-risk labels.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Interrupted diagnostic commands can publish misleading success output, with limited impact and no demonstrated state loss.
  • 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 (3 earlier review cycles)
  • reviewed 2026-11-11T04:10:14.969Z sha 93adc76 :: needs changes before merge. :: [P2] Check cancellation after a successful RPC returns
  • reviewed 2026-11-11T04:29:20.473Z sha e913431 :: needs changes before merge. :: [P2] Commit the requested cancellation regression
  • reviewed 2026-11-11T04:48:42.904Z sha fe4e68a :: needs changes before merge. :: [P2] Preserve receipts for generic Gateway write calls

Reviewed November 11, 2026, 12:00 AM ET / 05:00 UTC (Revision 4).

@obviyus

obviyus commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator Author

Candidate re-proof on e913431 (abort also checked after a successful reply), two runs:

[cand-run1/usage-json-sigint] Ctrl+C sent at 1.43s (request pending)
[cand-run1/usage-json-sigint] exit=0 rawstatus=0 elapsed=1.47s stdout_bytes=0
[cand-run1/usage-json-sigint] stdout: ''
[cand-run1/usage-json-sigint] stderr: 'Command interrupted by SIGINT. Waiting for cleanup before exiting.\n'
[cand-run1/usage-json-plain] exit=0 rawstatus=0 elapsed=2.83s stdout_bytes=9782
[cand-run1/usage-json-plain] stderr: ''
[cand-run1/usage-text-plain] exit=0 rawstatus=0 elapsed=2.57s stdout_bytes=168
[cand-run1/usage-text-plain] stdout: "\r\nOpenClaw 2026.11.3 (unknown)\r\nYou had me at 'openclaw gateway start.'\r\n\r\nUsage cost (30 days)\r\nTotal: $0.0000 · 0 token
[cand-run1/usage-text-plain] stderr: ''
[cand-run1/usage-text-sigint] Ctrl+C sent at 1.72s (request pending)
[cand-run1/usage-text-sigint] exit=0 rawstatus=0 elapsed=1.75s stdout_bytes=171
[cand-run1/usage-text-sigint] stdout: '\r\nOpenClaw 2026.11.3 (unknown)\r\nReachable via WhatsApp, Telegram, Signal, iMessage, and sheer force of will.\r\n\r\n\x1b[0m\x1b
[cand-run1/usage-text-sigint] stderr: 'Command interrupted by SIGINT. Waiting for cleanup before exiting.\n'
[cand-run1/call-json-sigint] Ctrl+C sent at 1.58s (request pending)
[cand-run1/call-json-sigint] exit=0 rawstatus=0 elapsed=1.63s stdout_bytes=0
[cand-run1/call-json-sigint] stdout: ''
[cand-run1/call-json-sigint] stderr: 'Command interrupted by SIGINT. Waiting for cleanup before exiting.\n'
[cand-run1/stability-json-sigint] Ctrl+C sent at 1.69s (request pending)
[cand-run1/stability-json-sigint] exit=0 rawstatus=0 elapsed=1.82s stdout_bytes=0
[cand-run1/stability-json-sigint] stdout: ''
[cand-run1/stability-json-sigint] stderr: 'Command interrupted by SIGINT. Waiting for cleanup before exiting.\n'
[cand-run1/health-json] exit=0 rawstatus=0 elapsed=1.14s stdout_bytes=1971
[cand-run1/health-json] stderr: ''
[cand-run1/health-text] exit=0 rawstatus=0 elapsed=1.03s stdout_bytes=134
[cand-run1/health-text] stdout: "\r\nOpenClaw 2026.11.3 (unknown)\r\nI'm not trapped in this container with you—you're trapped in here with me.\r\n\r\nGateway Health\r\
[cand-run1/health-text] stderr: ''
[cand-run2/usage-json-sigint] Ctrl+C sent at 3.47s (request pending)
[cand-run2/usage-json-sigint] exit=0 rawstatus=0 elapsed=3.53s stdout_bytes=0
[cand-run2/usage-json-sigint] stdout: ''
[cand-run2/usage-json-sigint] stderr: 'Command interrupted by SIGINT. Waiting for cleanup before exiting.\n'
[cand-run2/usage-json-plain] exit=0 rawstatus=0 elapsed=5.36s stdout_bytes=9782
[cand-run2/usage-json-plain] stderr: ''
[cand-run2/usage-text-plain] exit=0 rawstatus=0 elapsed=6.18s stdout_bytes=201
[cand-run2/usage-text-plain] stdout: '\r\nOpenClaw 2026.11.3 (unknown)\r\nI run on caffeine, JSON5, and the audacity of "it worked on my machine."\r\n\r\nUsage cost (30 d
[cand-run2/usage-text-plain] stderr: ''
[cand-run2/usage-text-sigint] Ctrl+C sent at 3.95s (request pending)
[cand-run2/usage-text-sigint] exit=0 rawstatus=0 elapsed=4.64s stdout_bytes=178
[cand-run2/usage-text-sigint] stdout: "\r\nOpenClaw 2026.11.3 (unknown)\r\nI'm not saying your workflow is chaotic... I'm just bringing a linter and a helmet.\r\n\r\n\x1b
[cand-run2/usage-text-sigint] stderr: 'Command interrupted by SIGINT. Waiting for cleanup before exiting.\n'
[cand-run2/call-json-sigint] Ctrl+C sent at 3.45s (request pending)
[cand-run2/call-json-sigint] exit=0 rawstatus=0 elapsed=3.87s stdout_bytes=0
[cand-run2/call-json-sigint] stdout: ''
[cand-run2/call-json-sigint] stderr: 'Command interrupted by SIGINT. Waiting for cleanup before exiting.\n'
[cand-run2/stability-json-sigint] Ctrl+C sent at 3.45s (request pending)
[cand-run2/stability-json-sigint] exit=0 rawstatus=0 elapsed=3.59s stdout_bytes=0
[cand-run2/stability-json-sigint] stdout: ''
[cand-run2/stability-json-sigint] stderr: 'Command interrupted by SIGINT. Waiting for cleanup before exiting.\n'
[cand-run2/health-json] exit=0 rawstatus=0 elapsed=4.58s stdout_bytes=1971
[cand-run2/health-json] stderr: ''
[cand-run2/health-text] exit=0 rawstatus=0 elapsed=5.89s stdout_bytes=127
[cand-run2/health-text] stdout: '\r\nOpenClaw 2026.11.3 (unknown)\r\nMEMORY.md: where I keep the receipts on every "temporary workaround."\r\n\r\nGateway Health\r\nOK (1m
[cand-run2/health-text] stderr: ''

@obviyus

obviyus commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 11, 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 11, 2026
@obviyus

obviyus commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator Author

Committed regression in src/cli/gateway-cli.coverage.test.ts (Ctrl+C before the reply lands, for usage-cost, call and stability): it fails 3/3 on main and passes 23/23 on this head. Net test lines: -1 (I replaced the probe and stability route-echo tests; the new rows still check the stability params).

@obviyus

obviyus commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 11, 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. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Nov 11, 2026
@clawsweeper clawsweeper Bot removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 11, 2026
@obviyus obviyus changed the title fix(cli): gateway usage-cost, call and stability print nothing after Ctrl+C fix(cli): gateway usage-cost and stability print nothing after Ctrl+C Nov 11, 2026
@obviyus

obviyus commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 11, 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. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 11, 2026
@obviyus

obviyus commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator Author

Exact-head re-proof on 4a51bb4 (built candidate, same harness). usage-cost and stability print nothing after Ctrl+C; call is unchanged on purpose; controls OK:

[cand-run3/usage-json-sigint] Ctrl+C sent at 2.07s (request pending)
[cand-run3/usage-json-sigint] exit=0 rawstatus=0 elapsed=2.20s stdout_bytes=0
[cand-run3/usage-json-sigint] stdout: ''
[cand-run3/usage-json-sigint] stderr: 'Command interrupted by SIGINT. Waiting for cleanup before exiting.\n'
[cand-run3/usage-json-plain] exit=0 rawstatus=0 elapsed=3.71s stdout_bytes=9782
[cand-run3/usage-json-plain] stderr: ''
[cand-run3/usage-text-plain] exit=0 rawstatus=0 elapsed=3.36s stdout_bytes=191
[cand-run3/usage-text-plain] stdout: '\r\nOpenClaw 2026.11.3 (unknown)\r\nOpen source means you can see exactly how I judge your config.\r\n\r\nUsage cost (30 days)\r\nTo
[cand-run3/usage-text-plain] stderr: ''
[cand-run3/usage-text-sigint] Ctrl+C sent at 1.66s (request pending)
[cand-run3/usage-text-sigint] exit=0 rawstatus=0 elapsed=1.70s stdout_bytes=122
[cand-run3/usage-text-sigint] stdout: '\r\nOpenClaw 2026.11.3 (unknown)\r\nGreetings, Professor Falken\r\n\r\n\x1b[0m\x1b[?25h\x1b[?1000l\x1b[?1002l\x1b[?1003l\x1b[?1006l
[cand-run3/usage-text-sigint] stderr: 'Command interrupted by SIGINT. Waiting for cleanup before exiting.\n'
[cand-run3/call-json-sigint] Ctrl+C sent at 1.33s (request pending)
[cand-run3/call-json-sigint] exit=0 rawstatus=0 elapsed=2.98s stdout_bytes=9782
[cand-run3/call-json-sigint] stderr: 'Command interrupted by SIGINT. Waiting for cleanup before exiting.\n'
[cand-run3/stability-json-sigint] Ctrl+C sent at 1.44s (request pending)
[cand-run3/stability-json-sigint] exit=0 rawstatus=0 elapsed=2.53s stdout_bytes=0
[cand-run3/stability-json-sigint] stdout: ''
[cand-run3/stability-json-sigint] stderr: 'Command interrupted by SIGINT. Waiting for cleanup before exiting.\n'
[cand-run3/health-json] exit=0 rawstatus=0 elapsed=1.74s stdout_bytes=1971
[cand-run3/health-json] stderr: ''
[cand-run3/health-text] exit=0 rawstatus=0 elapsed=3.04s stdout_bytes=126
[cand-run3/health-text] stdout: "\r\nOpenClaw 2026.11.3 (unknown)\r\nI'm the reason your shell history looks like a hacker-movie montage.\r\n\r\nGateway Health\r\nOK (1ms
[cand-run3/health-text] stderr: ''

@nithishreddy5771

Copy link
Copy Markdown

Thanks for picking this up. I tested three additional cases on Node 24.22.1: Ctrl+C while usage-cost or stability is waiting for a reply, and a transport error arriving after the abort. All three fail on main and pass on this PR. Happy to share the test additions if useful.

One question: the issue expects exit code 130 after Ctrl+C, but the PTY proof in the description shows exit=0. Is that down to how the harness sends SIGINT, or does the command's exit status change?

@obviyus

obviyus commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator Author

Maintainer override: the only red is checks-node-changed-2, and the same test fails the same way on PRs that don't touch the gateway CLI.

Same test, same assertion today on other PRs (none of them change src/cli/gateway-cli/):

Main, run locally (node 24.22.1 Linux container, clean install and build per commit, two runs each):

The local failures are not the CI assertion. They fail earlier: "Linux child ownership requires a process owner without source-loader hooks", then "fixture not ready", plus one 60 s timeout on current main. So the container can't show whether #196067 caused the CI failure, and it does not prove or rule out that commit. It does show the test fails on main without this PR.

This PR changes only src/cli/gateway-cli/register.ts (usage-cost and stability abort handling) and its test src/cli/gateway-cli.coverage.test.ts. The process test imports the run-loop entry points directly (runGatewayLoop), not register.ts.

@obviyus
obviyus merged commit 3031a32 into main Nov 11, 2026
125 of 130 checks passed
@obviyus
obviyus deleted the fix/usage-cost-sigint branch November 11, 2026 06:07
@obviyus

obviyus commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator Author

Landed in 3031a32. Thanks @GoldArowana for the report.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 12, 2026
…openclaw#197019)

fix(gateway-cli): stop usage-cost and stability output after Ctrl+C

openclaw gateway usage-cost and gateway stability sent their request without the command's abort signal and always printed the reply, so a Ctrl+C while the request was pending still printed the full result. Both now pass the existing signal, the same way gateway health does, and print nothing once aborted, including when a reply arrives after the abort. No text changes. gateway call is unchanged because it can run write methods, and hiding a reply after a change already happened would hide that change.

Evidence: the built CLI on node:24.22.1 in a real PTY against a real built Gateway behind a WebSocket proxy that holds the reply for 1.5 s, two runs each. On main, Ctrl+C while pending still printed the full JSON for usage-cost and stability and the summary in text mode; with this change stdout stays empty. Uninterrupted runs, text output and gateway health match on both. The regression row in gateway-cli.coverage.test.ts fails on main, at -2 net test lines. The red run-loop.direct-stop-active-work.process.test.ts check is inherited: openclaw#197019 (comment).

Fixes openclaw#197005. Thanks @GoldArowana for the report.

Co-authored-by: Ayaan Zaidi <[email protected]>
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.

[Bug]: gateway usage-cost --json writes a result after SIGINT

2 participants