openclaw - 💡(How to fix) Fix Session fork caused by heartbeat compaction loop losing conversation context [1 comments, 2 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#71691Fetched 2026-04-26 05:09:43
View on GitHub
Comments
1
Participants
2
Timeline
1
Reactions
0
Author
Timeline (top)
commented ×1

When a session mixes direct user chat (Telegram) with background subagent work (heartbeats, sherlock runs), the compaction system enters a loop that:

  1. Repeatedly compacts every few seconds
  2. Generates "No goal established — the conversation is empty" summaries despite active conversation history
  3. Gets stuck with tokens around 70k, unable to reduce
  4. Eventually causes OpenClaw to create a new session, losing all previous conversation context

Root Cause

When a session mixes direct user chat (Telegram) with background subagent work (heartbeats, sherlock runs), the compaction system enters a loop that:

  1. Repeatedly compacts every few seconds
  2. Generates "No goal established — the conversation is empty" summaries despite active conversation history
  3. Gets stuck with tokens around 70k, unable to reduce
  4. Eventually causes OpenClaw to create a new session, losing all previous conversation context
RAW_BUFFERClick to expand / collapse

Description

When a session mixes direct user chat (Telegram) with background subagent work (heartbeats, sherlock runs), the compaction system enters a loop that:

  1. Repeatedly compacts every few seconds
  2. Generates "No goal established — the conversation is empty" summaries despite active conversation history
  3. Gets stuck with tokens around 70k, unable to reduce
  4. Eventually causes OpenClaw to create a new session, losing all previous conversation context

Steps to Reproduce

  1. Active Telegram session with ongoing conversation (user chatting about topic X)
  2. Subagents running in background (sherlock investigations, etc.) feeding heartbeat messages into the same session
  3. Heartbeats trigger compaction checks
  4. Compaction runs repeatedly (~9 times in 21 seconds in our case)
  5. Each compaction summary says "conversation is empty" — conversation context is lost
  6. New session is created automatically, user arrives with no context

Evidence

Previous session — 9 compaction events in 21 seconds (17:44:06 to 17:44:27 UTC), all identical:

  • summary: "No goal established — the conversation is empty"
  • firstKeptEntryId: same for all
  • tokensBefore: 70617 to 70908 (barely changing)
  • All triggered by heartbeat messages

New session created at 17:44:53 UTC — 26 seconds after the last compaction burst.

Environment

  • OpenClaw version: 2026.4.21 (f788c88)
  • Model: Z.AI GLM-5 Turbo
  • Compaction mode: default
  • reserveTokens: 40000
  • keepRecentTokens: 30000
  • reserveTokensFloor: 20000
  • Channel: Telegram
  • 60+ child subagent sessions attached

Expected Behavior

Compaction should preserve conversation context (user messages, assistant responses about the active topic) and only compress/remove noise. If heartbeats are causing the issue, they should be excluded from compaction triggers or the compaction summary should accurately reflect the conversation.

Actual Behavior

Compaction erases conversation context, reports empty conversation, loops, and causes session fork — user loses all context from the current chat.

extent analysis

TL;DR

Excluding heartbeat messages from compaction triggers or adjusting compaction settings may resolve the issue of conversation context loss due to repeated compaction loops.

Guidance

  • Review the compaction trigger logic to determine why heartbeat messages are causing repeated compaction checks, and consider excluding them from triggers.
  • Verify the conversation context preservation by checking the keepRecentTokens and reserveTokens settings to ensure they are adequate for the conversation history.
  • Investigate the compaction mode and its impact on the conversation context, considering a potential switch to a different mode if necessary.
  • Analyze the role of subagent sessions and their heartbeat messages in the compaction process to identify potential optimizations.

Example

No code snippet is provided due to the lack of specific implementation details in the issue.

Notes

The issue seems to be related to the interaction between heartbeat messages, compaction triggers, and conversation context preservation. Further investigation into the compaction logic and settings is necessary to determine the root cause and optimal solution.

Recommendation

Apply workaround: Adjust compaction settings, such as keepRecentTokens and reserveTokens, to ensure conversation context preservation, and consider excluding heartbeat messages from compaction triggers to prevent repeated compaction loops. This approach may help mitigate the issue until a more permanent fix is available.

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 Session fork caused by heartbeat compaction loop losing conversation context [1 comments, 2 participants]