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