Files
nexus/wiki/concepts/上下文修剪.md
2026-04-18 00:18:08 +08:00

33 lines
1003 B
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, context]
last_updated: 2026-04-02
---
## Definition
通过 TTL生存时间和保留策略主动清理旧上下文的机制与内存刷新配合工作。
## Configuration
```json
{
"contextPruning": {
"mode": "cache-ttl",
"ttl": "6h",
"keepLastAssistants": 3
}
}
```
## Mechanism
- 6 小时后积极修剪旧上下文
- 保留最后 3 个 Assistants 响应
- 结合内存刷新Agent 早期将重要内容写入磁盘,旧上下文在导致溢出前被清理
## Key Insight
长会话是内存系统真正接受测试的地方。短对话很少触及压缩。是 2 小时的深度工作会话中你会丢失上下文且无法找出原因。**在负载下测试你的内存系统,而不仅仅是在快速聊天中。**
## Related
- [[上下文压缩]] — 导致信息丢失的机制
- [[内存刷新]] — 在压缩前将重要内容写入磁盘
- [[上下文窗口]] — 有限的对话历史容纳量