Check if auto-compaction should be triggered based on token usage. Returns `true` if `used_tokens / max_tokens >= threshold`.
(used_tokens: usize, max_tokens: usize, threshold: f32)
| 139 | /// |
| 140 | /// Returns `true` if `used_tokens / max_tokens >= threshold`. |
| 141 | pub(crate) fn should_auto_compact(used_tokens: usize, max_tokens: usize, threshold: f32) -> bool { |
| 142 | if max_tokens == 0 { |
| 143 | return false; |
| 144 | } |
| 145 | let usage_percent = used_tokens as f32 / max_tokens as f32; |
| 146 | usage_percent >= threshold |
| 147 | } |
| 148 | |
| 149 | /// Prune large tool outputs from messages to reclaim context space. |
| 150 | /// |