Skip to content

🐛 Bug: OpenClaw compaction after context_window_exceeded silently kills session — all conversation memory lost #60213

@xiaotong2026

Description

@xiaotong2026

Description

A session was silently abandoned after compaction, causing complete loss of conversation context. The user's agent lost all memory of the conversation and could not recall anything discussed earlier.

Steps to Reproduce

  1. Let a session grow large enough to trigger \model_context_window_exceeded\ from the provider
  2. Safeguard compaction kicks in — two consecutive compaction events fire within 1 second
  3. The session file receives no further writes after compaction
  4. On the next incoming message, OpenClaw creates a brand new empty session instead of resuming the compacted one
  5. Result: the agent starts with zero conversation context — complete amnesia

Expected Behavior

After compaction, the session should resume with the compacted summary. The agent should remember what was discussed before compaction.

What Actually Happened

  • Old session file exists on disk (not reset, not deleted — just orphaned)
  • New session is created from scratch
  • Agent has no recollection of any prior conversation
  • Only way to recover context is by reading the orphaned session file manually

Possible Root Causes

  1. Double-compaction race condition? Two compaction events fired within 1 second — could this corrupt the session state?
  2. Error recovery failure? \model_context_window_exceeded\ → compaction → but the error may leave the session in an unrecoverable state
  3. Session routing logic may have a fallback path that creates a new session when it can't load the compacted state

Environment

  • OpenClaw 2026.4.1 (da64a97)
  • Provider: zai (GLM-5-turbo, OpenAI-compatible API)
  • compaction.mode: safeguard
  • session.reset: not configured (default daily)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions