Skip to content

Cron runningAtMs flag never auto-clears after session timeout, permanently blocking cron execution #18120

@100menotu001

Description

@100menotu001

Problem

When a cron job fires and spawns an agent session, the gateway sets runningAtMs
on the cron's state. If the session times out or crashes, runningAtMs is never
cleared. The scheduler then skips the cron on every subsequent tick because it
thinks a session is still running.

The only way to clear it is a disable/enable toggle via the API, which is not
discoverable and requires knowing the internal state model.

Expected Behavior

The gateway should auto-clear runningAtMs when:

  • The spawned session ends (completes, times out, or errors)
  • runningAtMs has been set for longer than the cron's timeoutSeconds + a buffer

Observed Behavior

runningAtMs persists indefinitely. Crons silently stop executing with no
error logged. The only visible symptom is that nextRunAtMs stays in the past
and the cron never fires again.

Workaround

Disable/enable the cron via the API:

POST /tools/invoke
{"tool":"cron","args":{"action":"update","id":"<job-id>","patch":{"enabled":false}}}
// wait 100ms
POST /tools/invoke
{"tool":"cron","args":{"action":"update","id":"<job-id>","patch":{"enabled":true}}}

This clears state entirely and resets nextRunAtMs.

Environment

  • OpenClaw gateway v2026.2.x
  • macOS, launchd-managed gateway process

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions