MCPcopy Index your code
hub / github.com/coder/coder / shouldCompact

Function shouldCompact

coderd/x/chatd/chatloop/compaction.go:277–283  ·  view source on GitHub ↗

shouldCompact returns the usage percentage and whether it exceeds the threshold. Returns (0, false) when contextLimit is non-positive.

(contextTokens, contextLimit int64, thresholdPercent int32)

Source from the content-addressed store, hash-verified

275// the threshold. Returns (0, false) when contextLimit is
276// non-positive.
277func 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
285func startCompactionDebugRun(
286 ctx context.Context,

Callers 1

tryCompactFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected