MCPcopy Index your code
hub / github.com/docker/docker-agent / keepTokenBudget

Function keepTokenBudget

pkg/runtime/compactor/compactor.go:74–79  ·  view source on GitHub ↗

keepTokenBudget returns the verbatim-keep budget for a compaction, scaled to the context window so that the kept tail plus the summary always leave the post-compaction session well under the compaction threshold. A non-positive contextLimit (hook-supplied summaries may run without a resolvable model

(contextLimit int64)

Source from the content-addressed store, hash-verified

72// run without a resolvable model definition) falls back to the
73// unscaled policy.
74func keepTokenBudget(contextLimit int64) int64 {
75 if contextLimit <= 0 {
76 return maxKeepTokens
77 }
78 return min(maxKeepTokens, contextLimit/5)
79}
80
81// Result is the structural outcome of running a compaction strategy.
82// The runtime applies it to the parent session by appending a

Callers 2

ComputeFirstKeptEntryFunction · 0.85
extractMessagesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected