# Compaction

OpenClaw's compaction feature manages context window limitations by summarizing older conversation history while preserving recent messages.

## What Compaction Does

Compaction summarizes older conversation into a compact summary entry and keeps recent messages intact. The summaries remain stored in session history for future reference.

## Two Compaction Types

### Auto-compaction

Triggers automatically when sessions approach or exceed the model's context limits. Users see a "Auto-compaction complete" notification in verbose mode.

### Manual compaction

Initiated via the `/compact` command, optionally with custom instructions like "Focus on decisions and open questions."

## Compaction vs Session Pruning

| Feature | Compaction | Session Pruning |
|---------|------------|-----------------|
| Action | Summarizes and persists in JSONL | Trims old tool results only |
| Scope | Full conversation history | In-memory, per request |
| Persistence | Permanent | Temporary |

## Practical Guidance

- Use `/compact` when sessions feel outdated or context becomes bloated
- Use `/new` or `/reset` when starting fresh sessions is preferred

## Related Documentation

- [Session Management](/concepts/session)
- [Session Pruning](/concepts/session-pruning)
- [Context](/concepts/context)
