压缩配置。 preserve_recent_messages: 保留最近几条消息(不压缩它们) max_estimated_tokens: 超过多少 token 就触发压缩 对应源码: compact.rs:4-16
| 131 | |
| 132 | @dataclass(frozen=True) |
| 133 | class CompactionConfig: |
| 134 | """ |
| 135 | 压缩配置。 |
| 136 | |
| 137 | preserve_recent_messages: 保留最近几条消息(不压缩它们) |
| 138 | max_estimated_tokens: 超过多少 token 就触发压缩 |
| 139 | |
| 140 | 对应源码: compact.rs:4-16 |
| 141 | """ |
| 142 | preserve_recent_messages: int = 4 # 默认保留最近 4 条 |
| 143 | max_estimated_tokens: int = 10_000 # 默认 10k token 就压缩 |
| 144 | |
| 145 | |
| 146 | def should_compact(session: Session, config: CompactionConfig) -> bool: |
no outgoing calls
no test coverage detected