openclaw - 💡(How to fix) Fix diagnostics/memory: wire thresholds parameter to config (rssWarningBytes/rssCriticalBytes/heapUsedWarningBytes/heapUsedCriticalBytes)

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…

dist/diagnostic-D__kDNwM.js's emitDiagnosticMemorySample accepts a thresholds parameter (which resolveThresholds correctly merges with defaults), but no caller in the bundled gateway ever passes a value. The heartbeat path at line 1120 invokes it as:

emitDiagnosticMemorySample({
  emitSample: shouldRecordMemorySample,
  writeCriticalBundle: shouldWriteCriticalMemoryPressureBundle(heartbeatConfig),
  resolveSessionStorePaths: () => resolveDiagnosticSessionStorePaths(heartbeatConfig)
});

…with no thresholds. As a result the four hardcoded defaults in diagnostic-D__kDNwM.js:18-21 (RSS warn 1.5 GB / crit 3 GB, heap warn 1 GB / crit 2 GB) cannot be tuned without patching the dist bundle, which gets clobbered on every openclaw update.

The Zod schema (zod-schema-Cd4_GACR.js:965-1010) exposes diagnostics.memoryPressureSnapshot and other diagnostics fields but no threshold knobs.

Error Message

…with no thresholds. As a result the four hardcoded defaults in diagnostic-D__kDNwM.js:18-21 (RSS warn 1.5 GB / crit 3 GB, heap warn 1 GB / crit 2 GB) cannot be tuned without patching the dist bundle, which gets clobbered on every openclaw update.

Root Cause

dist/diagnostic-D__kDNwM.js's emitDiagnosticMemorySample accepts a thresholds parameter (which resolveThresholds correctly merges with defaults), but no caller in the bundled gateway ever passes a value. The heartbeat path at line 1120 invokes it as:

emitDiagnosticMemorySample({
  emitSample: shouldRecordMemorySample,
  writeCriticalBundle: shouldWriteCriticalMemoryPressureBundle(heartbeatConfig),
  resolveSessionStorePaths: () => resolveDiagnosticSessionStorePaths(heartbeatConfig)
});

…with no thresholds. As a result the four hardcoded defaults in diagnostic-D__kDNwM.js:18-21 (RSS warn 1.5 GB / crit 3 GB, heap warn 1 GB / crit 2 GB) cannot be tuned without patching the dist bundle, which gets clobbered on every openclaw update.

The Zod schema (zod-schema-Cd4_GACR.js:965-1010) exposes diagnostics.memoryPressureSnapshot and other diagnostics fields but no threshold knobs.

Fix Action

Fix / Workaround

…with no thresholds. As a result the four hardcoded defaults in diagnostic-D__kDNwM.js:18-21 (RSS warn 1.5 GB / crit 3 GB, heap warn 1 GB / crit 2 GB) cannot be tuned without patching the dist bundle, which gets clobbered on every openclaw update.

Even just an env-var override (e.g. OPENCLAW_RSS_WARNING_MB) would be a strict improvement over the current "patch the bundle" workaround.

Code Example

emitDiagnosticMemorySample({
  emitSample: shouldRecordMemorySample,
  writeCriticalBundle: shouldWriteCriticalMemoryPressureBundle(heartbeatConfig),
  resolveSessionStorePaths: () => resolveDiagnosticSessionStorePaths(heartbeatConfig)
});

---

[diagnostics/memory] memory pressure: level=warning reason=rss_threshold rssBytes=... thresholdBytes=1610612736

---

"diagnostics": {
  "memory": {
    "rssWarningBytes": 4294967296,      // 4 GB
    "rssCriticalBytes": 8589934592,     // 8 GB
    "heapUsedWarningBytes": 2147483648, // 2 GB
    "heapUsedCriticalBytes": 4294967296 // 4 GB
  }
}
RAW_BUFFERClick to expand / collapse

OpenClaw version: 2026.5.26

Summary

dist/diagnostic-D__kDNwM.js's emitDiagnosticMemorySample accepts a thresholds parameter (which resolveThresholds correctly merges with defaults), but no caller in the bundled gateway ever passes a value. The heartbeat path at line 1120 invokes it as:

emitDiagnosticMemorySample({
  emitSample: shouldRecordMemorySample,
  writeCriticalBundle: shouldWriteCriticalMemoryPressureBundle(heartbeatConfig),
  resolveSessionStorePaths: () => resolveDiagnosticSessionStorePaths(heartbeatConfig)
});

…with no thresholds. As a result the four hardcoded defaults in diagnostic-D__kDNwM.js:18-21 (RSS warn 1.5 GB / crit 3 GB, heap warn 1 GB / crit 2 GB) cannot be tuned without patching the dist bundle, which gets clobbered on every openclaw update.

The Zod schema (zod-schema-Cd4_GACR.js:965-1010) exposes diagnostics.memoryPressureSnapshot and other diagnostics fields but no threshold knobs.

Repro

Run a gateway with healthy steady-state usage above ~1.5 GB RSS (easy on a busy host with several plugins + AGENTS.md hooks loaded). The log fills with:

[diagnostics/memory] memory pressure: level=warning reason=rss_threshold rssBytes=... thresholdBytes=1610612736

These warnings have no behavioral effect (per logMemoryPressure at line 114-118, warning is log.info, and critical only triggers a snapshot bundle if diagnostics.memoryPressureSnapshot=true) — so they're pure noise on hosts where the true working set legitimately exceeds 1.5 GB RSS.

Proposed fix

Add a diagnostics.memory.thresholds config block to the schema:

"diagnostics": {
  "memory": {
    "rssWarningBytes": 4294967296,      // 4 GB
    "rssCriticalBytes": 8589934592,     // 8 GB
    "heapUsedWarningBytes": 2147483648, // 2 GB
    "heapUsedCriticalBytes": 4294967296 // 4 GB
  }
}

…and thread it through to the heartbeat caller so emitDiagnosticMemorySample actually receives the resolved values. The thresholds parameter and resolveThresholds helper already exist — this is purely a wiring + schema change.

Alternative

Even just an env-var override (e.g. OPENCLAW_RSS_WARNING_MB) would be a strict improvement over the current "patch the bundle" workaround.

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