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
- Have an active Discord thread-bound session with 168k+ tokens of conversation history
- Manually run
/compact command
- OpenClaw immediately cancels with safeguard error
- Wait for automatic compaction to trigger (context continues growing)
- 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
- Add diagnostic logging to identify which messages are being filtered out and why
- Distinguish between "no messages to compact" (valid skip) and "all messages filtered unexpectedly" (potential bug)
- Consider relaxing thread-session message extraction to ensure conversation messages are preserved
Description
Manual
/compactcommand triggered on Discord thread-bound sessions fails with:However, automatic compaction (triggered by OpenClaw internally) on the same session completes successfully moments later.
Steps to Reproduce
/compactcommandExpected Behavior
Manual
/compactshould succeed, or at least provide more specific diagnostic info about which messages were filtered out.Actual Behavior
Compaction failed: Compaction cancelledCompacted (168k → X tokens)✓Root Cause Analysis
Code at
src/agents/pi-extensions/compaction-safeguard.ts:578:The safeguard correctly detects when
messagesToSummarizecontains 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
discord:channel:1480626269652652052)Suggested Fix