Auto-sync: 2026-04-18 00:18

This commit is contained in:
2026-04-18 00:18:08 +08:00
parent 7a7a35f726
commit 5ce3ede529
25 changed files with 694 additions and 2 deletions

View File

@@ -0,0 +1,33 @@
---
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
- [[上下文压缩]] — 导致信息丢失的机制
- [[内存刷新]] — 在压缩前将重要内容写入磁盘
- [[上下文窗口]] — 有限的对话历史容纳量