openclaw - ✅(Solved) Fix Bug: tasks cancel returns 'Task runtime does not support cancellation yet' - no way to clear stale_running CLI tasks [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#62419Fetched 2026-04-08 03:04:31
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
0
Timeline (top)
commented ×1cross-referenced ×1referenced ×1

Fix Action

Fix / Workaround

  • openclaw tasks cancel returns "Task runtime does not support cancellation yet" for ALL CLI tasks
  • openclaw tasks maintenance --apply does 0 reconciliation/cleanup/prune for stale_running tasks
  • Gateway restart does not clear stale_running markers
  • No CLI command or workaround exists to clear these tasks

PR fix notes

PR #62506: Tasks: allow openclaw tasks cancel for CLI runtime (#62419)

Description (problem / solution / changelog)

Summary

  • Problem: openclaw tasks cancel returned "Task runtime does not support cancellation yet" for CLI-tracked tasks (for example gateway agent runs), so operators could not clear stuck running rows.
  • Why it matters: CLI tasks can remain running when follow-up bookkeeping never runs; without a working cancel path there was no supported way to mark them terminal.
  • What changed: cancelTaskById treats runtime === "cli" like other local cancellations: record cancelled in the task registry (CLI uses the main session as childSessionKey; there is no separate ACP/subagent session to stop). Docs and changelog updated; unit test covers the path.
  • What did NOT change: Cron and any other non-ACP/subagent/CLI runtimes still return the unsupported message. Maintenance/audit behavior for stale_running is unchanged (audit remains informational).

Change Type

  • Bug fix

Scope

  • Gateway / orchestration

Linked Issue/PR

  • Closes #62419
  • This PR fixes a bug or regression

Root Cause

  • Root cause: cancelTaskById only wired teardown for ACP and subagent runtimes; CLI fell through to the unsupported branch despite using a normal session key.
  • Missing detection / guardrail: Unit tests only covered ACP and subagent cancellation.

Regression Test Plan

  • Coverage: Unit test (src/tasks/task-registry.test.ts) asserts CLI cancel updates the task to cancelled, does not call ACP/subagent hooks, and delivers the expected terminal message when delivery is pending.

User-visible / Behavior Changes

  • openclaw tasks cancel succeeds for active CLI-tracked tasks and sets status to cancelled with operator error text.

Diagram

N/A

Security Impact

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No (registry state only for CLI cancel)
  • Data access scope changed? No

Repro + Verification

Environment

  • Unit test run: pnpm test src/tasks/task-registry.test.ts -t "cancels"

Steps

  1. Create a running CLI task record with childSessionKey set.
  2. Call cancelTaskById.
  3. Expect cancelled: true and no ACP/subagent control calls.

Expected

  • Task transitions to cancelled.

Actual

  • Matches test expectations.

Evidence

  • New unit test for CLI cancel path

Human Verification

  • Verified scenarios: Scoped Vitest for cancel tests in task-registry.test.ts.
  • Edge cases checked: Confirms ACP/subagent mocks are not invoked for CLI.
  • What I did not verify: Full pnpm check / pnpm build (local tree has unrelated TS/build failures on this checkout).

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? No

Risks and Mitigations

  • Risk: Cancelling while a CLI run is still live does not abort the agent run; it only updates task registry state (same class of limitation as other operator-driven terminal updates if completion races).
    • Mitigation: Matches prior behavior for non-CLI paths that only had registry + session kill where applicable; documented in docs/automation/tasks.md.

Made with Cursor

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • docs/automation/tasks.md (modified, +1/-1)
  • src/tasks/task-registry.test.ts (modified, +132/-0)
  • src/tasks/task-registry.ts (modified, +35/-30)
RAW_BUFFERClick to expand / collapse

Bug Description

CLI tasks that get stuck in stale_running state cannot be cancelled or cleared through any normal means. The openclaw tasks cancel command explicitly returns "Task runtime does not support cancellation yet", making it impossible to clean up orphaned tasks.

Steps to Reproduce

  1. Have several CLI tasks (e.g., exec-approval-followup type) that get stuck in stale_running state
  2. Try to cancel them with openclaw tasks cancel <task-id>
  3. Observe: returns "Task runtime does not support cancellation yet"
  4. Try openclaw tasks maintenance --apply
  5. Observe: outputs "0 reconcile · 0 cleanup · 0 prune" - does nothing
  6. Try gateway restart
  7. Observe: stale_running tasks persist after restart

Expected Behavior

  • Users should be able to manually cancel stuck CLI tasks
  • The tasks cancel command should actually work for CLI runtime tasks
  • The maintenance command should detect and clean up stale_running orphaned tasks
  • Gateway restart should clear stale task markers

Actual Behavior

  • openclaw tasks cancel returns "Task runtime does not support cancellation yet" for ALL CLI tasks
  • openclaw tasks maintenance --apply does 0 reconciliation/cleanup/prune for stale_running tasks
  • Gateway restart does not clear stale_running markers
  • No CLI command or workaround exists to clear these tasks

Task Details (for reference)

7 stuck tasks (all exec-approval-followup, exit code 0 but followup never transitioned):

  • 05b80529-5f55-4a06-a12a-3a25810906d7
  • 87cdf907-6a2c-4679-82be-a1c6138c2780
  • b2104428-f9a0-4d69-9734-0a7e46600fb0
  • c9fa3163-428d-479b-8465-75c28c301c42
  • bfaf23f7-53b3-4b31-825f-cde488ba1aae
  • 6e3d7c42-0b8c-4c85-9f54-28b758b894f0
  • 35a4140c-df91-4273-9ccd-0f29f03a1c09

Environment

  • OpenClaw: 2026.4.5
  • Platform: macOS
  • Node: v22.22.0
  • Tasks audit output: 7 stale_running errors

extent analysis

TL;DR

The most likely fix for stuck CLI tasks in the stale_running state is to implement task cancellation support for the CLI runtime or find an alternative workaround to manually clean up orphaned tasks.

Guidance

  • Investigate the OpenClaw documentation and codebase to determine if there are any existing mechanisms or plans to add cancellation support for CLI runtime tasks.
  • Consider manually updating the task state to a completed or failed state to remove them from the stale_running queue, if possible.
  • Review the tasks audit output to ensure that the 7 stale_running errors are the only issues and that there are no other underlying problems.
  • Check if there are any open issues or pull requests in the OpenClaw repository related to task cancellation or stale task cleanup.

Example

No code snippet is provided as the issue does not imply a specific code-based solution.

Notes

The provided information suggests that the issue is related to the lack of cancellation support for CLI runtime tasks in OpenClaw. However, without further details about the OpenClaw codebase or documentation, it is difficult to provide a more specific solution.

Recommendation

Apply workaround: Since the openclaw tasks cancel command does not support cancellation for CLI runtime tasks, an alternative workaround, such as manually updating the task state, may be necessary to clean up orphaned tasks.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING