20260514:增加新内容

This commit is contained in:
2026-05-14 13:54:52 +08:00
parent 56c4d3ef7c
commit b116710e4c
294 changed files with 10682 additions and 255 deletions

View File

@@ -0,0 +1,31 @@
---
title: "Context Compression上下文压缩"
created: 2026-05-11
updated: 2026-05-11
type: concept
tags: [context-management, summarization, agent-architecture]
sources: [[prompt-caching-architecture]]
---
# Context Compression上下文压缩
## 定义
Context Compression 是当 Agent 对话长度触及 Context Window 限制时,对历史对话进行摘要压缩的技术。其核心挑战是在压缩过程中避免触发 [[cache-invalidation|缓存失效]]。
## 两种压缩方式
| 方式 | 做法 | 缓存影响 |
|------|------|----------|
| 传统(错误) | 独立 API 调用,使用默认 System Prompt | 前缀不一致 → 缓存全失效 |
| [[cache-safe-forking|Cache-Safe Forking]] | 复用父会话完整前缀 | 仅最后几百 Token 需计算 |
## 工程陷阱
最常见的错误:发起新的独立 API 调用请求总结,该调用使用与原始会话不同的 System Prompt → 完全前缀不一致 → 成本剧增。
## 相关概念
- [[cache-safe-forking|缓存安全分叉]]
- [[prompt-caching|Prompt Caching]]
- [[agentic-systems|Agentic Systems]]