Files
nexus/wiki/concepts/内存刷新.md
2026-04-18 00:18:08 +08:00

34 lines
1.0 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: "内存刷新"
type: concept
tags: [ai-agent, memory, persistence]
last_updated: 2026-04-02
---
## Definition
在压缩触发前,提醒 Agent 将重要上下文写入磁盘的机制,确保重要内容在压缩擦除后仍能存活。
## Mechanism
当会话接近上下文限制时OpenClaw 触发一个静默回合,提醒 Agent 在压缩运行前将持久事实保存到 memory/YYYY-MM-DD.md。
## Configuration
```json
{
"compaction": {
"memoryFlush": {
"enabled": true,
"softThresholdTokens": 4000
}
}
}
```
> 注意4000 这个数值要根据使用的模型来调整。使用 Gemini/Claude/GPT-4.1 等大模型(上下文窗口 32K/128K/200K tokens4000 太保守,会导致频繁的 summary 和上下文"碎片化"。
## Key Insight
如果只在上下文窗口中,它是临时的。如果在磁盘上,它就能存活。
## Related
- [[上下文压缩]] — 导致信息丢失的机制
- [[上下文窗口]] — 有限的对话历史容纳量
- [[上下文记忆]] — AI Agent 保留对话历史的能力