Skip to content

fix(llm-task): stop canceled tasks from returning JSON - #124673

Merged
steipete merged 1 commit into
mainfrom
fix/autoqa150-provider-tools
Aug 16, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/autoqa150-provider-tools

Conversation

@steipete

@steipete steipete commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users canceling an llm-task tool call could still receive a stale successful JSON result when the nested isolated completion ignored cancellation.

The agent runtime already supplied an AbortSignal to the registered tool, but the plugin dropped it before calling the host completion runtime.

Why This Change Was Made

The plugin now forwards the existing tool-call signal into runtime.llm.complete. The host remains the single owner of pre-abort checks, mid-flight abort races, timeout handling, stable error normalization, and cleanup; no plugin-local timeout, race, retry, or compatibility path was added.

User Impact

Canceled llm-task calls now stop at the host completion boundary instead of later returning JSON. Uncanceled calls behave unchanged.

This PR is AI-assisted. The implementation, ownership boundary, tests, and runtime behavior were reviewed and verified by the author.

Evidence

Pre-fix boundary reproduction on the frozen baseline failed because the canceled promise resolved with details.json = { "ok": true } instead of rejecting.

Post-rebase focused proof:

node scripts/run-vitest.mjs extensions/llm-task/src/llm-task-tool.test.ts src/plugins/runtime/runtime-llm-isolated.runtime.test.ts
Result: 2 shards passed; 24 llm-task tests and 19 host isolated-runtime tests passed.

Source-blind registered-tool proof used the real plugin registration and host runtime with a controlled isolated backend that never settled:

Already-aborted call: rejected before backend invocation.
Mid-flight abort: host abort race won; no JSON returned; exact caller reason retained as cause.
Result: 1 file passed, 2 tests passed.

Post-rebase static and changed gates:

Extension production types: passed
Extension test types: passed
Targeted type-aware oxlint: 0 warnings, 0 errors
Formatting: passed
Plugin boundary report: passed
Runtime import cycles: 0
git diff --check: passed
check:changed: passed on Blacksmith Testbox tbx_01m05ke1f174safk7wkjt8q7x2
Actions run: https://github.com/openclaw/openclaw/actions/runs/31956130439

Fresh Codex autoreview on exact head 0ef9ae5ff5f9d1d95bf97be65afa127977ace868: no accepted/actionable findings; patch judged correct with 0.99 confidence.

Production LOC: +2/-1 (net +1) | Tests: +14/-0.

ClawSweeper exact-head review: #124673 (comment)

  • No correctness or security findings; readiness 5/6.
  • Rank-up move “Resolve merge risk”: applied. The maintainer explicitly approved this exact low-risk two-line propagation; net +1 production line is the unavoidable direct request field, and no coherent net-neutral owner fix exists.
  • Rank-up move “Complete next step”: applied. This PR owns the bounded repair, focused/source-blind proof is complete, Testbox changed gates passed, and exact-head CI is green.

@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 16, 2026 15:44
@openclaw-barnacle openclaw-barnacle Bot added extensions: llm-task Extension: llm-task size: XS maintainer Maintainer-authored PR labels Aug 16, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Aug 16, 2026
@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 16, 2026, 11:51 AM ET / 15:51 UTC.

ClawSweeper review

What this changes

The PR forwards the existing tool-call cancellation signal from the llm-task plugin into its isolated model-completion request.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open. Current main drops the invocation signal at the llm-task plugin boundary, while the branch forwards it to the host cancellation owner; the focused regression test fails before that forwarding exists. No blocking correctness findings.

Priority: P2
Reviewed head: 0ef9ae5ff5f9d1d95bf97be65afa127977ace868

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A small owner-boundary repair with a credible pre-fix failure shape, focused regression coverage, and no actionable review finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body nevertheless reports focused terminal and registered-tool/host runtime cancellation evidence.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body nevertheless reports focused terminal and registered-tool/host runtime cancellation evidence.
Evidence reviewed 5 items Current-main omission: Current main's llm-task tool accepts only the tool id and parameters, then calls the completion host without the invocation signal, so cancellation cannot reach the host boundary.
Caller and host contract: The plugin tool wrapper passes its invocation signal as the third execute argument, and the host completion contract accepts it; the isolated host path listens for abort and races the completion against it.
Focused regression coverage: The added test aborts during the completion call, requires rejection rather than a JSON result, and verifies that the same signal crossed the plugin-to-host boundary.
Findings None None.
Security None None.

How this fits together

The llm-task plugin turns an agent tool call into an isolated model completion through the plugin runtime. The invocation cancellation signal must reach the host runtime, which races cancellation against the completion and returns an abort outcome instead of stale JSON.

flowchart LR
  A[Agent tool call] --> B[Plugin tool wrapper]
  B --> C[llm-task plugin]
  C --> D[Host completion request]
  D --> E[Isolated model runtime]
  E --> F[JSON result or cancellation]
Loading

Before merge

  • Resolve merge risk (P1) - Production code is net +1 line; the added execute parameter and request field are both required to carry the already-existing signal, so no coherent net-neutral refactor is apparent.
  • Complete next step (P2) - Current main still drops the signal, and this open maintainer PR already owns the bounded repair.
Agent review details

Security

None.

PR surface

Source +1, Tests +14. Total +15 across 2 files.

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

Review metrics

Metric Value Why it matters
Production versus test LOC production +1 net (2 added, 1 removed); tests +14 The minimal production growth is the two-part signal propagation; the added test protects the plugin-to-host cancellation boundary.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep cancellation owned by the host runtime: forward the existing tool signal directly and retain the boundary regression test rather than adding plugin-local abort races or timeouts.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep cancellation owned by the host runtime: forward the existing tool signal directly and retain the boundary regression test rather than adding plugin-local abort races or timeouts.

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

Yes—source-reproducible: the tool wrapper supplies a signal, current main's llm-task tool drops it, and the host has an established abort race once it receives it. This read-only review did not execute the test suite.

Is this the best way to solve the issue?

Yes. Directly forwarding the existing signal is the narrow owner-aligned repair because the host already owns pre-abort handling, abort races, timeout normalization, and cleanup.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 5f561999a9d8.

Labels

Label changes:

  • add P2: A canceled optional llm-task call can return stale structured output, but the fix is narrowly scoped to one plugin-runtime boundary.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body nevertheless reports focused terminal and registered-tool/host runtime cancellation evidence.

Label justifications:

  • P2: A canceled optional llm-task call can return stale structured output, but the fix is narrowly scoped to one plugin-runtime boundary.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body nevertheless reports focused terminal and registered-tool/host runtime cancellation evidence.

Evidence

What I checked:

  • Current-main omission: Current main's llm-task tool accepts only the tool id and parameters, then calls the completion host without the invocation signal, so cancellation cannot reach the host boundary. (extensions/llm-task/src/llm-task-tool.ts:226, 5f561999a9d8)
  • Caller and host contract: The plugin tool wrapper passes its invocation signal as the third execute argument, and the host completion contract accepts it; the isolated host path listens for abort and races the completion against it. (src/plugins/tools.ts:845, 0ef9ae5ff5f9)
  • Focused regression coverage: The added test aborts during the completion call, requires rejection rather than a JSON result, and verifies that the same signal crossed the plugin-to-host boundary. (extensions/llm-task/src/llm-task-tool.test.ts:385, 0ef9ae5ff5f9)
  • Feature provenance: Blame ties the current plugin omission and the host abort implementation to the same recent main commit, making the missing cross-boundary propagation a coherent repair target. (extensions/llm-task/src/llm-task-tool.ts:135, 81d44365ae2e)
  • Current-main status: The proposed head is not an ancestor of current main, so the requested cancellation behavior is not already implemented there. (0ef9ae5ff5f9)

Likely related people:

  • steipete: Blame attributes both the llm-task completion call and isolated-host abort path to this contributor's recent main commit; the same contributor authored the proposed forwarding repair. (role: introduced the current path and authored the repair; confidence: high; commits: 81d44365ae2e, 0ef9ae5ff5f9; files: extensions/llm-task/src/llm-task-tool.ts, src/plugins/runtime/runtime-llm-isolated.ts)
  • cpojer: Feature history shortlog shows repeated prior contributions to the llm-task implementation. (role: prior area contributor; confidence: medium; files: extensions/llm-task/src/llm-task-tool.ts)

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.

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head 0ef9ae5ff5f9d1d95bf97be65afa127977ace868.

Root cause: llm-task received the AgentTool.execute cancellation signal but omitted it from the isolated runtime.llm.complete request. The host already owns pre-abort checks, the mid-flight abort race, timeout normalization, stable LLM_COMPLETION_ABORTED errors, and cleanup. The fix forwards that existing signal directly; no plugin-local race, timeout, retry, helper, config, SDK, auth, protocol, or persistence change was added.

Exact proof:

OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree node scripts/run-vitest.mjs extensions/llm-task/src/llm-task-tool.test.ts src/plugins/runtime/runtime-llm-isolated.runtime.test.ts
PASS: 24 llm-task tests + 19 host isolated-runtime tests.

OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree node scripts/run-vitest.mjs extensions/llm-task/src/llm-task-host-runtime.proof.test.ts
PASS: 2 source-blind registered-tool/real-host tests. Pre-abort never invoked the controlled backend; mid-flight abort beat a never-settling backend and returned no JSON. Temporary proof file removed after execution.

node scripts/run-tsgo.mjs -p tsconfig.extensions.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/extensions.tsbuildinfo
PASS

node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.extensions.test.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/extensions-test.tsbuildinfo
PASS

node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.extensions.json extensions/llm-task/src/llm-task-tool.test.ts extensions/llm-task/src/llm-task-tool.ts
PASS: 0 warnings, 0 errors

oxfmt --check extensions/llm-task/src/llm-task-tool.ts extensions/llm-task/src/llm-task-tool.test.ts
PASS

node --import tsx scripts/plugin-boundary-report.ts --summary --fail-on-eligible-compat
PASS

node --import tsx scripts/check-import-cycles.ts
PASS: 0 runtime value cycles

git diff origin/main...HEAD --check
PASS

node scripts/check-changed.mjs --base origin/main -- extensions/llm-task/src/llm-task-tool.ts extensions/llm-task/src/llm-task-tool.test.ts
PASS: Blacksmith Testbox tbx_01m05ke1f174safk7wkjt8q7x2, run https://github.com/openclaw/openclaw/actions/runs/31956130439

.agents/skills/autoreview/scripts/autoreview --mode commit --commit HEAD --stream-engine-output
PASS: no accepted/actionable findings; patch correct, confidence 0.99

Hosted CI: https://github.com/openclaw/openclaw/actions/runs/31956571918 — exact head matched; openclaw/ci-gate succeeded.

ClawSweeper: #124673 (comment) — no correctness/security findings, 5/6 readiness.

Rank-up moves:

  • “Resolve merge risk”: applied. The maintainer approved this exact low-risk fix; production is +2/-1 (net +1) because the existing signal requires one direct request field. A net-neutral alternative would add indirection or duplicate host policy.
  • “Complete next step”: applied. This PR owns the bounded repair; focused and source-blind proof, Testbox changed gates, fresh autoreview, and exact-head required CI are green.

LOC: Production +2/-1 (net +1) | Tests +14/-0.

Known proof gap: no external provider call was run because the claim is entirely within the local AgentTool and host completion cancellation contracts; no external API behavior is claimed.

@steipete
steipete merged commit 421e319 into main Aug 16, 2026
171 checks passed
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

extensions: llm-task Extension: llm-task maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. 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