Files
myWiki/concepts/context-pruning.md
2026-06-01 10:46:01 +08:00

41 lines
1.5 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: "Context Pruning (上下文剪枝)"
created: 2026-05-29
updated: 2026-05-29
type: concept
tags: ["distributed-systems", "resilience", "LLM", "degradation"]
sources: ["https://mp.weixin.qq.com/s/MUWV7eug14bktUMlqsxfQw"]
---
# Context Pruning (上下文剪枝)
**Context Pruning** 是分布式 Agent 系统在遭遇网络分区或 [[cache-cold-start]] 时的紧急降级策略:主动将长历史上下文切除,仅保留最核心的 System Prompt 与最近几轮对话(通常不超过 8k Token
## 触发条件
- 分布式路由表查询超时(毫秒级硬上限)
- 跨机主动预热流水线失败
- Redis 骨干网连接丢失
## 降级流程
1. **切断跨机预热**:立即停用 [[active-cache-warmup]]
2. **本地孤岛模式**:会话降级为单机运行
3. **内存剪枝**:切除长历史上下文,保留 System Prompt + 最近三轮对话
4. **硬控制延迟**:将冷启动延迟硬控制在阈值以内
## 权衡
- **牺牲推理深度**:裁剪后上下文信息减少,可能降低决策质量
- **保证可达性**:风控平仓等关键指令的绝对可达性优先于推理深度
## 在混沌工程中的角色
Context Pruning 是分布式缓存系统的最后一道防线——当所有优化机制(预热、路由、一致性)都失败时,确保系统仍能完成核心功能。
## 相关
- [[cache-cold-start]] — Pruning 应对的问题
- [[active-cache-warmup]] — Pruning 的"上游"机制(优先使用)
- [[distributed-prompt-caching]] — 分布式缓存体系