Files
nexus/wiki/concepts/Compaction.md

27 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "Compaction"
type: concept
last_updated: 2026-04-10
---
## Definition
Compaction 是 OpenClaw 对话上下文压缩机制,用于在 token 接近上限时将历史对话压缩为摘要,释放上下文空间。
## Safeguard Mode
在 safeguard 模式下OpenClaw 会预留 16K tokens 用于执行压缩操作:
- `reserveTokensFloor`: 压缩预留 token 下限
- 当模型 context window 较小时(如 deepseek-reasoner 的 16K预留空间与 context 相等导致实际可用空间为 0
## Configuration Levels
- **全局配置** (`openclaw.json`): 影响所有 Agent
- **Agent 级别配置** (routing rules): 影响特定 Agent/Channel优先级更高
## Related
- [[Context-Window]]: 压缩的必要性来自 context window 的限制
- [[Agent-Routing-Rules]]: Agent 级别配置可能覆盖全局 compaction 设置
- [[上下文压缩]]: 已在 [[养龙虾5天血泪史]] 中详细讨论
## Sources
- [[养虾日记4-一次「context-limit-exceeded」错误排查-我以为是小问题-结果踩了大坑]]
- [[养龙虾5天血泪史-我的ai-agent为什么总失忆-openclaw-记忆调试全记录]]