openclaw - 💡(How to fix) Fix Compaction results in full context reset instead of compression [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#57410Fetched 2026-04-08 01:49:57
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0

Code Example

/compact 重点保留: 1) project architecture 2) key decisions 3) current state
RAW_BUFFERClick to expand / collapse

Bug Description

/compact (and automatic compaction when context is full) results in a full context reset instead of compressing the conversation history. The agent loses all conversational continuity.

Expected Behavior

When compaction triggers (manually via /compact or automatically when context fills up), the context should be compressed to ~15-25% of its size, preserving a summary of the conversation. This is how it worked ~1 month ago (late February 2025).

Actual Behavior

Compaction completely resets the context. The agent starts fresh with no memory of the conversation. Context drops from 700K+ tokens to ~29K (just system prompt).

Steps to Reproduce

  1. Have a long conversation until context reaches 70%+ (e.g., ~730K/1M tokens)
  2. Send /compact with preservation instructions, e.g.:
    /compact 重点保留: 1) project architecture 2) key decisions 3) current state
  3. Result: Context resets to ~29K tokens. Agent has zero memory of the conversation.
  4. Running /status after compact shows: Context: 29k/1.0m (3%) · Compactions: 0

Evidence

  • The Compactions: 0 counter after the supposed compaction confirms it did not actually compact — it reset.
  • One month ago (late Feb), compaction worked correctly: it took a few minutes, compressed to ~15-20%, and the agent retained conversation continuity.
  • This regression appears to have started in the last 2-3 weeks.

Environment

  • OpenClaw version: 2026.3.24 (208ff68)
  • Model: anthropic/claude-opus-4-6
  • Channel: Telegram
  • Context window: 1M tokens
  • OS: macOS (Darwin 25.2.0 arm64)

Impact

This is a critical regression. Without working compaction, users must either:

  • Lose all conversation context when the window fills up (automatic reset)
  • Manually save important context to files before every reset
  • Avoid long conversations entirely

The whole value of compaction is maintaining continuity. A reset defeats the purpose entirely.

extent analysis

Fix Plan

To resolve the issue of context reset during compaction, we need to modify the compaction logic to preserve conversation continuity.

Here are the steps to fix the issue:

  • Update the compaction function to compress the conversation history instead of resetting it.
  • Modify the preservation instructions to correctly identify and retain key conversation points.
  • Adjust the compaction threshold to trigger at the correct context size.

Example code changes:

def compact_context(context, preservation_instructions):
    # Compress conversation history to 15-25% of its size
    compressed_context = compress_context(context, 0.15, 0.25)
    
    # Preserve key conversation points based on instructions
    preserved_context = preserve_key_points(compressed_context, preservation_instructions)
    
    return preserved_context

def compress_context(context, min_ratio, max_ratio):
    # Implement compression logic to reduce context size
    # while maintaining essential information
    compressed_context = []
    for message in context:
        # Apply compression techniques such as summarization or filtering
        compressed_message = compress_message(message)
        compressed_context.append(compressed_message)
    
    # Ensure compressed context size is within the desired ratio
    while len(compressed_context) < min_ratio * len(context):
        compressed_context.append("")
    while len(compressed_context) > max_ratio * len(context):
        compressed_context.pop()
    
    return compressed_context

def preserve_key_points(context, preservation_instructions):
    # Identify and retain key conversation points based on instructions
    preserved_context = []
    for instruction in preservation_instructions:
        # Apply preservation logic to retain relevant information
        preserved_message = preserve_message(context, instruction)
        preserved_context.append(preserved_message)
    
    return preserved_context

Verification

To verify the fix, follow these steps:

  • Test the compaction function with a sample conversation context and preservation instructions.
  • Check the compressed context size to ensure it is within the desired ratio (15-25%).
  • Verify that key conversation points are preserved correctly based on the preservation instructions.
  • Test the compaction function with different conversation contexts and preservation instructions to ensure it works as expected.

Extra Tips

  • Regularly review and update the compaction logic to ensure it adapts to changing conversation patterns and user needs.
  • Consider implementing additional features such as context summarization or filtering to further improve conversation continuity.
  • Monitor user feedback and adjust the compaction threshold and preservation instructions accordingly to optimize the conversation experience.

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