Tutorial
Pruning and compaction trade context length for a smaller prompt. That can lower latency or provider cost, but it can also remove the exact instruction, file path, or approval detail that explains a later action. Choose the boundary from the workflow, not from a fixed token target.
What to keep
- Keep the current task, constraints, and expected output.
- Keep tool results that prove what changed or failed.
- Keep a short pointer to older context instead of copying an entire transcript.
A support handoff may need more history than a short coding task. Review both paths with synthetic data before changing defaults on a shared Gateway.
openclaw gateway status
openclaw doctor
Measure the trade-off
- Run the same task with the current session policy.
- Record response quality, latency, provider usage, and the details a reviewer can still see.
- Change one threshold at a time.
- Repeat the test after an update because session behavior can change between releases.
The session pruning reference, session concepts, and token-use notes are the current sources for implementation details.
Reference Trail
Sources and further reading
- session pruning referencedocs.openclaw.ai
- session conceptsdocs.openclaw.ai
- token-use notesdocs.openclaw.ai