Managing Long Conversations with OpenClaw Compaction
I have often hit that wall where a chat session gets too long. The model starts losing track of the early parts of the conversation, or the request fails because I have exceeded the token limit. It is a common headache to manage these limits while trying to maintain the context of a long-running project.
OpenClaw handles this by using compaction. Instead of just cutting off your old messages, it summarizes them so the model stays informed without hitting the context ceiling.
What You’ll Need
Section titled “What You’ll Need”- A configured model provider catalog (to determine context limits)
- Access to the
agents.defaults.compactionsettings - Verbose mode enabled (if you want to see compaction logs)
- The
/statuscommand to monitor session health
Quick Start
Section titled “Quick Start”OpenClaw enables auto-compaction by default. When your session gets close to the model’s context window, the system automatically summarizes the older history into a single entry. This summary and your most recent messages are then used for future requests.
1. Monitor Auto-Compaction
Section titled “1. Monitor Auto-Compaction”If you are running in verbose mode, you will see a notification when the system cleans up the history:
🧹 Auto-compaction complete
You can check how many times this has happened by typing:
/status
2. Manual Compaction
Section titled “2. Manual Compaction”If the session feels stale or the context is getting bloated, you can force a compaction pass yourself. You can even give it specific instructions on what to prioritize in the summary.
/compact Focus on decisions and open questions3. Understanding Persistence
Section titled “3. Understanding Persistence”Unlike simple pruning, compaction is permanent. The summary is stored in your session’s JSONL history file. This ensures that the condensed context remains available even if you restart the session later.
Troubleshooting
Section titled “Troubleshooting”- Session feels stale: If the model is stuck on old details, use
/compactto refresh the context. - Context is still too large: Large tool outputs are truncated by default, but you might need session pruning to trim tool results in-memory.
- Need a fresh start: If compaction isn’t enough and you want a clean slate, use
/newor/resetto start a new session ID. - Memory loss: Before compaction, OpenClaw can run a silent memory flush to save durable notes to disk. Check your memory configuration if you lose specific details.
If you have questions about your specific setup, check the AI Setup Assistant.
What’s Next
Section titled “What’s Next”OpenClaw Expert
Still stuck?
If this page didn't answer your case, ask OpenClaw Expert for step-by-step guidance.