shouldCompact returns the usage percentage and whether it exceeds the threshold. Returns (0, false) when contextLimit is non-positive.
(contextTokens, contextLimit int64, thresholdPercent int32)
| 275 | // the threshold. Returns (0, false) when contextLimit is |
| 276 | // non-positive. |
| 277 | func shouldCompact(contextTokens, contextLimit int64, thresholdPercent int32) (float64, bool) { |
| 278 | if contextLimit <= 0 { |
| 279 | return 0, false |
| 280 | } |
| 281 | usagePercent := (float64(contextTokens) / float64(contextLimit)) * 100 |
| 282 | return usagePercent, usagePercent >= float64(thresholdPercent) |
| 283 | } |
| 284 | |
| 285 | func startCompactionDebugRun( |
| 286 | ctx context.Context, |