Skip to content

Memory dreaming managed cron job deleted on gateway restart but never recreated #64043

Description

@nicolas-hey

Bug 描述

标题: Memory dreaming managed cron job deleted on gateway restart but never recreated

问题描述:

memory-core 的 dreaming 功能通过 gateway:startup hook 自动创建 managed cron job。但每次 gateway 重启时,该 cron job 会被删除,随后未能重建。

复现步骤

  1. 启用 dreaming 配置:
{
  "plugins": {
    "entries": {
      "memory-core": {
        "enabled": true,
        "config": {
          "dreaming": {
            "enabled": true
          }
        }
      }
    }
  }
}
  1. 启动/重启 gateway
  2. 观察:首次启动时 dreaming cron 成功创建(日志:memory-core: created managed dreaming cron job.)
  3. 重启 gateway
  4. 观察:日志显示 memory-core: removed 1 managed dreaming cron job(s).,但没有 created 日志

根因分析

extensions/memory-core/src/dreaming.tsresolveCronServiceFromStartupSource() 依赖 gateway:startup 事件中的 context.crondeps.cron 来获取 cron service。如果 startup 时 cron service 尚未就绪,函数返回 null,reconcileShortTermDreamingCronJob 跳过创建。

关键代码路径:

  1. registerShortTermPromotionDreaming 注册 gateway:startup hook
  2. startup hook 调用 reconcileManagedDreamingCron({ reason: "startup" })
  3. resolveCronServiceFromStartupSource(startupCronSource) 返回 null
  4. reconcileShortTermDreamingCronJob({ cron: null, ... }) 返回 { status: "unavailable" }
  5. 未创建 cron job

环境信息

  • OpenClaw 版本:2026.4.5 和 2026.4.9 均复现
  • OS:macOS Darwin 25.3.0 (arm64)
  • Node.js:v25.8.0

日志证据

2026-04-08T12:05:45.239+08:00 [plugins] memory-core: created managed dreaming cron job.
2026-04-08T12:25:01.499+08:00 [plugins] memory-core: removed 1 managed dreaming cron job(s).
# 之后无 "created" 日志

重启多次(包括升级到 2026.4.9 后)均复现相同行为。

临时 Workaround

通过 HEARTBEAT.md 检查 + openclaw cron add 手动补建,每次 heartbeat 验证 cron 是否存在。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions