Skip to content

fix(cli): cancel infer web requests and discard late output - #191628

Merged
obviyus merged 5 commits into
openclaw:mainfrom
zhangguiping-xydt:fix/proof-round3-1
Nov 3, 2026
Merged

obviyus merged 5 commits into
openclaw:mainfrom
zhangguiping-xydt:fix/proof-round3-1

Conversation

@zhangguiping-xydt

@zhangguiping-xydt zhangguiping-xydt commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

infer web search and web fetch can print a late result or provider failure after acknowledging Ctrl-C. Their request owners did not receive the invocation signal, and their output bypassed the existing cancellation-aware capability wrapper.

What Changed

Forward the existing AsyncWorkScope signal to web search, the default fetch tool, and a pinned fetch provider. Use the existing runCapabilityCommand owner to discard late success/failure output. Ordinary structured failures still exit nonzero after output drains, without overriding an acknowledged interruption.

Provider APIs, security guards, selection, credentials and timeout policy are unchanged. No new signal manager or configuration is introduced.

Evidence

Head: a11fa18f2f894253c467e7d34aa7949d8e42cfa0.

Built CLI before/after proof: clean main/candidate builds in secretless Node 24.22.1 Docker, normal bundled Firecrawl search/pinned fetch and direct HTTP fetch. The delayed local peer receives each request, then the harness sends real SIGINT and waits for the actual root acknowledgement before releasing the response.

Twice per case, main prints late output after acknowledgement: search success 999 bytes, search HTTP 503 471 bytes, pinned-fetch success 794 bytes, pinned-fetch HTTP 503 464 bytes, direct-fetch success 1,080 bytes. Candidate prints zero stdout and only the root acknowledgement on stderr; all interrupted invocations exit naturally with 130. Uninterrupted successes remain visible with exit 0, and HTTP 503 failures remain visible with exit 1 on both refs. Forty CLI invocations total; no forced kills.

No socket-abort claim: every peer observation had responseClosedBeforeFinish=false. The proof establishes cancellation acknowledgement, late-output suppression and exit-status preservation; the regression separately checks signal forwarding.

Consolidated the interruption regression into existing default-fetch cases and restored moved web tests to their original suite. Removed the extra registrar and test-growth allocation, duplicate configuration setup and generic envelope echoes, retaining provider-state, normal output, disabled-fetch, structured-failure and SecretRef coverage.

  • Candidate capability suite: 102 tests passed; 50.61 s Vitest / 53.31 s runner including cold compilation, approximately 13.7 s test execution. Changed fetch cases: 2 ms each.
  • Baseline focused regression fails at missing invocation-signal forwarding.
  • Focused Oxfmt, Oxlint and whitespace checks passed.
  • Whole-PR delta: production +24/-23 (net +1), tests +101/-106 (net -5), docs +3. Moved test lines are not counted as new production.
  • Fixed an own introduced test-type error from spreading a plain array into required arguments: both literal domain and action now precede the variadic arguments. The two disabled-fetch cases pass; the exact previously failing type graph now passes through the repository's pinned compiler runner. Production code and runtime proof are unchanged.
  • Integrated current main after fix(cli): preserve TTS output after accepted interruption #191635 landed its disjoint TTS documentation and tests. Both TTS and Web interruption guidance are retained. Web request/output and root signal owners are byte-unchanged by that merge, so the recorded runtime proof remains applicable.

Merge Danger

Two-way door: reverting restores prior cancellation/output behavior; there are no persisted state or public-contract changes. Blast radius is local infer web search/fetch interruption and ordinary failure exit handling. Other capability commands continue to use the same existing output owner.

@clawsweeper

clawsweeper Bot commented Nov 3, 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 cli CLI command changes size: L labels Nov 3, 2026
@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: 🐚 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:bug Preliminary submission classification; full source review pending. labels Nov 3, 2026
@clawsweeper

clawsweeper Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Forward invocation cancellation to infer web requests and suppress results or failures arriving after interruption.

Example: Press Ctrl-C during openclaw infer web search --provider firecrawl --query OpenClaw --json before the response arrives.

  • Before: The CLI acknowledges interruption but can subsequently print the provider result.
  • After: The CLI suppresses the late result and preserves exit code 130.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused repair with shipped CLI before/after proof, meaningful cancellation regression coverage, and no correctness or security findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The supplied secretless Node 24.22.1 Docker proof exercises the built CLI with bundled Firecrawl search/pinned fetch and direct HTTP fetch, withholding responses until real SIGINT acknowledgement; candidate runs suppress late success/failure output and preserve interrupt and ordinary exit statuses, with the exercised production owners unchanged at the reviewed head.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Web inference can print a result or failure after the CLI has acknowledged the user's interruption.
Reason: The change restores the existing interruption contract using established owners without new configuration, public APIs, or persistent state.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current-main cancellation defect with a focused change and no actionable findings; exact-head CI is still running.

Priority: P2
Reviewed head: a11fa18f2f894253c467e7d34aa7949d8e42cfa0

Before merge

None.

Findings

None.

Agent review details

How this fits together

The infer web CLI resolves configuration and providers, invokes the existing search or fetch owner, and publishes a capability envelope through shared CLI output and cleanup handling.

flowchart TD
  A[Infer web command] --> B[Configuration and provider resolution]
  C[Invocation cancellation signal] --> D[Search or fetch owner]
  B --> D
  D --> E[Cancellation aware capability output]
  C --> E
  E --> F[CLI output and exit finalization]
Loading

Technical review

Best possible solution:

Land the focused reuse of existing request cancellation and output owners once required checks pass.

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

Current-main source retains the missing signal forwarding and unconditional late publication; the supplied built-CLI comparison demonstrates the failure through equivalent production owners.

Is this the best way to solve the issue?

This is the smallest complete fix: connect all three web request paths to the invocation signal and reuse the established cancellation-aware output wrapper while retaining failure output draining.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Shared web command envelope and failure exit keeps the original intent (5be62f2: Consolidate web envelope, error, and output handling while preserving CLI behavior; the earlier output-drain repair requires complete failed output before exit.)
  • Default web fetch tool ownership keeps the original intent (bb957f5: Use the agent web-fetch tool for default fetching so extraction, fallback, and SSRF handling retain one owner.)
  • Existing web regression coverage keeps the original intent (86310c8: Consolidate overlapping tests while retaining distinct cancellation, authority, and protocol regressions.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Vincent Koc: Raw commit 59c3606 adds src/cli/capability-cli/web.ts:49 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 59c3606366d5; files: src/cli/capability-cli/web.ts)

PR surface

Source +1, Tests -5, Docs +3. Total -1 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 24 23 +1
Tests 1 101 106 -5
Docs 1 3 0 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 128 129 -1

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Late output after acknowledged interruption is a bounded CLI correctness defect with no demonstrated data loss or process outage.
  • 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-03T03:24:18.817Z sha 3964a22 :: needs maintainer review before merge. :: none
  • reviewed 2026-11-03T04:03:45.286Z sha 0e12f53 :: needs maintainer review before merge. :: none
  • reviewed 2026-11-03T04:16:21.973Z sha 0a991ba :: needs maintainer review before merge. :: none
  • reviewed 2026-11-03T04:29:13.772Z sha ebd7f34 :: needs maintainer review before merge. :: none

Reviewed November 2, 2026, 11:37 PM ET / November 3, 2026, 04:37 UTC (Revision 5).

@obviyus

obviyus commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

Evidence

Built main c86fbe68e5a1ae494e49ac6ad41aef9585210ab6 and contributor candidate 3964a226e59b4bcf654e42917514e79d41afa41a from clean archived sources in secretless node:24.22.1 Docker. Final head 0e12f53bceddea804d1de47e70995e4932412afc has identical production code; only test consolidation and documentation wording changed afterward.

Exercised shipped dist/entry.js --profile <isolated-profile> infer web search --provider firecrawl --query ... --json, pinned infer web fetch --provider firecrawl, and direct infer web fetch. Firecrawl used its normal bundled provider and configured local self-hosted API endpoint with synthetic credentials. Direct fetch used the ordinary HTTP guard with the task-owned loopback hostname explicitly allowed in config. No provider implementation, security guard, or signal manager was replaced.

The local HTTP peer first received each request. For interrupted runs the harness then sent real SIGINT to that CLI process group and withheld the response until stderr contained the root owner's actual acknowledgement:

Command interrupted by SIGINT. Waiting for cleanup before exiting.

Only after observing that acknowledgement did the peer send its success page/search response or HTTP 503 failure. Two runs of each case per ref:

late stdout bytes after acknowledgement      main runs       candidate runs
search success                              999 / 999       0 / 0
search HTTP 503                              471 / 471       0 / 0
pinned fetch success                        794 / 794       0 / 0
pinned fetch HTTP 503                        464 / 464       0 / 0
direct fetch success                        1080 / 1080     0 / 0

All interrupted commands exited naturally with code 130. Candidate stderr contained only the root acknowledgement, with no late result/error. No forced kill occurred. Uninterrupted controls were run twice for all five cases on both refs: successes published their expected fixture content and exited 0; HTTP 503 failures remained visible and exited 1. Overall: 40 real CLI invocations / HTTP requests.

Limit: no socket abort is claimed. The peer recorded responseClosedBeforeFinish=false for every case. These observations prove acknowledged interruption, late-output suppression and exit-status preservation. Signal forwarding is separately exercised by the regression and confirmed at the three existing request owners in source.

The fix reuses getAsyncWorkSignal and the existing cancellation-aware runCapabilityCommand output owner; provider API, routing/selection, credentials and network guards are unchanged. The failure exit check runs only when the invocation was not cancelled, preserving root interruption ownership.

Test consolidation restores the existing web cases to their original capability suite instead of retaining an extra registrar. One existing default-fetch case now closes a real AsyncWorkScope while its mocked provider returns, asserting both the invocation signal and discarded JSON. The existing normal output, provider state, disabled-fetch, structured-failure and SecretRef cases remain. Duplicated configuration setup and generic envelope echoes were removed; dedicated SecretRef and shared output-owner coverage remain. The old 294-line registrar was moved code, not new production code. No test-growth allocation remains.

Baseline focused cases failed because the invocation signal was absent at the direct-fetch owner. Candidate complete capability suite: 102 tests passed, 50.61 s Vitest / 53.31 s runner (cold compilation included; test execution approximately 13.7 s). The two changed fetch cases took 2 ms each. Focused Oxfmt/Oxlint and whitespace checks passed. Whole-PR delta against the merge base: production +24/-23 (net +1), tests +104/-106 (net -2), docs +3/-0.

@obviyus

obviyus commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 3, 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. clawsweeper:intake:needs-repro 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. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 3, 2026
@obviyus

obviyus commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the clawsweeper:intake:bug Preliminary submission classification; full source review pending. label Nov 3, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 3, 2026
@obviyus

obviyus commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 3, 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-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 3, 2026
@obviyus

obviyus commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 3, 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-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 3, 2026
@obviyus
obviyus merged commit cac59aa into openclaw:main Nov 3, 2026
115 checks passed
@obviyus

obviyus commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

Landed in cac59aa. Thanks @zhangguiping-xydt. Interrupted infer web commands no longer print late output.

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

fix(cli): don't publish web search or fetch output after the command is interrupted

`infer web` search, direct fetch and pinned fetch did not follow the command's cancellation signal. After an acknowledged SIGINT, a late response was still printed. These commands now use the existing cancellation scope, so an interrupted run publishes nothing and exits with 130. Provider APIs, security guards and provider selection are unchanged, and uninterrupted runs are unchanged.

Evidence: 40 built-CLI runs in secretless Node 24.22.1 Docker with delayed real HTTP responses released only after the SIGINT was acknowledged. Main published late search, pinned-fetch and direct-fetch output twice; with this change nothing was published and the command exited with 130, twice. Uninterrupted success and error controls kept exit codes 0 and 1. Details: openclaw#191628 (comment).

Thanks @zhangguiping-xydt.

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 docs Improvements or additions to documentation 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: M 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