openclaw - 💡(How to fix) Fix Heartbeat sessions never compact — memory system incompatible with short-session agent patterns [1 comments, 1 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#60719Fetched 2026-04-08 02:47:59
View on GitHub
Comments
1
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
commented ×1

Root Cause

This affects every Paperclip user running heartbeat-driven agents. The most valuable agent patterns (daily standups, recurring checks, monitoring) are systematically lost to memory. The agent becomes a commodity consumer of tokens with zero institutional memory.

Code Example

Paperclip heartbeat fires → new short session (500 tokens) → agent does work → session ends
→ repeat every 15 minutes → never hits context limit → never compacts → never writes to memory
RAW_BUFFERClick to expand / collapse

Problem

OpenClaw's memory system relies on session compaction as the trigger for writing summaries to memory. Compaction only fires when a session approaches the model's context limit.

With modern context windows (200K+ tokens), short sessions — particularly heartbeat-driven sessions — may never approach the context limit. A typical heartbeat session might be 500 tokens. With a 200K context window, it would need to run ~400 times before triggering compaction.

This creates a critical failure mode for Paperclip-style agents:

Paperclip heartbeat fires → new short session (500 tokens) → agent does work → session ends
→ repeat every 15 minutes → never hits context limit → never compacts → never writes to memory

Result: Thousands of dollars of agent work, weeks of heartbeat cycles, and zero memory persistence. All that pattern data evaporates when sessions close.

Specific failure modes

  1. Heartbeat sessions — designed to be short and frequent, below compaction threshold
  2. Paperclip-driven sessions — each wake = fresh session = isolated context = no accumulation
  3. High-context agents — with large context windows, even hours of work may not trigger compaction

Current architecture

Memory flow:

  1. Session runs → grows toward context limit
  2. Near limit → compaction fires → agent reminded to save notes to memory
  3. Memory flush → QMD indexes the markdown
  4. Short sessions never reach step 1

Proposed solutions (pick one)

Option A: Configurable compaction interval Force compaction after N sessions or N hours, regardless of token count. E.g., compaction: { forceAfterSessions: 50 }

Option B: Heartbeat memory flush A heartbeat-specific memory write that fires on session end without waiting for compaction. Small, consistent, guaranteed.

Option C: Session summary on close Every session writes a mandatory one-line summary to memory on close, even if never compacted.

Why this matters

This affects every Paperclip user running heartbeat-driven agents. The most valuable agent patterns (daily standups, recurring checks, monitoring) are systematically lost to memory. The agent becomes a commodity consumer of tokens with zero institutional memory.

Environment

OpenClaw 2026.4.2, MiniMax M2.7 (200K+ context), Paperclip heartbeat cadence

extent analysis

TL;DR

Implement a configurable compaction interval or a heartbeat-specific memory write to ensure session data is persisted to memory, even for short sessions that don't reach the context limit.

Guidance

  • Consider implementing Option A: Configurable compaction interval, which allows forcing compaction after a specified number of sessions or hours, regardless of token count.
  • Evaluate Option B: Heartbeat memory flush, which involves writing a heartbeat-specific memory update on session end, without waiting for compaction.
  • Assess the feasibility of Option C: Session summary on close, where every session writes a mandatory one-line summary to memory on close, even if never compacted.
  • Weigh the trade-offs between these options, considering factors such as performance, data consistency, and agent behavior.

Example

// Example configuration for Option A
const compactionConfig = {
  forceAfterSessions: 50
};

Notes

The choice of solution depends on the specific requirements and constraints of the OpenClaw and Paperclip setup. It's essential to consider the potential impact on performance, data consistency, and agent behavior when selecting a solution.

Recommendation

Apply Option B: Heartbeat memory flush, as it provides a small, consistent, and guaranteed memory write on session end, which can help mitigate the critical failure mode of losing valuable agent patterns.

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

openclaw - 💡(How to fix) Fix Heartbeat sessions never compact — memory system incompatible with short-session agent patterns [1 comments, 1 participants]