Skip to content

[Bug]: Managed memory dreaming cron can overload gateway under pressure #84847

Description

@galiniliev

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

Managed memory dreaming cron can sweep many workspaces in one gateway tick, keeping the gateway under memory and CPU pressure instead of yielding background work.

Steps to reproduce

  1. Run OpenClaw with memory-core short-term dreaming enabled for a multi-workspace agent setup.
  2. Let the managed memory dreaming cron fire while the gateway is already under load.
  3. Observe the gateway continuing the dreaming sweep across all configured workspaces during the same tick.

Expected behavior

Managed background memory dreaming should avoid adding substantial gateway pressure: cron-triggered work should be bounded per tick and deferred when RSS or heap pressure is already high.

Actual behavior

Observed logs show one managed dreaming cron tick processing 10 workspaces and taking 69621 ms while nearby diagnostics reported high memory pressure and a saturated event loop.

OpenClaw version

NOT_ENOUGH_INFO

Operating system

NOT_ENOUGH_INFO

Install method

NOT_ENOUGH_INFO

Model

NOT_ENOUGH_INFO

Provider / routing chain

NOT_ENOUGH_INFO

Additional provider/model setup details

NOT_ENOUGH_INFO

Logs, screenshots, and evidence

memory-core: dreaming promotion complete (workspaces=10, candidates=10, applied=1, failed=0)
observed managed background task duration: 69621ms
memory pressure warning: rssBytes=1827979264 heapUsedBytes=684072312 thresholdBytes=1610612736
liveness warning: eventLoopUtilization=0.991 cpuCoreRatio=1.107 active=0 waiting=0 queued=0

Impact and severity

Affected: gateways with memory-core short-term dreaming enabled across multiple workspaces.
Severity: high for responsiveness when background memory work overlaps active gateway load.
Frequency: observed during managed dreaming cron execution.
Consequence: background memory promotion can consume gateway time and memory during normal operation, contributing to delayed or saturated agent handling.

Additional information

The attached fix bounds managed cron dreaming to a small rotating workspace batch, defers cron-triggered dreaming when process RSS or heap pressure is above warning thresholds, and applies the same cron guard to queued managed heartbeat delivery.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.bugSomething isn't workingclawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.maintainerMaintainer-authored PR

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions