openclaw - ✅(Solved) Fix deleteAfterRun ignored for non-'at' schedule kinds [3 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#63770Fetched 2026-04-10 03:41:53
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×2commented ×1referenced ×1

Root Cause

In server.impl-BxLfE9ri.js line ~7809:

const shouldDelete = job.schedule.kind === "at" && job.deleteAfterRun === true && result.status === "ok";

The job.schedule.kind === "at" guard means deleteAfterRun is hardcoded to only apply to at-type schedules.

Fix Action

Workaround

Use kind: "at" with a near-future timestamp instead of kind: "every" when you need fire-once-and-delete behavior.

PR fix notes

PR #63824: fix(crons): honor deleteAfterRun for every and cron schedule kinds

Description (problem / solution / changelog)

Summary

Before this fix, deleteAfterRun: true only worked for kind: "at" schedules because the shouldDelete condition explicitly checked kind === "at"", ignoring kind === "every"andkind === "cron"` jobs.

This change removes that guard so deleteAfterRun: true correctly deletes every and cron kind jobs after their first successful run.

Root Cause

In src/cron/service/timer.ts, the shouldDelete condition was:

const shouldDelete =
  job.schedule.kind === "at" && job.deleteAfterRun === true && result.status === "ok";

The job.schedule.kind === "at" guard meant deleteAfterRun was hardcoded to only apply to at-type schedules.

Fix

Removed the kind === "at" restriction from the shouldDelete condition:

const shouldDelete =
  job.deleteAfterRun === true && result.status === "ok";

Test Coverage

Added a new test honors deleteAfterRun for every and cron schedule kinds that verifies jobs with kind: "every" and kind: "cron" are deleted from the store when deleteAfterRun: true is set and the run completes with status: "ok".

Fixes #63770

Changed files

  • src/agents/bash-tools.exec.ts (modified, +1/-1)
  • src/agents/bash-tools.shared.test.ts (modified, +37/-2)
  • src/agents/bash-tools.shared.ts (modified, +14/-21)
  • src/cron/service/timer.regression.test.ts (modified, +38/-0)
  • src/cron/service/timer.ts (modified, +1/-2)

PR #63871: fix(cron): honor deleteAfterRun for recurring jobs

Description (problem / solution / changelog)

Summary

  • make cron deleteAfterRun delete jobs after any successful run, not only at jobs
  • keep existing one-shot behavior unchanged
  • add regression coverage for recurring every jobs with deleteAfterRun: true

Validation

  • pnpm vitest run src/cron/service/timer.regression.test.ts

Fixes #63770

Changed files

  • src/cron/service/timer.regression.test.ts (modified, +228/-0)
  • src/cron/service/timer.ts (modified, +1/-2)
  • src/infra/outbound/target-resolver.test.ts (modified, +5/-0)

PR #64375: fix(cron): honor deleteAfterRun for every and cron schedule kinds

Description (problem / solution / changelog)

Summary

  • deleteAfterRun: true was silently ignored on kind: "every" and kind: "cron" schedules because applyJobResult hardcoded job.schedule.kind === "at" in the shouldDelete guard.
  • Removed the kind === "at" constraint so deleteAfterRun works for all schedule types when the run succeeds (status === "ok").

Fixes #63770

Test plan

  • pnpm test src/cron/service/timer.regression.test.ts — 27/27 pass
  • pnpm test src/cron/ — 76 files, 593/593 pass
  • Added 3 regression tests:
    • kind: "every" + deleteAfterRun: true → job deleted after success
    • kind: "cron" + deleteAfterRun: true → job deleted after success
    • kind: "every" + deleteAfterRun: true + error → job kept (not deleted on failure)

Changed files

  • src/cron/service/timer.regression.test.ts (modified, +99/-0)
  • src/cron/service/timer.ts (modified, +1/-2)

Code Example

const shouldDelete = job.schedule.kind === "at" && job.deleteAfterRun === true && result.status === "ok";

---

cron.add({
  name: "test-delete",
  schedule: { kind: "every", everyMs: 60000 },
  deleteAfterRun: true,
  sessionTarget: "main",
  payload: { kind: "systemEvent", text: "test" }
})
RAW_BUFFERClick to expand / collapse

Bug

deleteAfterRun: true only works for kind: "at" schedules. Setting it on kind: "every" or kind: "cron" jobs has no effect — the job is never deleted after running.

Root Cause

In server.impl-BxLfE9ri.js line ~7809:

const shouldDelete = job.schedule.kind === "at" && job.deleteAfterRun === true && result.status === "ok";

The job.schedule.kind === "at" guard means deleteAfterRun is hardcoded to only apply to at-type schedules.

Expected Behavior

If deleteAfterRun: true is set on any schedule kind, the job should be deleted after its first successful run. This enables a valid use case: "fire once on next interval tick, then self-destruct."

Reproduction

cron.add({
  name: "test-delete",
  schedule: { kind: "every", everyMs: 60000 },
  deleteAfterRun: true,
  sessionTarget: "main",
  payload: { kind: "systemEvent", text: "test" }
})

Job fires repeatedly. Never deletes.

Workaround

Use kind: "at" with a near-future timestamp instead of kind: "every" when you need fire-once-and-delete behavior.

Environment

OpenClaw 2026.4.9 (35c152d)

extent analysis

TL;DR

To achieve the "fire once and delete" behavior for non-"at" schedules, modify the condition in server.impl-BxLfE9ri.js to remove the job.schedule.kind === "at" guard.

Guidance

  • Identify the line of code causing the issue: const shouldDelete = job.schedule.kind === "at" && job.deleteAfterRun === true && result.status === "ok";
  • Modify this line to apply deleteAfterRun regardless of the schedule kind by removing the job.schedule.kind === "at" condition.
  • Test the modification with different schedule kinds ("every", "cron") to ensure deleteAfterRun works as expected.
  • Consider the workaround provided for immediate use: using kind: "at" with a near-future timestamp for fire-once-and-delete behavior.

Example

const shouldDelete = job.deleteAfterRun === true && result.status === "ok";

Notes

The provided fix assumes that removing the schedule kind condition is sufficient and does not introduce unintended behavior for other schedule types.

Recommendation

Apply the workaround using kind: "at" with a near-future timestamp until a permanent fix can be implemented, as it provides the desired functionality without modifying the underlying code.

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