openclaw - ✅(Solved) Fix Scheduled dream diary generation uses request-only subagent runtime and fails in cron context [2 pull requests, 2 comments, 3 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#63832Fetched 2026-04-10 03:41:46
View on GitHub
Comments
2
Participants
3
Timeline
3
Reactions
0
Author
Timeline (top)
commented ×2cross-referenced ×1

Error Message

  1. On affected builds, narrative generation fails with the request-only runtime error.

Root Cause

Symptom | 症状

Dream diary generation fails in scheduled Dreaming runs because the code path assumes request-scoped plugin runtime subagent methods are available.

Fix Action

Fix / Workaround

Local Workaround | 本地临时解决办法

A local fallback narrative path was added so cron-based Dreaming can still produce DREAMS.md content without request-scoped subagent runtime.

PR fix notes

PR #63903: fix(memory-core): limit dreaming narrative fallback to request-scoped subagent runtime errors

Description (problem / solution / changelog)

Summary

  • Problem: scheduled Dreaming can hit request-scoped subagent runtime errors and skip diary output.
  • Why it matters: we should preserve DREAMS.md output for that specific scheduled/runtime mismatch.
  • What changed: fallback is now limited to the canonical request-scoped runtime error, with shared constant wiring across throw/check sites.
  • What did NOT change: non-request-scope subagent.run failures still follow existing best-effort warning behavior (no fallback diary write).

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

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

Root Cause (if applicable)

  • Root cause: scheduled Dreaming used a subagent runtime path that can be request-scoped only.
  • Missing guardrail: narrative fallback path was not scoped tightly to that specific runtime-unavailable condition.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: extensions/memory-core/src/dreaming-narrative.test.ts
  • Scenario locked in: request-scoped runtime error triggers fallback diary write; other run failures do not.

User-visible / Behavior Changes

  • Scheduled Dreaming now writes fallback diary text only for request-scoped subagent runtime unavailability.

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No
  • Data access scope changed? No

Human Verification (required)

  • Verified scenarios: request-scoped fallback path, non-request failure path, existing narrative flow tests.
  • Edge case checked: nested cause text no longer triggers fallback path.
  • Not verified in this PR: live cron run on a real gateway instance.

Risks and Mitigations

  • Risk: request-scoped discriminator drift across boundaries.
    • Mitigation: shared exported constant (SUBAGENT_RUNTIME_REQUEST_SCOPE_ERROR_MESSAGE) used by both runtime throw and memory-core check.
  • Risk: diary writes through symlinked DREAMS.md.
    • Mitigation: appendNarrativeEntry now uses guarded atomic write path.

Changed files

  • extensions/memory-core/src/dreaming-narrative.ts (modified, +50/-0)

PR #64156: fix(memory-core): harden request-scoped dreaming fallback

Description (problem / solution / changelog)

Summary

  • Problem: scheduled dreaming can hit request-scoped subagent runtime errors and skip DREAMS.md narrative output.
  • Why it matters: cron-driven dreaming should degrade cleanly only for that specific runtime mismatch, without broad fallback matching or path leakage.
  • What changed:
    • added a shared request-scoped subagent runtime error code/class in the plugin runtime seam
    • limited narrative fallback to that typed/stable signal instead of generic message matching
    • kept non-request-scope failures on the existing warn-and-stop path
    • removed workspace-path leakage from the fallback warning

Change Type

  • Bug fix
  • Security hardening

Scope

  • Memory / storage
  • API / contracts

Linked Issue/PR

  • Closes #63832
  • Supersedes #63903

Root Cause

The narrative fallback path was trying to detect a request-scoped subagent runtime failure too loosely. That made the seam brittle and left the runtime throw/check sites coupled by message text rather than a stable contract.

Regression Test Plan

  • Unit test
  • Target files:
    • extensions/memory-core/src/dreaming-narrative.test.ts
    • src/plugins/runtime/index.test.ts
  • Locked scenarios:
    • direct request-scoped runtime failure triggers fallback diary write
    • stable error code triggers fallback diary write
    • nested generic causes do not trigger fallback
    • warning log does not leak workspace path

Verification

Authoritative mb-server gate passed:

  • pnpm test -- extensions/memory-core/src/dreaming-narrative.test.ts src/plugins/runtime/index.test.ts

Risks and Mitigations

  • Risk: drift between runtime throw site and fallback detection.
    • Mitigation: shared exported error code/class.
  • Risk: overbroad fallback classification.
    • Mitigation: only direct typed/code-matched failures fall back now.

Changed files

  • CHANGELOG.md (modified, +2/-0)
  • docs/.generated/plugin-sdk-api-baseline.sha256 (modified, +2/-2)
  • extensions/memory-core/src/dreaming-narrative.test.ts (modified, +83/-1)
  • extensions/memory-core/src/dreaming-narrative.ts (modified, +91/-5)
  • src/plugin-sdk/error-runtime.ts (modified, +13/-0)
  • src/plugins/runtime/index.ts (modified, +2/-1)

Code Example

Plugin runtime subagent methods are only available during a gateway request.
RAW_BUFFERClick to expand / collapse

Symptom | 症状

Dream diary generation fails in scheduled Dreaming runs because the code path assumes request-scoped plugin runtime subagent methods are available.

Observed log during Memory Dreaming Promotion cron:

Plugin runtime subagent methods are only available during a gateway request.

在定时的 Dreaming run 里,梦境日记生成会失败,因为代码路径假设 request-scoped plugin runtime subagent methods 在 cron 场景里也可用。

Trigger | 触发条件

  • OpenClaw 2026.4.8
  • Memory Dreaming Promotion managed cron
  • Dreaming diary/narrative generation stage

Minimal Reproduction | 最小复现

  1. Enable Dreaming and ensure managed cron is active.

  2. Let Memory Dreaming Promotion run (or trigger it manually).

  3. Watch logs during diary/narrative generation.

  4. On affected builds, narrative generation fails with the request-only runtime error.

  5. 开启 Dreaming,并确保 managed cron 生效。

  6. Memory Dreaming Promotion 运行,或手动触发。

  7. 观察梦境日记/叙事生成阶段的日志。

  8. 有问题的构建会报 request-only runtime 错误。

Actual Result | 实际结果

The scheduled run can complete partial promotion work, but dream diary narrative generation fails because it tries to use runtime methods that are only valid during a live gateway request.

实际结果是:定时任务可能完成部分 promotion,但梦境日记叙事生成会失败,因为它尝试调用只在实时 gateway request 内才有效的 runtime 方法。

Local Workaround | 本地临时解决办法

A local fallback narrative path was added so cron-based Dreaming can still produce DREAMS.md content without request-scoped subagent runtime.

本地通过增加一个 request-independent fallback narrative 路径,让 cron 场景也能继续生成 DREAMS.md,不再完全失败。

Suggested Fix | 建议修复方向

Please avoid depending on request-only subagent runtime in cron/heartbeat/scheduled contexts. Possible fixes:

  • provide a request-independent narrative generator for scheduled Dreaming
  • or make the required runtime available to scheduled jobs in a supported way
  • in either case, the scheduled path should degrade gracefully instead of silently losing dream diary output

建议不要让 cron / heartbeat / scheduled 场景依赖 request-only subagent runtime。可行方向包括:

  • 给定时 Dreaming 提供一个与 request 无关的 narrative generator
  • 或者以受支持的方式,为 scheduled job 提供所需 runtime
  • 无论哪种方式,这条路径都应该优雅降级,而不是直接丢失 dream diary 输出

extent analysis

TL;DR

Avoid depending on request-only subagent runtime in cron/heartbeat/scheduled contexts by implementing a request-independent narrative generator for scheduled Dreaming.

Guidance

  • Identify and refactor code paths that assume request-scoped plugin runtime subagent methods are available during scheduled runs.
  • Implement a request-independent narrative generator for scheduled Dreaming to ensure DREAMS.md content can be generated without relying on request-only runtime methods.
  • Consider making the required runtime available to scheduled jobs in a supported way, if possible, to maintain functionality without workarounds.
  • Ensure the scheduled path degrades gracefully instead of silently losing dream diary output, providing a fallback narrative path if necessary.

Example

No specific code snippet can be provided without more context, but the local workaround mentioned in the issue suggests adding a request-independent fallback narrative path can help mitigate the issue.

Notes

The suggested fix implies that the current implementation is tightly coupled with request-scoped runtime methods, which may not be available in scheduled contexts. A more robust solution would involve decoupling the narrative generation from request-only dependencies.

Recommendation

Apply workaround: Implement a request-independent narrative generator for scheduled Dreaming, as this approach allows for a more flexible and robust solution that can handle both request-scoped and scheduled contexts.

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