Skip to content

Manual /compact command fails with 'no real conversation messages' on Discord thread sessions #44138

@CharZhou

Description

@CharZhou

Description

Manual /compact command triggered on Discord thread-bound sessions fails with:

[compaction-safeguard] Compaction safeguard: cancelling compaction with no real conversation messages to summarize.

However, automatic compaction (triggered by OpenClaw internally) on the same session completes successfully moments later.

Steps to Reproduce

  1. Have an active Discord thread-bound session with 168k+ tokens of conversation history
  2. Manually run /compact command
  3. OpenClaw immediately cancels with safeguard error
  4. Wait for automatic compaction to trigger (context continues growing)
  5. Automatic compaction succeeds, creating a summary

Expected Behavior

Manual /compact should succeed, or at least provide more specific diagnostic info about which messages were filtered out.

Actual Behavior

  • Manual: Compaction failed: Compaction cancelled
  • Auto: Compacted (168k → X tokens)

Root Cause Analysis

Code at src/agents/pi-extensions/compaction-safeguard.ts:578:

if (!preparation.messagesToSummarize.some(isRealConversationMessage)) {
    log.warn(
        "Compaction safeguard: cancelling compaction with no real conversation messages to summarize.",
    );
    return { cancel: true };
}

The safeguard correctly detects when messagesToSummarize contains no user/assistant/toolResult messages. However, on Discord thread sessions, the message extraction/filtering logic appears to be stripping out all valid conversation messages before reaching the safeguard.

Hypothesis: Discord thread session keys or post-compaction session state may trigger a different message-extraction path that incorrectly filters messages.

Environment

  • OpenClaw: 2026.3.2
  • Session type: Discord thread-bound (discord:channel:1480626269652652052)
  • Context: 168k/200k tokens
  • Manual trigger: Yes, within minutes of automatic compaction succeeding

Suggested Fix

  1. Add diagnostic logging to identify which messages are being filtered out and why
  2. Distinguish between "no messages to compact" (valid skip) and "all messages filtered unexpectedly" (potential bug)
  3. Consider relaxing thread-session message extraction to ensure conversation messages are preserved

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