Skip to content

Commit 30d4fc1

Browse files
authored
Docs/context compressor (#889)
1 parent b274aac commit 30d4fc1

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

docs/en/Components/Config.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,41 @@ tools:
106106
107107
For the complete list of supported tools and custom tools, please refer to [here](./Tools.md)
108108
109+
## Memory Compression Configuration
110+
111+
> Optional, for context management in long conversations
112+
113+
```yaml
114+
memory:
115+
# Context Compressor: token detection + tool output pruning + LLM summary
116+
context_compressor:
117+
context_limit: 128000 # Model context window size
118+
prune_protect: 40000 # Token threshold to protect recent tool outputs
119+
prune_minimum: 20000 # Minimum pruning amount
120+
reserved_buffer: 20000 # Reserved buffer
121+
enable_summary: true # Enable LLM summary
122+
summary_prompt: | # Custom summary prompt (optional)
123+
Summarize this conversation...
124+
125+
# Refine Condenser: structured compression preserving execution trace
126+
refine_condenser:
127+
threshold: 60000 # Character threshold to trigger compression
128+
system: ... # Custom compression prompt (optional)
129+
130+
# Code Condenser: generate code index files
131+
code_condenser:
132+
system: ... # Custom index generation prompt (optional)
133+
code_wrapper: ['```', '```'] # Code block markers
134+
```
135+
136+
Supported compressor types:
137+
138+
| Type | Use Case | Compression Method |
139+
|------|----------|-------------------|
140+
| `context_compressor` | General long conversations | Token detection + Tool pruning + LLM summary |
141+
| `refine_condenser` | Preserve execution trace | Structured message compression (1:6 ratio) |
142+
| `code_condenser` | Code generation tasks | Generate code index JSON |
143+
109144
## Others
110145

111146
> Optional, configure as needed

docs/zh/Components/config.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,41 @@ tools:
106106
107107
支持的完整工具列表,以及自定义工具请参考 [这里](./tools)
108108
109+
## 内存压缩配置
110+
111+
> 可选,用于长对话场景的上下文管理
112+
113+
```yaml
114+
memory:
115+
# 上下文压缩器:基于token检测 + 工具输出裁剪 + LLM摘要
116+
context_compressor:
117+
context_limit: 128000 # 模型上下文窗口大小
118+
prune_protect: 40000 # 保护最近工具输出的token阈值
119+
prune_minimum: 20000 # 最小裁剪数量
120+
reserved_buffer: 20000 # 预留缓冲区
121+
enable_summary: true # 是否启用LLM摘要
122+
summary_prompt: | # 自定义摘要提示词(可选)
123+
Summarize this conversation...
124+
125+
# 精炼压缩器:保留执行轨迹的结构化压缩
126+
refine_condenser:
127+
threshold: 60000 # 触发压缩的字符阈值
128+
system: ... # 自定义压缩提示词(可选)
129+
130+
# 代码压缩器:生成代码索引文件
131+
code_condenser:
132+
system: ... # 自定义索引生成提示词(可选)
133+
code_wrapper: ['```', '```'] # 代码块标记
134+
```
135+
136+
支持的压缩器类型:
137+
138+
| 类型 | 适用场景 | 压缩方式 |
139+
|------|---------|---------|
140+
| `context_compressor` | 通用长对话 | Token检测 + 工具裁剪 + LLM摘要 |
141+
| `refine_condenser` | 需保留执行轨迹 | 结构化消息压缩(1:6压缩比) |
142+
| `code_condenser` | 代码生成任务 | 生成代码索引JSON |
143+
109144
## 其他
110145

111146
> 可选,按需配置

0 commit comments

Comments
 (0)