MCPcopy Create free account
hub / github.com/AI45Lab/Code / should_auto_compact

Function should_auto_compact

core/src/compaction.rs:141–147  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

139///
140/// Returns `true` if `used_tokens / max_tokens >= threshold`.
141pub(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///

Callers 1

maybe_auto_compactMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected